Skip to content

Tool Response

ToolResponse objects encapsulate the complete outcome of tool executions and contextual metadata.

Structure

@dataclass
class ToolResponse:
    tool: ToolUse         # Tool invocation details (name and arguments)
    result: Optional[Any] # Return value from tool execution

Key Features

  • Unified Interface: Access tool results and errors through standardized fields
  • Context Preservation: Maintains link to original tool call through tool property
  • Error Resilience: Captures exceptions without interrupting control flow

Example Usage

response = toolbox.use(event)
print(f"{response.tool.name} result: {response.result}")