Guidance for building agent systems with Deep Agents including middleware and subagents.

Install

mkdir -p .claude/skills/deep-agents && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16784" && unzip -o skill.zip -d .claude/skills/deep-agents && rm skill.zip

Installs to .claude/skills/deep-agents

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

LangChain Deep Agents patterns for building production agents. Use when writing code that imports from `deepagents`, designing agent systems with pluggable filesystem backends, implementing middleware stacks, spawning subagents, streaming agent output, or integrating Deep Agents into Clarity's orchestration layer. Covers: create_deep_agent(), BackendProtocol, StoreBackend, middleware system, subagent spawning, streaming, human-in-the-loop, memory patterns, and sandbox backends.
482 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Advanced

Key capabilities

  • Create Deep Agents with specified models and tools
  • Configure backend storage for agents
  • Implement middleware for agent functionality
  • Spawn subagents for complex tasks
  • Stream agent output with various modes
  • Enable human-in-the-loop interactions

How it works

The skill uses the `create_deep_agent()` function to configure and instantiate a LangChain Deep Agent, integrating various components like models, tools, backends, and middleware.

Inputs & outputs

You give it
Agent name, model, tools, system prompt, backend, store, checkpointer, interrupt_on configuration, subagents, skills, memory, context schema, response format
You get back
A compiled `CompiledStateGraph` (LangGraph) instance

When to use deep-agents

  • Build agent system
  • Create subagent
  • Configure middleware

About this skill

LangChain Deep Agents

Package: deepagents v0.5.0 (Beta, MIT, Python >=3.11) Homepage: https://docs.langchain.com/oss/python/deepagents/overview GitHub: https://github.com/langchain-ai/deepagents

pip install deepagents
uv add deepagents

Returns a compiled CompiledStateGraph (LangGraph) — all LangGraph primitives (.stream(), .ainvoke(), Studio, Platform) work on the result.

Reference Pages

TopicFileWhen to read
Backends & storesreferences/backends.mdBackendProtocol, StoreBackend, CompositeBackend, namespace factories, custom backends
Middlewarereferences/middleware.mdAll built-in middleware classes, parameters, custom middleware
Subagentsreferences/subagents.mdSubAgent dict spec, CompiledSubAgent, task() tool, context propagation
Streamingreferences/streaming.mdstream_mode options, event structure, subagent event namespacing
Sandboxesreferences/sandboxes.mdModal, Runloop, Daytona, AgentCore sandbox backends, file transfer
Memory & skillsreferences/memory-skills.mdMemory scoping, AGENTS.md, skills loading, SKILL.md format

Core API

create_deep_agent()

from deepagents import create_deep_agent

agent = create_deep_agent(
    name: str | None = None,
    model: str | BaseChatModel | None = None,       # default: "claude-sonnet-4-6"
    tools: Sequence[BaseTool | Callable | dict] | None = None,
    *,
    system_prompt: str | SystemMessage | None = None,
    backend: BackendProtocol | None = None,          # default: StateBackend()
    store: BaseStore | None = None,
    checkpointer: BaseCheckpointSaver | None = None, # REQUIRED for human-in-the-loop
    interrupt_on: dict | None = None,
    subagents: list[dict | CompiledSubAgent] | None = None,
    skills: list[str] | None = None,
    memory: list[str] | None = None,
    context_schema: type | None = None,
    response_format: type[BaseModel] | None = None,  # structured output
)
# Returns: CompiledStateGraph

Model format: "provider:model" string or BaseChatModel instance. Supported providers: Anthropic, OpenAI, Google, Azure, AWS Bedrock, OpenRouter, Fireworks, Baseten, Ollama.

Invocation

# Single-turn
result = agent.invoke({"messages": [{"role": "user", "content": "..."}]})

# With thread (required for checkpointing, human-in-the-loop)
result = agent.invoke(
    {"messages": [{"role": "user", "content": "..."}]},
    config={"configurable": {"thread_id": "some-id"}},
)

# Async
result = await agent.ainvoke(...)

# Structured output result key
result["structured_response"]  # when response_format= is set

Built-in Tools

These are injected automatically based on middleware:

ToolMiddlewareDescription
write_todosTodoListMiddlewareTask planning/decomposition
lsFilesystemMiddlewareList directory contents
read_fileFilesystemMiddlewareRead file with offset+limit
write_fileFilesystemMiddlewareWrite/create file
edit_fileFilesystemMiddlewareString-replace edit
globFilesystemMiddlewarePattern-based file search
grepFilesystemMiddlewareRegex content search
executeSandbox backends onlyRun shell commands
taskSubAgentMiddlewareSpawn subagent

Minimal Example

from deepagents import create_deep_agent

def get_weather(city: str) -> str:
    """Return current weather for a city."""
    return f"Sunny, 72°F in {city}"

agent = create_deep_agent(
    model="anthropic:claude-sonnet-4-6",
    tools=[get_weather],
    system_prompt="You are a helpful assistant.",
)

result = agent.invoke({"messages": [{"role": "user", "content": "Weather in NYC?"}]})

Tool Registration

Any Python callable with type hints and a docstring works. LangChain BaseTool and @tool-decorated functions also accepted.

from langchain.tools import tool

@tool
def search(query: str) -> str:
    """Search the web for information."""
    return search_api(query)

agent = create_deep_agent(tools=[search, my_plain_callable])

Streaming

