Custom tools allow you to extend the agent’s capabilities by registering functions that it can call during execution. When the agent needs to perform an action that your tool provides, it will pause and wait for you to execute the tool and return the result.Documentation Index
Fetch the complete documentation index at: https://docs.smooth.sh/llms.txt
Use this file to discover all available pages before exploring further.
How Custom Tools Work
- Register tools when creating a task via the
custom_toolsparameter - Poll for tool calls - the agent sends
tool_callevents when it needs to use a tool - Execute the tool locally and return the result via the Event endpoint
- Agent continues with the tool’s output
Step 1: Define Your Tools
When creating a task, define your custom tools using thecustom_tools parameter:
Tool Definition Schema
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique identifier for the tool |
description | string | Yes | Explains what the tool does and when to use it |
inputs | object | Yes | JSON Schema describing the input parameters |
output | string | Yes | Description of what the tool returns |
Step 2: Poll for Tool Calls
When the agent needs to call one of your tools, it emits atool_call event. Poll the task endpoint to receive these events:
id field in the event is crucial - you’ll use it to send the response.
Step 3: Execute and Respond
Execute the tool locally, then send the result back via the Event endpoint:Response Format
| Field | Type | Description |
|---|---|---|
name | string | Must be "tool_call" |
id | string | Must match the event ID from the tool call |
payload.code | number | 200 for success, 400 or 500 for errors |
payload.output | any | The tool’s result (or error message) |
Handling Errors
If your tool fails, return an error:Complete Example: Weather Bot
Here’s a complete implementation that handles custom tool calls:Using with Sessions
Custom tools work the same way with session workflows. Define them when creating the session:Python SDK Example
The SDK provides a decorator-based approach for custom tools:Best Practices
- Write clear descriptions - The agent uses descriptions to decide when to call your tool
- Define complete schemas - Include all required fields and descriptions for each input
- Handle errors gracefully - Return meaningful error messages so the agent can recover
- Set appropriate timeouts - Long-running tools should be async with proper timeout handling
- Validate inputs - Check that required fields are present before executing