| name | deepagents-code-review |
| description | Reviews Deep Agents code for bugs, anti-patterns, and improvements. Use when reviewing code that uses create_deep_agent, backends, subagents, middleware, or human-in-the-loop patterns. Catches common configuration and usage mistakes. |
Deep Agents Code Review
When reviewing Deep Agents code, check for these categories of issues.
Anti-confabulation (gate 0 — runs before every other gate)
Before issuing any finding — flag a bug, anti-pattern, or improvement — you MUST echo the exact artifact you are judging, quoted from a source you read in this turn:
- The code finding: its
file:line plus the cited code, read freshly now.
- The agent code under review: the
create_deep_agent, backend, subagent, or middleware snippet your finding depends on, quoted from the file you just read.
The artifact is the only source of truth. Never infer what you are reviewing from the branch name, the working directory, surrounding files, or recollection. If your mental model differs from the freshly read source, the source wins. A finding issued without a same-turn echo of its target is invalid — emit the echo first, or do not emit the finding.
This gate exists because an LLM under contextual priming will confidently flag code that is not in the file. It runs before the gates below.
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, custom backend=, 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:line plus 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_on set with no checkpointer in 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
agent = create_deep_agent(
tools=[send_email],
interrupt_on={"send_email": True},
)
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
from deepagents.backends import StoreBackend
agent = create_deep_agent(
backend=lambda rt: StoreBackend(rt),
)
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
agent = create_deep_agent(checkpointer=InMemorySaver())
agent.invoke({"messages": [...]})
config = {"configurable": {"thread_id": "user-123"}}
agent.invoke({"messages": [...]}, config)
4. Relative Paths in Filesystem Tools
read_file(path="src/main.py")
read_file(path="./config.json")
read_file(path="/workspace/src/main.py")
read_file(path="/config.json")
5. Windows Paths in Virtual Filesystem
read_file(path="C:\\Users\\file.txt")
write_file(path="D:/projects/code.py", content="...")
read_file(path="/workspace/file.txt")
write_file(path="/projects/code.py", content="...")
Backend Issues
6. StateBackend Expecting Persistence
agent = create_deep_agent()
agent.invoke({"messages": [...]}, {"configurable": {"thread_id": "a"}})
agent.invoke({"messages": [...]}, {"configurable": {"thread_id": "b"}})
agent = create_deep_agent(
backend=CompositeBackend(
default=StateBackend(),
routes={"/data/": StoreBackend(store=store)},
),
store=store,
)
7. FilesystemBackend Without root_dir Restriction
agent = create_deep_agent(
backend=FilesystemBackend(root_dir="/"),
)
agent = create_deep_agent(
backend=FilesystemBackend(root_dir="/home/user/project"),
)
8. CompositeBackend Route Order Confusion
agent = create_deep_agent(
backend=CompositeBackend(
default=StateBackend(),
routes={
"/mem/": backend_a,
"/mem/long-term/": backend_b,
},
),
)
agent = create_deep_agent(
backend=CompositeBackend(
default=StateBackend(),
routes={
"/memories/": persistent_backend,
"/workspace/": ephemeral_backend,
},
),
)
9. Expecting execute Tool Without SandboxBackend
agent = create_deep_agent()
agent = create_deep_agent(
backend=FilesystemBackend(root_dir="/project"),
)
Subagent Issues
10. Subagent Missing Required Fields
agent = create_deep_agent(
subagents=[{
"name": "helper",
}]
)
agent = create_deep_agent(
subagents=[{
"name": "helper",
"description": "General helper for misc tasks",
"system_prompt": "You are a helpful assistant.",
"tools": [],
}]
)
11. Subagent Name Collision
agent = create_deep_agent(
subagents=[
{"name": "research", "description": "A", ...},
{"name": "research", "description": "B", ...},
]
)
agent = create_deep_agent(
subagents=[
{"name": "web-research", "description": "Web-based research", ...},
{"name": "doc-research", "description": "Document research", ...},
]
)
12. Overusing Subagents for Simple Tasks
"Use the task tool to check the current time"
"Delegate file reading to a subagent"
"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
from langgraph.graph import StateGraph
class CustomState(TypedDict):
custom_field: str
sub_builder = StateGraph(CustomState)
subgraph = sub_builder.compile()
agent = create_deep_agent(
subagents=[CompiledSubAgent(
name="custom",
description="Custom workflow",
runnable=subgraph,
)]
)
class CompatibleState(TypedDict):
messages: Annotated[list, add_messages]
custom_field: str
Middleware Issues
14. Middleware Order Misunderstanding
class PreProcessMiddleware(AgentMiddleware):
def transform_request(self, request):
return request
agent = create_deep_agent(middleware=[PreProcessMiddleware()])
15. Middleware Mutating Request/Response
class BadMiddleware(AgentMiddleware):
def transform_request(self, request):
request.messages.append(extra_message)
return request
class GoodMiddleware(AgentMiddleware):
def transform_request(self, request):
return ModelRequest(
messages=[*request.messages, extra_message],
**other_fields
)
16. Middleware Tools Without Descriptions
@tool
def my_tool(arg: str) -> str:
return process(arg)
class MyMiddleware(AgentMiddleware):
tools = [my_tool]
@tool
def my_tool(arg: str) -> str:
"""Process the input string and return formatted result.
Args:
arg: The string to process
Returns:
Formatted result string
"""
return process(arg)
System Prompt Issues
17. Duplicating Built-in Tool Instructions
agent = create_deep_agent(
system_prompt="""You have access to these tools:
- write_todos: Create task lists
- read_file: Read files from the filesystem
- task: Delegate to subagents
When using files, always use absolute paths..."""
)
agent = create_deep_agent(
system_prompt="""You are a code review assistant.
Workflow:
1. Read the files to review
2. Create a todo list of issues found
3. Delegate deep analysis to subagents if needed
4. Compile findings into a report"""
)
18. Contradicting Built-in Instructions
agent = create_deep_agent(
system_prompt="""Never use the task tool.
Always process everything in the main thread.
Don't use todos, just remember everything."""
)
agent = create_deep_agent(
system_prompt="""For simple tasks, handle directly.
For complex multi-step research, use subagents.
Track progress with todos for tasks with 3+ steps."""
)
19. Missing Stopping Criteria
agent = create_deep_agent(
system_prompt="Research everything about the topic thoroughly."
)
agent = create_deep_agent(
system_prompt="""Research the topic with these constraints:
- Maximum 5 web searches
- Stop when you have 3 reliable sources
- Limit subagent delegations to 2 parallel tasks
- Summarize findings within 500 words"""
)
Performance Issues
20. Not Parallelizing Independent Subagents
agent = create_deep_agent(
system_prompt="""When researching multiple topics,
launch all research subagents in parallel in a single response."""
)
21. Large Files in State
agent = create_deep_agent(
backend=CompositeBackend(
default=StateBackend(),
routes={
"/large_files/": FilesystemBackend(root_dir="/tmp/agent"),
},
),
)
22. InMemorySaver in Production
agent = create_deep_agent(
checkpointer=InMemorySaver(),
)
from langgraph.checkpoint.postgres import PostgresSaver
agent = create_deep_agent(
checkpointer=PostgresSaver.from_conn_string(DATABASE_URL),
)
23. Missing Recursion Awareness
agent = create_deep_agent(
system_prompt="Keep improving the solution until it's perfect."
)
agent = create_deep_agent(
system_prompt="""Improve the solution iteratively:
- Maximum 3 revision cycles
- Stop if quality score > 90%
- Stop if no improvement after 2 iterations"""
)
Code Review Checklist
See references/checklist.md for the full per-area checklist (Configuration, Backends, Subagents, Middleware, System Prompt, Performance). Run it after the Review gates and the numbered issue catalogue above.