How It Works
How to Create Tools as Functions
1
Define Simple Function
2
Use with Agent
How to Create Tools as Lambda Functions
1
Define Lambda Tool
2
Use with Agent
How to Create Tools from External Libraries
1
Wrap Library Function
2
Use Wrapped Tool
How to Create Tools in tools.py File
1
Create tools.py
2
Reference in Template
How to Create Tools in a Package
1
Create Package Structure
2
Define Tools in Module
3
Export in __init__.py
4
Use as tools_source
How to Create Tools with Decorators
1
Use Tool Decorator
2
Use with Agent
How to Add Tools via CLI
1
Add Package Tools
2
Add Local File
3
Add from GitHub
4
Verify Added Tools
How to Create Tools with Choice Parameters
1
Use Literal for Fixed Options
Tool Creation Methods Comparison
Best Practices
Start with a plain function and @tool
Start with a plain function and @tool
The function-plus-decorator path has the lowest complexity and covers most tools — reach for classes only when you need shared state.
Use classes for stateful tools
Use classes for stateful tools
When a tool holds a connection or cache, a class keeps that state tidy; pass the bound methods to the agent’s
tools list.Wrap external libraries thinly
Wrap external libraries thinly
Adapt a library call into a typed, docstringed function so the model gets a clean schema without the library’s full surface.
Related
Create Custom Tools
Detailed walkthrough per tool style
Remote Tools from GitHub
Load tools from remote sources

