Skip to content

Tools

Tools give agents the ability to interact with the world — reading files, writing code, running shell commands, searching codebases, and more. Chimera ships 20 built-in tools and provides two ways to define custom tools: a class-based approach via BaseTool and a decorator-based shortcut via @tool.

Every tool in Chimera extends BaseTool, defined in chimera.core.tool:

class BaseTool(ABC):
name: str # Tool name (used in LLM function calling)
description: str # Description shown to the model
parameters: dict[str, Any] # JSON Schema for arguments
requires_approval: bool = False # Whether the tool needs human approval
@abstractmethod
def execute(self, args: dict[str, Any], env: Environment | None) -> ToolResult:
"""Execute the tool with given arguments."""
def to_openai_schema(self) -> dict[str, Any]:
"""Convert to OpenAI function calling format."""
def to_anthropic_schema(self) -> dict[str, Any]:
"""Convert to Anthropic tool use format."""

Key points:

  • execute() receives the parsed arguments and an optional Environment, and returns a ToolResult(output, error, metadata).
  • to_openai_schema() and to_anthropic_schema() generate the schema format each provider expects. You only need to define parameters once as JSON Schema.
  • requires_approval can flag dangerous tools for human-in-the-loop confirmation (when used with a PermissionPolicy in LoopConfig).

For simple tools, skip the class and use the @tool decorator:

from chimera.core.tool import tool
@tool(
name="word_count",
description="Count words in a file",
parameters={
"type": "object",
"properties": {
"path": {"type": "string", "description": "Path to the file"},
},
"required": ["path"],
},
)
def word_count(args, env):
content = env.read_file(args["path"])
count = len(content.split())
return ToolResult(output=f"{count} words")

The decorator wraps your function in a _FunctionTool instance that implements BaseTool. The function signature is always (args: dict, env: Environment | None) -> ToolResult.

ToolGroup organizes tools into named collections, like a preset toolkit:

from chimera.core.tool_group import ToolGroup
from chimera.tools import ReadFileTool, WriteFileTool, BashTool, SearchTool
coding_tools = ToolGroup("coding", [
ReadFileTool(),
WriteFileTool(),
BashTool(),
SearchTool(),
])
# Iterate, look up by name, add tools dynamically
coding_tools.has("bash") # True
coding_tools.get("bash") # BashTool instance
coding_tools.add(my_tool) # Add a custom tool
len(coding_tools) # Number of tools
list(coding_tools) # Iterate over tools

Chimera provides a pre-built DEFAULT_TOOLS group with the essential tools:

from chimera.core.tool_group import DEFAULT_TOOLS
# Contains: ReadFileTool, WriteFileTool, BashTool, ImageReadTool
agent = Agent(provider=provider, tools=list(DEFAULT_TOOLS))