← Back to Skills Marketplace
anderskev

Deepagents Architecture

by Kevin Anderson · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ✓ Security Clean
160
Downloads
0
Stars
1
Active Installs
2
Versions
Install in OpenClaw
/install deepagents-architecture
Description
Guides architectural decisions for Deep Agents applications. Use when deciding between Deep Agents vs alternatives, choosing backend strategies, designing su...
README (SKILL.md)

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:

Scenario Alternative Why
Single LLM call Direct API call Deep Agents overhead not justified
Simple RAG pipeline LangChain LCEL Simpler abstraction
Custom graph control flow LangGraph directly More flexibility
No file operations needed create_react_agent Lighter weight
Stateless tool use Function calling No middleware needed

Backend Selection

Backend Comparison

Backend Persistence Use Case Requires
StateBackend Ephemeral (per-thread) Working files, temp data Nothing (default)
FilesystemBackend Disk Local development, real files root_dir path
StoreBackend Cross-thread User preferences, knowledge bases LangGraph store
CompositeBackend Mixed Hybrid memory patterns Multiple 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

Need Use Middleware Use 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).
Usage Guidance
This is an architecture guideline only — it doesn't ask for credentials or install code itself and appears coherent. Before using recommendations in a running agent, review any code you copy from the guide: backend/middleware choices can enable file reads, disk persistence, or command execution (e.g., FilesystemBackend or middleware with an 'execute' tool). Only grant your agent the minimal tools and environment variables it truly needs, avoid pasting secrets into prompts, and review any runtime configuration that binds to the filesystem or external stores.
Capability Analysis
Type: OpenClaw Skill Name: deepagents-architecture Version: 1.0.1 The skill bundle provides architectural guidance and a structured decision-making framework for designing applications using the 'Deep Agents' framework. The content in SKILL.md consists of educational material, decision trees, and a checklist ('Gates') for the agent to follow, all of which are well-aligned with the stated purpose and show no signs of malicious intent, data exfiltration, or unauthorized execution.
Capability Assessment
Purpose & Capability
Name/description (Deep Agents architecture guidance) match the SKILL.md content: design guidance, decision trees, and code examples for backends, subagents, and middleware. There are no unrelated credential or binary requirements.
Instruction Scope
SKILL.md stays within architectural guidance and example code; it does not instruct the agent to read local secrets or call external endpoints. Note: examples reference filesystem/backends and an 'execute' middleware/tool — these are sample configurations that, if implemented by the user, may enable file/command execution, but the skill itself does not perform those actions.
Install Mechanism
No install spec or code files are present (instruction-only), so nothing is written to disk or downloaded by the skill itself.
Credentials
The skill declares no required environment variables, credentials, or config paths; the content's references to storage/backends are conceptual and do not request secrets.
Persistence & Privilege
always is false and the skill is user-invocable; it does not request persistent/privileged presence or modify other skills or system-wide config.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install deepagents-architecture
  3. After installation, invoke the skill by name or use /deepagents-architecture
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.1
- Updated the architecture decision checklist to a new section called "Gates: architecture decisions before implementation", specifying a stepwise, documented review process for each major architectural decision. - Each gate now requires a written artifact (rationale, configuration, or explicit lists) before that step is considered complete, increasing clarity and auditability. - All prior architecture guidance, backend comparisons, subagent patterns, and middleware explanations remain intact for reference. - No functional feature changes to code or implementation guidance—documentation-only update to improve design process rigor.
v1.0.0
- Initial release of deepagents-architecture skill. - Provides clear guidelines on when to use Deep Agents versus alternatives. - Includes backend selection strategies and a decision tree for choosing backends. - Documents subagent architecture patterns and decision-making criteria. - Details middleware stack, customization, and best practices. - Supplies a comprehensive architecture decision checklist.
Metadata
Slug deepagents-architecture
Version 1.0.1
License MIT-0
All-time Installs 1
Active Installs 1
Total Versions 2
Frequently Asked Questions

What is Deepagents Architecture?

Guides architectural decisions for Deep Agents applications. Use when deciding between Deep Agents vs alternatives, choosing backend strategies, designing su... It is an AI Agent Skill for Claude Code / OpenClaw, with 160 downloads so far.

How do I install Deepagents Architecture?

Run "/install deepagents-architecture" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Deepagents Architecture free?

Yes, Deepagents Architecture is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Deepagents Architecture support?

Deepagents Architecture is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Deepagents Architecture?

It is built and maintained by Kevin Anderson (@anderskev); the current version is v1.0.1.

💬 Comments