A comprehensive template for building Deep Agents using the DeepAgents library and LangGraph Studio.
This template showcases all key DeepAgent capabilities:
- 🔧 Custom Tools - Internet search with Tavily
- 🤖 Subagents - Specialized agents for different tasks
- 📁 File System - Built-in file operations
- 📋 Planning Tool - Task organization and tracking
- 🎨 LangGraph Studio - Visual debugging and development
- Planning Tool: Automatically breaks down complex tasks into manageable steps
- File System: Create, read, edit, and manage files within the agent's context
- Subagents: Delegate specialized tasks to focused sub-agents
- Custom Tools: Extensible tool system for domain-specific functionality
- LangGraph Integration: Full compatibility with LangGraph Studio for visual debugging
src/
├── agent/
│ └── graph.py # Main agent definition
├── tools/
│ └── tool.py # Custom tools (internet search)
└── prompts/
└── prompt.py # Agent prompts and instructions
- Install dependencies
uv add deepagents tavily-python
pip install -e . "langgraph-cli[inmem]"- Set up environment
cp .env.example .env
# Add your API keys to .env- Start LangGraph Studio
langgraph devCreate a .env file with:
# Required for internet search
TAVILY_API_KEY=your_tavily_key
# Optional: LangSmith tracing
LANGSMITH_API_KEY=lsv2_your_key
LANGCHAIN_TRACING_V2=true
# Optional: Other LLM providers
ANTHROPIC_API_KEY=your_anthropic_key
OPENAI_API_KEY=your_openai_keyTo use a different model, uncomment and modify in graph.py:
from langchain_anthropic import ChatAnthropic
agent = create_deep_agent(
tools=[internet_search],
instructions=research_instructions,
subagents=[analysis_subagent],
model=ChatAnthropic(model="claude-3-haiku-20240307")
)- Create your tool function in
src/tools/tool.py - Add it to the tools list in
graph.py
- Define the subagent prompt in
src/prompts/prompt.py - Create the subagent config in
graph.py:
my_subagent = {
"name": "my-agent",
"description": "What this agent does",
"prompt": my_agent_prompt,
"tools": ["tool_name"] # Optional: restrict tools
}Edit src/prompts/prompt.py to customize the main agent's behavior and capabilities.
The agent has access to a virtual file system. Example usage:
# In your agent interactions:
# - write_file("research.md", "# My Research\n...")
# - read_file("data.json")
# - edit_file("report.txt", old_content, new_content)Call specialized subagents for focused tasks:
# The agent can call: "analysis-agent" for detailed technical analysis- Visual Debugging: See your agent's decision process step-by-step
- Hot Reload: Changes to your code are automatically applied
- State Management: Edit past states and rerun from any point
- Thread Management: Create new conversations with the
+button
The template includes a research agent that demonstrates:
- Planning: Breaking down research tasks
- Search: Using Tavily for web research
- Analysis: Calling subagents for detailed analysis
- File Management: Organizing findings in files
- Reporting: Compiling results into structured reports
Try asking: "Research the latest developments in AI agents and create a comprehensive report"
MIT
