To build a specialized research agent using the deepagents package, you should compose four key components: native tools, task-specific tools, task-specific instructions, and task-specific sub-agents. This modular approach allows for better context isolation and specialized capabilities.
Workflow Summary
- Define Tools: Combine native tools with custom tools (e.g.,
tavily_search for web access and a think_tool for reasoning audits). - Define Instructions: Use prompting techniques like 'Think Like The Agent' (broad-to-narrow search), 'Concrete Heuristics' (setting tool call budgets), and 'Show your thinking' (using a think tool to analyze results).
- Define Sub-Agents: Create sub-agents as dictionaries to isolate context. A sub-agent requires a
name, description, system_prompt, and a list of tools. - Initialize Agent: Use
create_deep_agent to bind the model, tools, instructions, and sub-agents together.
from deepagents import create_deep_agent
from langchain.chat_models import init_chat_model
# 1. Setup Model
model = init_chat_model(model="anthropic:claude-sonnet-4-5-20250929", temperature=0.0)
# 2. Define Sub-agent
research_sub_agent = {
"name": "research-agent",
"description": "Delegate research to the sub-agent researcher.",
"system_prompt": "Your specialized instructions here",
"tools": [tavily_search, think_tool],
}
# 3. Create Agent
agent = create_deep_agent(
model=model,
tools=[tavily_search, think_tool],
system_prompt="Main orchestrator instructions",
subagents=[research_sub_agent],
)
# 4. Run Agent
result = agent.invoke({
"messages": [{"role": "user", "content": "your research query"}]
})