Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
existential-birds avatar

Deepagents Architecture

  • 151 installs
  • 74 repo stars
  • Updated July 21, 2026
  • existential-birds/beagle

Design and implement deep agent architectures with planning loops, tool orchestration, memory, and delegation patterns when building production-grade autonomous AI systems.

About

The deepagents-architecture skill from existential-birds/beagle teaches how to structure deep AI agents: layered planners, executors, tool routers, memory, and guardrails. Use it when designing autonomous workflows that must reason over many steps, call external tools safely, and remain maintainable as complexity grows.

  • Deep agent topology and control-flow patterns
  • Tool routing, delegation, and multi-step planning loops
  • Memory, state, and context management for long-horizon tasks
  • Production boundaries between planner, executor, and evaluator roles
  • Scalable patterns for reliable autonomous workflows

Deepagents Architecture by the numbers

  • 151 all-time installs (skills.sh)
  • Ranked #3,330 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/existential-birds/beagle --skill deepagents-architecture

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs151
repo stars74
Last updatedJuly 21, 2026
Repositoryexistential-birds/beagle

What it does

Design and implement deep agent architectures with planning loops, tool orchestration, memory, and delegation patterns when building production-grade autonomous AI systems.

Files

SKILL.mdMarkdownGitHub ↗

Deep Agents Architecture Decisions

When to Use Deep Agents

Use Deep Agents When You Need:

  • Long-horizon tasks - Complex workflows spanning dozens of tool calls
  • Planning capabilities - Task decomposition before execution
  • Filesystem operations - Reading, writing, and editing files
  • Subagent delegation - Isolated task execution with separate context windows
  • Persistent memory - Long-term storage across conversations
  • Human-in-the-loop - Approval gates for sensitive operations
  • Context management - Auto-summarization for long conversations

Consider Alternatives When:

ScenarioAlternativeWhy
Single LLM callDirect API callDeep Agents overhead not justified
Simple RAG pipelineLangChain LCELSimpler abstraction
Custom graph control flowLangGraph directlyMore flexibility
No file operations neededcreate_react_agentLighter weight
Stateless tool useFunction callingNo middleware needed

Backend Selection

Backend Comparison

BackendPersistenceUse CaseRequires
StateBackendEphemeral (per-thread)Working files, temp dataNothing (default)
FilesystemBackendDiskLocal development, real filesroot_dir path
StoreBackendCross-threadUser preferences, knowledge basesLangGraph store
CompositeBackendMixedHybrid memory patternsMultiple backends

Backend Decision Tree

Need real disk access?
├─ Yes → FilesystemBackend(root_dir="/path")
└─ No
   └─ Need persistence across conversations?
      ├─ Yes → Need mixed ephemeral + persistent?
      │  ├─ Yes → CompositeBackend
      │  └─ No → StoreBackend
      └─ No → StateBackend (default)

CompositeBackend Routing

Route different paths to different storage backends:

from deepagents import create_deep_agent
from deepagents.backends import CompositeBackend, StateBackend, StoreBackend

agent = create_deep_agent(
    backend=CompositeBackend(
        default=StateBackend(),  # Working files (ephemeral)
        routes={
            "/memories/": StoreBackend(store=store),    # Persistent
            "/preferences/": StoreBackend(store=store), # Persistent
        },
    ),
)

Subagent Architecture

When to Use Subagents

Use subagents when:

  • Task is complex, multi-step, and can run independently
  • Task requires heavy context that would bloat the main thread
  • Multiple independent tasks can run in parallel
  • You need isolated execution (sandboxing)
  • You only care about the final result, not intermediate steps

Don't use subagents when:

  • Task is trivial (few tool calls)
  • You need to see intermediate reasoning
  • Splitting adds latency without benefit
  • Task depends on main thread state mid-execution

Subagent Patterns

Pattern 1: Parallel Research
         ┌─────────────┐
         │  Orchestrator│
         └──────┬──────┘
    ┌──────────┼──────────┐
    ▼          ▼          ▼
┌──────┐  ┌──────┐  ┌──────┐
│Task A│  │Task B│  │Task C│
└──┬───┘  └──┬───┘  └──┬───┘
   └──────────┼──────────┘
              ▼
      ┌─────────────┐
      │  Synthesize │
      └─────────────┘

