Skip to content

fix: native Python agent for Render deployment#53

Merged
GeneralJerel merged 3 commits intomainfrom
fix/native-python-agent
Mar 25, 2026
Merged

fix: native Python agent for Render deployment#53
GeneralJerel merged 3 commits intomainfrom
fix/native-python-agent

Conversation

@GeneralJerel
Copy link
Copy Markdown
Collaborator

Summary

  • Replace langchain/langgraph-api Docker image with native FastAPI + ag_ui_langgraph server, eliminating the PostgreSQL dependency that blocked Render deployment
  • Add BoundedMemorySaver (200 thread cap, FIFO eviction) for memory-safe checkpointing on Render's 512MB starter plan
  • Switch frontend from LangGraphAgent to LangGraphHttpAgent (AG-UI protocol)
  • Add Three.js coordinate conventions to fix consistent aircraft axis swap in 3D visualizations

Test plan

  • Agent starts and /health returns {"status":"ok"}
  • Frontend connects and chat works end-to-end
  • Render deploys agent as native Python (no Docker)
  • Render health check passes on /health

🤖 Generated with Claude Code

GeneralJerel and others added 2 commits March 25, 2026 13:45
The langgraph-api Docker image requires PostgreSQL (DATABASE_URI) which
blocked Render deployment. Switch to serving the agent directly via
FastAPI + ag_ui_langgraph, matching the Shadify reference pattern.

- Replace Dockerfile.agent with native Python runtime on Render
- Add BoundedMemorySaver for memory-safe checkpointing (200 thread cap)
- Switch frontend from LangGraphAgent to LangGraphHttpAgent (AG-UI protocol)
- Remove langgraph-api, langgraph-cli deps (-25 packages)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The LLM consistently builds aircraft with the wing as the fuselage
(long axis along X instead of Z), causing pitch and roll to appear
swapped. Add explicit axis conventions, correct geometry patterns,
and flight dynamics rotation mapping to the visualization skill.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@GeneralJerel
Copy link
Copy Markdown
Collaborator Author

PR Review

Overview

Solid PR. Replaces the langgraph-api Docker image (which required PostgreSQL) with a native FastAPI server, unblocking Render deployment. Net -134 lines — nice cleanup.

Findings

1. BoundedMemorySaver.put() — eviction loop can desync (Medium)

apps/agent/src/bounded_memory_saver.py:46-54 — If a thread is evicted from _insertion_order but was already deleted from self.storage by some other path, the while loop pops from _insertion_order without actually shrinking self.storage, potentially looping until _insertion_order is empty. The if oldest_thread in self.storage guard skips the delete but doesn't re-check the loop condition against the right collection.

Consider adding a secondary guard:

while len(self.storage) > self.max_threads and self._insertion_order:

2. warnings.filterwarnings placement (Low)

apps/agent/main.py:98 — The pydantic warning filter is set after add_langgraph_fastapi_endpoint and agent creation, which is where most pydantic warnings fire (during model validation at import/construction time). Move it before agent = create_deep_agent(...) to actually suppress those warnings.

3. render.yamlLANGGRAPH_DEPLOYMENT_URL uses hostport (Low, verify)

render.yaml:48-51 — The frontend normalizes bare host:port into http:// at route.ts:40-44, which is good. Just confirm Render's internal service communication is plain HTTP (not HTTPS) — if Render uses TLS between services, this would need https://.

4. Dockerfile.agent deleted but .env.example not updated (Nit)

The Dockerfile is removed — if .env.example or README referenced Docker-based setup for the agent, those docs may be stale. Worth a quick check.

What looks good

  • Clean separation: FastAPI app setup is straightforward
  • BoundedMemorySaver concept is well-reasoned for the 512MB constraint, with good docstring noting the MemorySaver.storage internal dependency and version pin
  • Frontend LangGraphAgentLangGraphHttpAgent switch is correct for AG-UI protocol
  • Dependency cleanup removes ~25 packages (langgraph-api, langgraph-cli, etc.)
  • Health check endpoint enables Render's health monitoring
  • Three.js coordinate convention docs are clear and well-structured

Verdict

Ship it with the while loop guard fix (finding #1). The rest are minor.

Prevent infinite loop if _insertion_order empties before storage
shrinks below max_threads due to external deletions.
@GeneralJerel GeneralJerel merged commit fb2c361 into main Mar 25, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant