Reference Deep Agent
April 23, 2026 · View on GitHub
Source: src/langgraph_kit/graphs/reference_deep_agent.py
Agent ID: reference-deep-agent
The full-stack general-purpose reference agent that wires every kit feature
together. Clone this agent as the starting point for any new domain-specific
agent (see coding-agent for the canonical extension pattern).
Architecture
Built on the deepagents framework with the complete langgraph-kit feature stack:
User Message
│
▼
Middleware Stack (11 middleware)
│
▼
deepagents create_deep_agent()
├── Prompt Assembly (PromptComposer)
├── Tool Registry (standard + memory + UI + HITL)
├── Worker Definitions (researcher, implementer, verifier)
├── Backend Factory (memories, notes, state)
└── Command Dispatcher (7 built-in commands)
Prompt Sections
The reference agent registers 5 core prompt sections:
| Section ID | Stability | Content |
|---|---|---|
core_identity | STABLE | Agent identity and capabilities |
memory_instructions | STABLE | How to use persistent memory |
orchestration_instructions | STABLE | Multi-agent delegation patterns |
continuation_guidance | STABLE | When to continue vs. stop |
ui_interaction | CONDITIONAL | UI artifact and event usage |
Worker Definitions
Three specialized workers for task delegation, defined in core/orchestration/workers.py:
| Worker | Definition | Description |
|---|---|---|
researcher | RESEARCHER_DEFINITION | Finds information, reads docs, searches code |
implementer | IMPLEMENTER_DEFINITION | Writes code, makes changes, builds features |
verifier | VERIFIER_DEFINITION | Reviews changes, runs tests, validates output |
Pre-composed as GENERAL_WORKERS — see Workers.
Features Included
- Prompt assembly with stable-first caching
- Persistent memory (CRUD + auto-extraction)
- Tool registry with risk levels
- 7 built-in slash commands
- Context pressure monitoring
- Session notebook continuity
- Async task delegation
- Message queue for busy threads
- HITL approval for destructive operations
- UI artifacts, progress, suggestions, citations
- Skill discovery
- MCP tool integration
- Resilience middleware (completion guard, empty turn, tool error)
- Langfuse observability
Build Function
def build_reference_deep_agent(
checkpointer,
store,
*,
mcp_tools=None,
recursion_limit=DEFAULT_RECURSION_LIMIT, # 100
):
"""Build the reference deep agent with all kit features.
Returns: (compiled_graph, command_dispatcher)
"""
Returns a tuple of the compiled graph and command dispatcher, both registered together.
Recursion Limit
Defaults to DEFAULT_RECURSION_LIMIT (100) — high enough for realistic multi-turn runs with worker delegation and tool loops, where LangGraph's native default of 25 is not. Raise it for long autonomous runs by passing recursion_limit=<n> to the builder, or override per-invocation with config={"recursion_limit": <n>}. See the agents overview for details.
Middleware Stack
The reference agent uses the full standard middleware stack (11 middleware), built by core.graph_builder.build_middleware_stack():
- CommandMiddleware
- RuntimeStateMiddleware
- QueuedInputMiddleware
- ToolErrorMiddleware
- PressureMiddleware
- ResultPersistenceMiddleware
- ExtractionMiddleware
- EmptyTurnMiddleware
- CompletionGuardMiddleware
- StopHooksMiddleware
- PostRunBackstopMiddleware