Build sophisticated AI agent systems with planning, sub-agent delegation, and multi-step workflows. Built on the Strands Agents SDK.
Check the related article for more details.
Deep Agents enables AI systems to handle complex, multi-step tasks through:
- 🧠 Strategic Planning - Break down complex tasks into actionable TODOs
- 🤝 Sub-agent Orchestration - Delegate specialized tasks to focused agents
- 📁 Context Management - Efficient file-based operations to keep context lean
- 💾 Session Persistence - Resume work across sessions
- 🔬 Research & Analysis - Multi-perspective investigation and synthesis
Featured Example: DeepSearch - A production-ready research agent demonstrating sub-agent orchestration, parallel research, and intelligent synthesis.
# Using UV
uv add strands-deep-agents
# Using pip
pip install strands-deep-agentsRequirements: Python >= 3.12
from strands_deep_agents import create_deep_agent
agent = create_deep_agent(
instructions="You are a helpful coding assistant.",
model="global.anthropic.claude-sonnet-4-5-20250929-v1:0"
)
result = agent("Create a Python calculator module with add, subtract, multiply, divide functions")
print(result)The agent will automatically:
- Plan the task using TODOs
- Create the file with proper structure
- Add docstrings and examples
# View the agent's planned tasks
for todo in agent.state.get("todos", []):
print(f"[{todo['status']}] {todo['content']}")Output:
[completed] Plan calculator module structure
[completed] Create calculator.py file
[completed] Add arithmetic functions
[completed] Add docstrings and examples
DeepSearch demonstrates the full power of Deep Agents through a production-ready research agent system with intelligent orchestration and parallel research capabilities.
For this example, we can use any internet search tool, for example [Linkup] (https://app.linkup.so/) or tavily tool for web search.
DeepSearch uses a three-tier agent architecture:
- Research Lead Agent - Strategic planning, task decomposition, and synthesis
- Research Sub-agents - Parallel, focused investigation on specific topics
- Citations Agent - Post-processing to add proper source references
- Intelligent Task Decomposition: Analyzes queries as depth-first (multiple perspectives) or breadth-first (independent sub-questions)
- Parallel Research: Deploys multiple sub-agents simultaneously for efficient information gathering
- Context Management: Sub-agents write findings to files, keeping context lean
- Source Citation: Automated citation agent adds proper references to final reports
- Session Persistence: Resume research across sessions
cd examples/deepsearch
# Basic usage with default prompt
python agent.py
# Custom research prompt
python agent.py -p "Research the impact of AI on healthcare in 2025"from strands_deep_agents import create_deep_agent, SubAgent
from strands_tools import tavily, file_read, file_write
# Research sub-agent - performs focused investigations
research_subagent = SubAgent(
name="research_subagent",
description=(
"Specialized research agent for focused investigations. "
"Researches specific questions, gathers facts, analyzes sources. "
"Has access to web search. Writes findings to files."
),
tools=[tavily, file_write],
prompt="You are a thorough researcher. Gather comprehensive, accurate information..."
)
# Citations agent - adds source references
citations_agent = SubAgent(
name="citations_agent",
description="Adds proper citations to research reports.",
tools=[file_read, file_write],
prompt="Add citations to research text using provided sources..."
)
# Create the research lead agent
agent = create_deep_agent(
instructions="""
You are an expert research lead. Your role:
1. Analyze the research question
2. Create a research plan
3. Deploy research sub-agents for focused investigations
4. Synthesize findings into a comprehensive report
5. Call citations agent to add references
""",
subagents=[research_subagent, citations_agent],
tools=[file_read, file_write]
)
# Execute research
result = agent("""
Research AI safety in 2025:
1. Main challenges and concerns
2. Leading organizations and initiatives
Create a comprehensive report with executive summary.
""")- Planning Phase: Lead agent analyzes the query and creates a research plan
- Parallel Research: Multiple research sub-agents investigate different aspects simultaneously
- File-Based Context: Sub-agents write findings to
./research_findings_*.mdfiles - Synthesis: Lead agent reads all findings and synthesizes a comprehensive report
- Citations: Citations agent adds proper source references to the final report
Research findings written to: research_findings_1.md, research_findings_2.md, ...
Final report: ai_safety_2025_report.md
TODOs:
✅ Analyze research question and create plan
✅ Deploy subagent: AI safety challenges
✅ Deploy subagent: Leading organizations
✅ Deploy subagent: Recent initiatives
✅ Synthesize findings into report
✅ Add citations to report
Deep Agents excel at delegating specialized tasks:
from strands_deep_agents import create_deep_agent
subagents = [
{
"name": "researcher",
"description": "Conducts focused research on specific topics",
"prompt": "You are a thorough researcher. Gather comprehensive information."
},
{
"name": "analyst",
"description": "Analyzes data and identifies patterns",
"prompt": "You are a data analyst. Find insights and patterns."
}
]
agent = create_deep_agent(
instructions="You are a research coordinator.",
subagents=subagents
)Resume work across sessions:
from strands.session.file_session_manager import FileSessionManager
session_manager = FileSessionManager(
session_id="project-xyz",
storage_dir="./sessions"
)
agent = create_deep_agent(
instructions="You are a research assistant.",
session_manager=session_manager
)
# First session
agent("Start researching quantum computing")
# Later - conversation history and TODOs restored
agent("Continue where we left off")Extend agents with your own tools:
from strands import tool
@tool
def web_search(query: str) -> str:
"""Search the web for information."""
# Your implementation
return search_results
agent = create_deep_agent(
instructions="You are a research assistant.",
tools=[web_search]
)Create a deep agent with planning and sub-agent capabilities.
from strands_deep_agents import create_deep_agent
agent = create_deep_agent(
instructions="System prompt for the agent",
model=None, # Default: Claude Sonnet 4
subagents=None, # List of SubAgent configs
tools=None, # Additional custom tools
session_manager=None, # For persistence
disable_parallel_tool_calling=False, # Force sequential execution
**kwargs # Additional Agent params
)Define specialized sub-agents:
from strands_deep_agents import SubAgent
subagent = SubAgent(
name="unique_name",
description="When to use this agent (helps main agent decide)",
prompt="System prompt for sub-agent",
tools=[...], # Optional: specific tools
model=model # Optional: override model
)from strands_deep_agents import async_create_deep_agent
agent = await async_create_deep_agent(
instructions="You are a research assistant."
)
result = await agent.invoke_async("Your task")# AWS Bedrock (default provider)
export AWS_REGION=us-east-1
export AWS_ACCESS_KEY_ID=your_key
export AWS_SECRET_ACCESS_KEY=your_secret
# Optional: Skip tool consent prompts
export BYPASS_TOOL_CONSENT=true# Use AWS Bedrock models (default)
agent = create_deep_agent(
model="global.anthropic.claude-sonnet-4-5-20250929-v1:0"
)
# Custom model configuration
from strands.models import Model
custom_model = Model(
provider="bedrock",
name="claude-3-5-sonnet-20241022-v2:0",
region="us-east-1"
)
agent = create_deep_agent(model=custom_model)The examples/ directory contains more patterns:
# Basic agent usage
python examples/basic_usage.py
# Sub-agent delegation patterns
python examples/sub_agents.py
# Session persistence
python examples/session_persistence.py
# DeepSearch - Advanced research agent (recommended)
cd examples/deepsearch
python agent.py- Clear Instructions - Be specific about agent roles and expectations
- Strategic Sub-agents - Use sub-agents for specialized, focused tasks
- Context Management - Use file operations to keep context lean
- Session Persistence - Enable for long-running or resumable tasks
- Prompt for Planning - Encourage agents to create plans before execution
- GitHub: https://github.com/lemopian/strands-deep-agents
- Strands Agents SDK: https://github.com/strands-ai/strands-agents
- Article: Deep Agents Using Strands
- Inspiration: https://github.com/langchain-ai/deepagents
MIT License - see LICENSE file for details.
Built with ❤️ by PA