for chunk in agent.stream(
    {"messages": [{"role": "user", "content": "..."}]},
    stream_mode=["updates", "messages", "custom"],
    subgraphs=True,
    version="v2",
):
    # chunk["type"] is "updates", "messages", or "custom"
    # chunk["ns"] is () for main agent, ("tools:<id>",) for subagent
    ...

See references/streaming.md for event structure details.

Human-in-the-Loop

from langgraph.checkpoint.memory import MemorySaver
from langgraph.types import Command

agent = create_deep_agent(
    tools=[sensitive_tool],
    checkpointer=MemorySaver(),           # REQUIRED
    interrupt_on={"sensitive_tool": True},
)

thread = {"configurable": {"thread_id": "t1"}}
result = agent.invoke(input, config=thread, version="v2")

# result.interrupts[0].value contains action_requests and review_configs
# Resume:
agent.invoke(Command(resume={"decisions": ["approve"]}), config=thread, version="v2")

interrupt_on values: True, False, or {"allowed_decisions": ["approve", "edit", "reject"]}.

Standards

Always do

  1. Set a thread_id whenever using checkpointer or needing human-in-the-loop.
  2. Use StoreBackend with namespace factories for multi-tenant deployments — never StateBackend in production serving multiple users.
  3. Pass checkpointer=MemorySaver() (or persistent saver) when using interrupt_on.
  4. Provide type hints and docstrings on all tool callables — the agent uses them to understand the tool.
  5. Use backend.upload_files() before invoking when seeding a sandbox with source code or data.
  6. Read version="v2" when streaming — required for unified event format.

Never do

  1. Don't use StateBackend for multi-user — files are not isolated between threads.
  2. Don't put secrets in sandbox environments — they can be read/exfiltrated via context injection.
  3. Don't skip checkpointer with interrupt_on — human-in-the-loop silently fails without it.
  4. Don't expect subagents to inherit the parent's tools, middleware, or skills — they must be specified explicitly.
  5. Don't use the deprecated runtime constructor arg on StateBackend/StoreBackend.

Vs. Claude Agent SDK

Deep Agents adds on top of LangGraph: virtual filesystem with pluggable backends, composable middleware, long-term memory via Store, and sandbox-as-tool pattern. Use Deep Agents when you need multi-backend filesystems, middleware composition, or model-agnostic support. Use Claude Agent SDK when tight Claude Code integration (hooks, permissions, CLAUDE.md) is the priority. See the comparison page.

When not to use it

  • When tight Claude Code integration (hooks, permissions, CLAUDE.md) is the priority
  • When not using LangChain Deep Agents patterns
  • When `StateBackend` is used for multi-user deployments

Prerequisites

deepagents Python packagePython >=3.11

Limitations

  • Subagents do not inherit the parent's `tools`, `middleware`, or `skills`
  • Secrets should not be put in sandbox environments
  • Human-in-the-loop silently fails without a `checkpointer`

How it compares

This skill provides a structured approach to building production-ready agents with advanced features like pluggable filesystems, middleware, and human-in-the-loop capabilities, extending beyond basic LangGraph agents.

Compared to similar skills

deep-agents side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
deep-agents (this skill)04moReviewAdvanced
llama-cpp219moReviewIntermediate
langchain269moReviewIntermediate
llama-factory159moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

llama-cpp

zechenzhangAGI

Runs LLM inference on CPU, Apple Silicon, and consumer GPUs without NVIDIA hardware. Use for edge deployment, M1/M2/M3 Macs, AMD/Intel GPUs, or when CUDA is unavailable. Supports GGUF quantization (1.5-8 bit) for reduced memory and 4-10× speedup vs PyTorch on CPU.

21471

langchain

zechenzhangAGI

Framework for building LLM-powered applications with agents, chains, and RAG. Supports multiple providers (OpenAI, Anthropic, Google), 500+ integrations, ReAct agents, tool calling, memory management, and vector store retrieval. Use for building chatbots, question-answering systems, autonomous agents, or RAG applications. Best for rapid prototyping and production deployments.

26138

llama-factory

zechenzhangAGI

Expert guidance for fine-tuning LLMs with LLaMA-Factory - WebUI no-code, 100+ models, 2/3/4/5/6/8-bit QLoRA, multimodal support

15112

langgraph

davila7

Expert in LangGraph - the production-grade framework for building stateful, multi-actor AI applications. Covers graph construction, state management, cycles and branches, persistence with checkpointers, human-in-the-loop patterns, and the ReAct agent pattern. Used in production at LinkedIn, Uber, and 400+ companies. This is LangChain's recommended approach for building agents. Use when: langgraph, langchain agent, stateful agent, agent graph, react agent.

1374

computer-use-agents

davila7

Build AI agents that interact with computers like humans do - viewing screens, moving cursors, clicking buttons, and typing text. Covers Anthropic's Computer Use, OpenAI's Operator/CUA, and open-source alternatives. Critical focus on sandboxing, security, and handling the unique challenges of vision-based control. Use when: computer use, desktop automation agent, screen control AI, vision-based agent, GUI automation.

1040

senior-prompt-engineer

davila7

World-class prompt engineering skill for LLM optimization, prompt patterns, structured outputs, and AI product development. Expertise in Claude, GPT-4, prompt design patterns, few-shot learning, chain-of-thought, and AI evaluation. Includes RAG optimization, agent design, and LLM system architecture. Use when building AI products, optimizing LLM performance, designing agentic systems, or implementing advanced prompting techniques.

743

Search skills

Search the agent skills registry