Deep Agents Code Review
When reviewing Deep Agents code, check for these categories of issues.
Review gates (evidence-bound)
Run these steps in order before and while you write findings. Skipping a step is a failed review.
- Locate — Enumerate call sites in scope (
create_deep_agent,CompiledSubAgent,CompositeBackend, custombackend=,interrupt_on,checkpointer,store). Pass: You list each relevant file path and line number (or a grep/search result that proves where the code lives). - Anchor — For each suspected issue, tie it to quoted or line-referenced code from those files, not to imports or names alone. Pass: Every finding includes evidence (
path:lineplus a short quote or “absent parameter” note showing the gap). - Classify — Map each anchored issue to one category below (Critical → Performance) and a severity. Pass: The category label matches what the cited code actually does or omits.
- Runtime claims — If you say something will error, fail at runtime, or leak data, Pass: The cited snippet shows the exact API combo (e.g.
interrupt_onset with nocheckpointerin the same construction path), or you state uncertain and what would confirm it.
If you cannot satisfy step 1, stop and say what file or search is missing instead of inferring issues from memory.
Critical Issues
1. Missing Checkpointer with interrupt_on
# BAD - interrupt_on without checkpointer
agent = create_deep_agent(
tools=[send_email],
interrupt_on={"send_email": True},
# No checkpointer! Interrupts will fail
)
# GOOD - checkpointer required for interrupts
from langgraph.checkpoint.memory import InMemorySaver
agent = create_deep_agent(
tools=[send_email],
interrupt_on={"send_email": True},
checkpointer=InMemorySaver(),
)
2. Missing Store with StoreBackend
# BAD - StoreBackend without store
from deepagents.backends import StoreBackend
agent = create_deep_agent(
backend=lambda rt: StoreBackend(rt),
# No store! Will raise ValueError at runtime
)
# GOOD - provide store
from langgraph.store.memory import InMemoryStore
store = InMemoryStore()
agent = create_deep_agent(
backend=lambda rt: StoreBackend(rt),
store=store,
)
3. Missing thread_id with Checkpointer
# BAD - no thread_id when using checkpointer
agent = create_deep_agent(checkpointer=InMemorySaver())
agent.invoke({"messages": [...]}) # Error!
# GOOD - always provide thread_id
config = {"configurable": {"thread_id": "user-123"}}
agent.invoke({"messages": [...]}, config)
4. Relative Paths in Filesystem Tools
# BAD - relative paths not supported
read_file(path="src/main.py")
read_file(path="./config.json")
# GOOD - absolute paths required
read_file(path="/workspace/src/main.py")
read_file(path="/config.json")
5. Windows Paths in Virtual Filesystem
# BAD - Windows paths rejected
read_file(path="C:\\Users\\file.txt")
write_file(path="D:/projects/code.py", content="...")
# GOOD - Unix-style virtual paths
read_file(path="/workspace/file.txt")
write_file(path="/projects/code.py", content="...")
Backend Issues
6. StateBackend Expecting Persistence
# BAD - expecting files to persist across threads
agent = create_deep_agent() # Uses StateBackend by default
# Thread 1
agent.invoke({"messages": [...]}, {"configurable": {"thread_id": "a"}})
# Agent writes to /data/report.txt
# Thread 2 - file won't exist!
agent.invoke({"messages": [...]}, {"configurable": {"thread_id": "b"}})
# Agent tries to read /data/report.txt - NOT FOUND
# GOOD - use StoreBackend or CompositeBackend for cross-thread persistence
agent = create_deep_agent(
backend=CompositeBackend(
default=StateBackend(),
routes={"/data/": StoreBackend(store=store)},
),
store=store,
)
7. FilesystemBackend Without root_dir Restriction
# BAD - unrestricted filesystem access
agent = create_deep_agent(
backend=FilesystemBackend(root_dir="/"), # Full system access!
)
# GOOD - scope to project directory
agent = create_deep_agent(
backend=FilesystemBackend(root_dir="/home/user/project"),
)
8. CompositeBackend Route Order Confusion
# BAD - shorter prefix shadows longer prefix
agent = create_deep_agent(
backend=CompositeBackend(
default=StateBackend(),
routes={
"/mem/": backend_a, # This catches /mem/long-term/ too!
"/mem/long-term/": backend_b, # Never reached
},
),
)
# GOOD - CompositeBackend sorts by length automatically
# But be explicit about your intent:
agent = create_deep_agent(
backend=CompositeBackend(
default=StateBackend(),
routes={
"/memories/": persistent_backend,
"/workspace/": ephemeral_backend,
},
),
)
9. Expecting execute Tool Without SandboxBackend
# BAD - execute tool won't work with StateBackend
agent = create_deep_agent() # Default StateBackend
# Agent calls execute("ls -la") → Error: not supported
# GOOD - use FilesystemBackend for shell execution
agent = create_deep_agent(
backend=FilesystemBackend(root_dir="/project"),
)
# Agent calls execute("ls -la") → Works
Subagent Issues
10. Subagent Missing Required Fields
# BAD - missing required fields
agent = create_deep_agent(
subagents=[{
"name": "helper",
# Missing: description, system_prompt, tools
}]
)
# GOOD - all required fields present
agent = create_deep_agent(
subagents=[{
"name": "helper",
"description": "General helper for misc tasks",
"system_prompt": "You are a helpful assistant.",
"tools": [], # Can be empty but must be present
}]
)
11. Subagent Name Collision
# BAD - duplicate subagent names
agent = create_deep_agent(
subagents=[
{"name": "research", "description": "A", ...},
{"name": "research", "description": "B", ...}, # Collision!
]
)
# GOOD - unique names
agent = create_deep_agent(
subagents=[
{"name": "web-research", "description": "Web-based research", ...},
{"name": "doc-research", "description": "Document research", ...},
]
)
12. Overusing Subagents for Simple Tasks
# BAD - subagent overhead for trivial task
# In system prompt or agent behavior:
"Use the task tool to check the current time"
"Delegate file reading to a subagent"
# GOOD - use subagents for complex, isolated work
"Use the task tool for multi-step research that requires many searches"
"Delegate the full analysis workflow to a subagent"
13. CompiledSubAgent Without Proper State
# BAD - subgraph with incompatible state schema
from langgraph.graph import StateGraph
class CustomState(TypedDict):
custom_field: str # No messages field!
sub_builder = StateGraph(CustomState)
# ... build graph
subgraph = sub_builder.compile()
agent = create_deep_agent(
subagents=[CompiledSubAgent(
name="custom",
description="Custom workflow",
runnable=subgraph, # State mismatch!
)]
)
# GOOD - ensure compatible state or use message-based interface
class CompatibleState(TypedDict):
messages: Annotated[list, add_messages]
custom_field: str
Middleware Issues
14. Middleware Order Misunderstanding
# BAD - expecting custom middleware to run first
class PreProcessMiddleware(AgentMiddleware):
def transform_request(self, request):
# Expecting this runs before built-in middleware
return request
agent = create_deep_agent(middleware=[PreProcessMiddleware()])
# Actually runs AFTER TodoList, Filesystem, SubAgent, etc.
# GOOD - understand middleware runs after built-in stack
# Built-in order:
# 1. TodoListMiddleware
# 2. FilesystemMiddleware
# 3. SubAgentMiddleware
# 4. SummarizationMiddleware
# 5. AnthropicPromptCach