An event records one occurrence during agent execution. It wraps typed content—such as a message, tool call, or tool result—with an identifier, execution identifier, timestamp, and author. Grouping events by execution_id creates a complete audit trail for debugging and analysis. section 4.3.1
Use events to represent the main parts of an agent trace:
- Store user and assistant exchanges as Message content with a role and text. section 4.3.1
- Store model requests as ToolCall content, including the tool name, arguments, and tool_call_id. section 4.3.1
- Store execution outcomes as ToolResult content with success or error status, output, and the originating call identifier. section 4.3.1
- Add model responses and tool outcomes to the execution context as separate events during each think–act cycle. section 4.6.3
Tracing a tool call
For the question about Kipchoge running to the Moon, the agent records a user message, a search_web ToolCall, its ToolResult, further research and calculation calls, and the final assistant message. Each event identifies the producing actor and belongs to the same execution. section 4.3.1
Listing 4.3 Event class for execution tracking
class Event(BaseModel):
"""A recorded occurrence during agent execution."""
id: str = Field(default_factory=lambda: str(uuid.uuid4()))
execution_id: str
timestamp: float = Field(default_factory=lambda: datetime.now().timestamp())
author: str # "user" or agent name
content: List[ContentItem] = Field(default_factory=list)
The Event model shows the minimal Python representation: generated identity and timestamp, execution grouping, author, and a list of typed content items. section 4.3.1
