Basic Usage
Add functions directly as tools:Tool Configuration
Use theTool type for custom descriptions and parameter control. The handler parameter is required and must be the function:
Custom Description
If the function name or docstring doesn’t clearly describe what the tool does, add a customdescription. This is the description the LLM sees about the tool:
Parameter Visibility
When a tool has many parameters, reduce tokens and avoid overwhelming the LLM by showing only required parameters:Default Parameters
Set default values that are automatically applied when the tool is called. These values are used when not specified by the LLM:Built-in Tools
Timbal provides built-in tools for common use cases. These tools are ready to use and don’t require implementing handlers.WebSearch
WebSearch enables agents to search the web.
allowed_domains: List of domains to restrict searches toblocked_domains: List of domains to exclude (Anthropic only)user_location: Dictionary with location info to localize search results. Must includetypefield. Common values are"approximate"or"exact", but valid values depend on the provider.
Multiple Instances of the Same Tool
If you need multiple instances of the same built-in tool with different configurations, they will have the same name by default, which causes conflicts. Set unique names and descriptions for each instance:Agent as a Tool
You can use an Agent as a tool within another Agent, enabling hierarchical agent compositions where specialized agents handle specific tasks. SinceAgent instances can be treated as Tool objects, they inherit the same parameter control configurations available to regular tools.
Automatic Nesting: When an agent is used as a tool within another agent (as shown above), it’s automatically nested for proper tracing and context management. However, if you use an agent inside a
pre_hook or post_hook, you must manually call .nest(). See Using Agents in Hooks for details.Commands
Register acommand on any tool, agent, or workflow to let users invoke it directly with a / prefix — bypassing the LLM for that turn:
MCP Servers
Connect any Model Context Protocol server and use its tools like native ones:Dynamic Tools
When tool availability depends on runtime conditions (user role, permissions, input parameters), you need dynamic tool resolution. Instead of exposing all tools to the agent, use Timbal’sToolSet class to resolve which tools are available at runtime.
For example, with a role-based ToolSet:
- Role: admin → Available tools:
delete_user,modify_permissions,view_profile - Role: user → Available tools:
view_profile
Summary
- Automatic Introspection: Function signatures become tool schemas automatically
- Enhanced Validation: Pydantic-based parameter validation
- Execution Flexibility: Support for all Python callable types
- Better Configuration: Fine-grained parameter control
- Performance: Concurrent execution and optimized patterns
- Robustness: Improved error handling and tracing
- Tool Sets: Dynamic tool resolution
- MCP Servers: Any Model Context Protocol server as a tool source — see MCP Servers
- Commands: Slash-command shortcuts for direct tool invocation — see Commands