Skip to content
Agent

Subagents

by BAEM1N

AI Summary

Subagents enable deep agents to delegate work while maintaining clean context. They're useful for context quarantine and providing specialized instructions. Subagents solve the context bloat problem. When agents use tools producing large outputs (web searches, file reads, database queries), the cont

Install

Copy this and paste it into Claude Code, Cursor, or any AI assistant:

I want to set up the "Subagents" agent in my project.

Please run this command in my terminal:
# Add AGENTS.md to your project root
curl --retry 3 --retry-delay 2 --retry-all-errors -o AGENTS.md "https://raw.githubusercontent.com/BAEM1N/langchain-langgraph-deepagents-notebooks/main/docs/deepagents/07-subagents.md"

Then explain what the agent does and how to invoke it.

Description

LangChain · LangGraph · Deep Agents Notebooks

Overview

Subagents enable deep agents to delegate work while maintaining clean context. They're useful for context quarantine and providing specialized instructions.

Why Use Subagents?

Subagents solve the context bloat problem. When agents use tools producing large outputs (web searches, file reads, database queries), the context window fills rapidly with intermediate results. Subagents isolate detailed work — the main agent receives only final results, not the dozens of tool calls that produced them. When to use: • Multi-step tasks that would clutter main agent context • Specialized domains needing custom instructions or tools • Tasks requiring different model capabilities • When keeping main agent focused on high-level coordination When NOT to use: • Simple, single-step tasks • When intermediate context is needed • When overhead outweighs benefits

SubAgent (Dictionary-based)

| Field | Type | Description | |-------|------|-------------| | name | str | Required unique identifier | | description | str | Required; what the subagent does | | system_prompt | str | Required; custom instructions (does not inherit from parent) | | tools | list[Callable] | Required; overrides parent tools when specified | | model | str \| BaseChatModel | Optional; overrides main agent model | | middleware | list[Middleware] | Optional; custom behavior/logging (no inheritance) | | interrupt_on | dict[str, bool] | Optional; human-in-the-loop config that overrides main agent settings | | skills | list[str] | Optional; isolated skill directories per subagent | | response_format | ResponseFormat | Optional; structured output schema (requires deepagents ≥ 0.5.3) | | permissions | list[FilesystemPermission] | Optional; replaces parent rules entirely |

CompiledSubAgent

For complex workflows using pre-built LangGraph graphs: | Field | Type | Description | |-------|------|-------------| | name | str | Required unique identifier | | description | str | Required; what it does | | runnable | Runnable | Required; compiled LangGraph graph |

Discussion

0/2000
Loading comments...

Health Signals

MaintenanceCommitted Yesterday
Active
AdoptionUnder 100 stars
52 ★ · Niche
DocsMissing or thin
Undocumented

GitHub Signals

Stars52
Forks15
Issues0
UpdatedYesterday
View on GitHub
No License

My Fox Den

Community Rating

Sign in to rate this booster

Works With

Claude Code
Claude.ai