Tool Architecture
DeerFlow’s tools come from multiple sources:Tool Loading
Tools are assembled viaget_available_tools():
- Config-defined tools (via reflection)
- MCP tools (from enabled servers)
- Built-in tools
- Sub-agent tool (if enabled)
Sandbox Tools
Core filesystem and command execution tools:bash
Execute shell commands in the sandbox
ls
List directory contents in tree format
read_file
Read file contents with optional line range
write_file
Write or append to files
str_replace
Replace text in files
Sandbox Tools Reference
Complete tool documentation
Built-in Tools
Tools available to all agents:present_files
Make output files visible to the user. Usage:- Only files in
/mnt/user-data/outputscan be presented - Files must exist
- Returns artifact metadata for frontend display
ask_clarification
Request clarification from the user (interrupts execution). Usage:- Interrupts agent execution
- Returns control to user
- User response appended to conversation
view_image
Load image as base64 for vision-enabled models. Usage:- Model must have
supports_vision: true - Image formats: PNG, JPEG, GIF, WebP
Built-in Tools Reference
Detailed tool documentation
Community Tools
Pre-integrated external service tools:web_search (Tavily)
Search the web for current information. Configuration:TAVILY_API_KEY environment variable
web_fetch
Fetch and extract content from web pages. Providers: Tavily, Jina AI, Firecrawl Configuration:image_search (DuckDuckGo)
Search for images. Configuration:Community Tools Reference
All community tools
MCP Tools
Model Context Protocol (MCP) enables integration with external tools and services. Configuration (extensions_config.json):
- stdio transport: Command-based servers
- HTTP/SSE transport: Web-based servers
- OAuth support: Automatic token management
- Lazy loading: Tools loaded on first use
- Cache invalidation: Detects config changes
MCP Integration Guide
Set up MCP servers
Sub-agent Tool
Delegate complex tasks to sub-agents. Configuration:- Up to 3 concurrent sub-agents
- Isolated contexts
- Shared filesystem
- 15-minute timeout
Sub-agents
Learn about task delegation
Custom Tools
Add your own tools viaconfig.yaml:
my_tools/custom.py
use: module.path:variable_nameresolved viaresolve_variable()- Validates against LangChain tool interface
- Supports any callable that returns a LangChain tool
Creating Custom Tools
Build your own tools
Tool Groups
Organize tools into logical groups:Tool Calling Flow
- Agent Decision: Agent decides to use a tool
- Tool Call Message: AIMessage with
tool_calls - Tool Execution: Tool function invoked
- Tool Message: ToolMessage with result
- Agent Processing: Agent processes result
Error Handling
Tools should handle errors gracefully:- Return error messages as strings (not raise exceptions)
- Include context in error messages
- Suggest fixes when possible
Tool Permissions
Skills can restrict tool usage:SKILL.md frontmatter
Next Steps
Sandbox Tools
Filesystem and command tools
Built-in Tools
Core agent tools
MCP Integration
Connect external tools
Custom Tools
Create your own tools