Best for: Research on multiple topics, parallel analysis, batch processing.

Pattern 2: Specialized Agents
research_agent = {
    "name": "researcher",
    "description": "Deep research on complex topics",
    "system_prompt": "You are an expert researcher...",
    "tools": [web_search, document_reader],
}

coder_agent = {
    "name": "coder",
    "description": "Write and review code",
    "system_prompt": "You are an expert programmer...",
    "tools": [code_executor, linter],
}

agent = create_deep_agent(subagents=[research_agent, coder_agent])

Best for: Domain-specific expertise, different tool sets per task type.

Pattern 3: Pre-compiled Subagents
from deepagents import CompiledSubAgent, create_deep_agent

# Use existing LangGraph graph as subagent
custom_graph = create_react_agent(model=..., tools=...)

agent = create_deep_agent(
    subagents=[CompiledSubAgent(
        name="custom-workflow",
        description="Runs specialized workflow",
        runnable=custom_graph
    )]
)

Best for: Reusing existing LangGraph graphs, complex custom workflows.

Middleware Architecture

Built-in Middleware Stack

Deep Agents applies middleware in this order:

1. TodoListMiddleware - Task planning with write_todos/read_todos 2. FilesystemMiddleware - File ops: ls, read_file, write_file, edit_file, glob, grep, execute 3. SubAgentMiddleware - Delegation via task tool 4. SummarizationMiddleware - Auto-summarizes at ~85% context or 170k tokens 5. AnthropicPromptCachingMiddleware - Caches system prompts (Anthropic only) 6. PatchToolCallsMiddleware - Fixes dangling tool calls from interruptions 7. HumanInTheLoopMiddleware - Pauses for approval (if interrupt_on configured)

Custom Middleware Placement

from langchain.agents.middleware import AgentMiddleware

class MyMiddleware(AgentMiddleware):
    tools = [my_custom_tool]

    def transform_request(self, request):
        # Modify system prompt, inject context
        return request

    def transform_response(self, response):
        # Post-process, log, filter
        return response

# Custom middleware added AFTER built-in stack
agent = create_deep_agent(middleware=[MyMiddleware()])

Middleware vs Tools Decision

NeedUse MiddlewareUse Tools
Inject system prompt content
Add tools dynamically
Transform requests/responses
Standalone capability
User-invokable action

Subagent Middleware Inheritance

Subagents receive their own middleware stack by default:

  • TodoListMiddleware
  • FilesystemMiddleware (shared backend)
  • SummarizationMiddleware
  • AnthropicPromptCachingMiddleware
  • PatchToolCallsMiddleware

Override with default_middleware=[] in SubAgentMiddleware or per-subagent middleware key.

Gates: architecture decisions before implementation

Complete in order. A step passes only when the stated artifact exists in the design note, ADR stub, or ticket; internal intent alone does not count.

1. Fit - Confirm Deep Agents vs alternatives (see tables above).

  • Pass: Short written rationale that either names one matching "Use Deep Agents When You Need" bullet or one "Consider Alternatives" row plus the chosen alternative.

2. Backend - Match the Backend Decision Tree to a concrete choice.

  • Pass: Backend name(s) from the Backend Comparison table; if FilesystemBackend or CompositeBackend, root_dir and any route prefixes are written down (path placeholders OK).

3. Subagents - Decide delegation boundaries.

  • Pass: Either "no subagents" plus one sentence why or a named list where each subagent maps to at least one "When to Use Subagents" reason; parallel plans state what merges outputs.

4. Human-in-the-loop - Approval surface.

  • Pass: Explicit list of tools/operations that use interrupt_on, or "no HITL" plus one-line risk acceptance.

5. Middleware - Custom vs built-in only.

  • Pass: Either "custom middleware: none" or each custom piece named, placed after the built-in stack, and tied to prompt injection, tools, or request/response transforms.

6. Context - Long threads and large inputs.

  • Pass: Stated plan for default summarization behavior (~85% context / ~170k tokens) or an alternative cap; large files handled via references/chunking or equivalent, named in text.

7. Checkpointing - Resume and durability.

  • Pass: Checkpoint/checkpointer approach named for the graph or "none" with one-line rationale (e.g. ephemeral demo only).

Related skills

AI & Agent Buildingagentsllmautomation

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.