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 IDStabilityContent
core_identitySTABLEAgent identity and capabilities
memory_instructionsSTABLEHow to use persistent memory
orchestration_instructionsSTABLEMulti-agent delegation patterns
continuation_guidanceSTABLEWhen to continue vs. stop
ui_interactionCONDITIONALUI artifact and event usage

Worker Definitions

Three specialized workers for task delegation, defined in core/orchestration/workers.py:

WorkerDefinitionDescription
researcherRESEARCHER_DEFINITIONFinds information, reads docs, searches code
implementerIMPLEMENTER_DEFINITIONWrites code, makes changes, builds features
verifierVERIFIER_DEFINITIONReviews 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():

  1. CommandMiddleware
  2. RuntimeStateMiddleware
  3. QueuedInputMiddleware
  4. ToolErrorMiddleware
  5. PressureMiddleware
  6. ResultPersistenceMiddleware
  7. ExtractionMiddleware
  8. EmptyTurnMiddleware
  9. CompletionGuardMiddleware
  10. StopHooksMiddleware
  11. PostRunBackstopMiddleware