Tool Anatomy
A tool consists of:- Function definition with type hints
@tooldecorator from LangChain- Documentation via
@with_docdecorator - Rate limiting via
@with_rate_limiting(optional) - Return value with structured data
Basic Tool Example
Here’s a simple weather tool fromapp/agents/tools/weather_tool.py:
Advanced Tool Pattern
A more complex tool fromapp/agents/tools/todo_tool.py:
Tool Decorators
@tool - LangChain Tool Decorator
Marks a function as a LangChain tool:@with_doc - Documentation Decorator
Adds detailed documentation from templates:app/templates/docstrings/:
@with_rate_limiting - Rate Limit Decorator
Prevents abuse with rate limiting:Streaming Progress
Useget_stream_writer() to send real-time updates:
Tool Registration
Register tools in the tool registry:Static Registration
Inapp/agents/tools/core/registry.py:
Dynamic Registration
Register tools at runtime:Integration Tools
Tools requiring OAuth integration:Error Handling
Always handle errors gracefully:Tool Testing
Test tools in isolation:Best Practices
Next Steps
Testing Tools
Learn comprehensive testing strategies for tools
Creating Prompts
Write effective prompts that use your tools