Skip to main content
The ready-to-run example is available here!

Understanding the Tool System

The SDK’s tool system is built around three core components:
  1. Action - Defines input parameters (what the tool accepts)
  2. Observation - Defines output data (what the tool returns)
  3. Executor - Implements the tool’s logic (what the tool does)
These components are tied together by a ToolDefinition that registers the tool with the agent.

Built-in Tools

The tools package (source code) provides a bunch of built-in tools that follow these patterns.
See source code for the complete list of available tools and design philosophy.

Creating a Custom Tool

Here’s a minimal example of creating a custom grep tool:
1

Define the Action

Defines input parameters (what the tool accepts)
2

Define the Observation

Defines output data (what the tool returns)
The to_llm_content() property formats observations for the LLM.
3

Define the Executor

Implements the tool’s logic (what the tool does)
4

Finally, define the tool

Good to know

Tool Registration

Tools are registered using register_tool() and referenced by name:

Factory Functions

Tool factory functions receive conv_state as a parameter, allowing access to workspace information:

Shared Executors

Multiple tools can share executors for efficiency and state consistency:

When to Create Custom Tools

Create custom tools when you need to:
  • Combine multiple operations into a single, structured interface
  • Add typed parameters with validation
  • Format complex outputs for LLM consumption
  • Integrate with external APIs or services

Ready-to-run Example

This example is available on GitHub: examples/01_standalone_sdk/02_custom_tools.py
examples/01_standalone_sdk/02_custom_tools.py
You can run the example code as-is.
The model name should follow the LiteLLM convention: provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o). The LLM_API_KEY should be the API key for your chosen provider.
ChatGPT Plus/Pro subscribers: You can use LLM.subscription_login() to authenticate with your ChatGPT account and access Codex models without consuming API credits. See the LLM Subscriptions guide for details.

Next Steps