Skip to main content

Overview

Class-based tools automatically register all public methods (not starting with _) as tools. Simply create a class instance and pass it to your agent or task.

Example

Key Points

  • Public methods only: Methods starting with _ are ignored
  • Automatic registration: All public methods become tools automatically

Class Tool vs ToolKit

When to Use Each

Use Class Tool when:
  • All public methods should be tools
  • Simple utility classes
  • Quick prototyping
Use ToolKit when:
  • You need helper methods that shouldn’t be tools
  • You want explicit control over tool registration
  • You have complex internal logic

State Management

Class instances maintain state between tool calls:

Removing Class Tools

Remove individual methods or the entire class: