inspect_ai.event
Core Events
ModelEvent
Call to a language model.
class ModelEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['model']-
Event type.
modelstr-
Model name.
rolestr | None-
Model role.
inputlist[ChatMessage]-
Model input (list of messages).
input_refslist[tuple[int, int]] | None-
Message pool references for input. Each element is a (start, end_exclusive) range.
toolslist[ToolInfo]-
Tools available to the model.
tool_choiceToolChoice-
Directive to the model which tools to prefer.
configGenerateConfig-
Generate config used for call to model.
outputModelOutput-
Output from model.
retriesint | None-
Retries for the model API request.
errorstr | None-
Error which occurred during model call.
tracebackstr | None-
Error traceback (plain text).
traceback_ansistr | None-
Error traceback with ANSI color codes for display.
cacheLiteral['read', 'write'] | None-
Was this a cache read or write.
callModelCall | None-
Raw call made to model API.
completedUtcDatetime | None-
Time that model call completed (see
timestampfor started) working_timefloat | None-
working time for model call that succeeded (i.e. was not retried).
ToolEvent
Call to a tool.
class ToolEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['tool']-
Event type.
typeLiteral['function']-
Type of tool call (currently only ‘function’)
idstr-
Unique identifier for tool call.
functionstr-
Function called.
argumentsdict[str, JsonValue]-
Arguments to function.
viewToolCallContent | None-
Custom view of tool call input.
resultToolResult-
Function return value.
truncatedtuple[int, int] | None-
Bytes truncated (from,to) if truncation occurred
errorToolCallError | None-
Error that occurred during tool call.
completedUtcDatetime | None-
Time that tool call completed (see
timestampfor started) working_timefloat | None-
Working time for tool call (i.e. time not spent waiting on semaphores).
agentstr | None-
Name of agent if the tool call was an agent handoff.
agent_span_idstr | None-
Span ID of the agent span, if this tool call spawned an agent.
failedbool | None-
Did the tool call fail with a hard error?.
message_idstr | None-
Id of ChatMessageTool associated with this event.
cancelledbool-
Was the task cancelled?
BranchEvent
Branch in conversation history.
class BranchEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['branch']-
Event type.
from_spanstr-
Span where the branch originated.
from_messagestr-
Message at the branch point.
CompactionEvent
Compaction of conversation history.
class CompactionEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['compaction']-
Event type.
typeLiteral['summary', 'edit', 'trim']-
Compaction type.
tokens_beforeint | None-
Tokens before compaction.
tokens_afterint | None-
Tokens after compaction.
sourcestr | None-
Compaction source (e.g. ‘inspect’, ‘claude_code’, etc.)
ApprovalEvent
Tool approval.
class ApprovalEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['approval']-
Event type
messagestr-
Message generated by model along with tool call.
callToolCall-
Tool call being approved.
viewToolCallView | None-
View presented for approval.
approverstr-
Aprover name.
decisionLiteral['approve', 'modify', 'reject', 'escalate', 'terminate']-
Decision of approver.
modifiedToolCall | None-
Modified tool call for decision ‘modify’.
explanationstr | None-
Explanation for decision.
SandboxEvent
Sandbox execution or I/O
class SandboxEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['sandbox']-
Event type
actionLiteral['exec', 'read_file', 'write_file']-
Sandbox action
cmdstr | None-
Command (for exec)
optionsdict[str, JsonValue] | None-
Options (for exec)
filestr | None-
File (for read_file and write_file)
inputstr | None-
Input (for cmd and write_file). Truncated to 100 lines.
resultint | None-
Result (for exec)
outputstr | None-
Output (for exec and read_file). Truncated to 100 lines.
completedUtcDatetime | None-
Time that sandbox action completed (see
timestampfor started)
InfoEvent
Event with custom info/data.
class InfoEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['info']-
Event type.
sourcestr | None-
Optional source for info event.
dataJsonValue-
Data provided with event.
ScoreEvent
Event with score.
Can be the final score for a Sample, or can be an intermediate score resulting from a call to score.
class ScoreEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['score']-
Event type.
scoreScore-
Score value.
targetstr | list[str] | None-
“Sample target.
intermediatebool-
Was this an intermediate scoring?
model_usagedict[str, ModelUsage] | None-
Cumulative model usage at the time of this score.
role_usagedict[str, ModelUsage] | None-
Cumulative model usage by role at the time of this score.
LoggerEvent
Log message recorded with Python logger.
class LoggerEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['logger']-
Event type.
messageLoggingMessage-
Logging message
ErrorEvent
Event with sample error.
class ErrorEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['error']-
Event type.
errorEvalError-
Sample error
SpanBeginEvent
Mark the beginning of a transcript span.
class SpanBeginEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['span_begin']-
Event type.
idstr-
Unique identifier for span.
parent_idstr | None-
Identifier for parent span.
typestr | None-
Optional ‘type’ field for span.
namestr-
Span name.
SpanEndEvent
Mark the end of a transcript span.
class SpanEndEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['span_end']-
Event type.
idstr-
Unique identifier for span.
Event Tree
event_tree
Build a tree representation of a sequence of events.
Organize events heirarchially into event spans.
def event_tree(events: Sequence[Event]) -> EventTreeeventsSequence[Event]-
Sequence of
Event.
event_tree_walk
Walk an event tree yielding nodes matching a filter.
def event_tree_walk(
tree: EventTree,
filter: type[T]
| tuple[type[T], ...]
| Callable[[EventTreeNode], bool]
| None = None,
) -> Iterable[T] | Iterable[EventTreeNode]treeEventTree-
Event tree to walk.
filtertype[T] | tuple[type[T], ...] | Callable[[EventTreeNode], bool] | None-
A type, tuple of types (passed to
isinstance), a predicate function, or None to yield all nodes.
event_sequence
Flatten a span forest back into a properly ordered seqeunce.
def event_sequence(tree: EventTree | EventTreeSpan) -> Iterable[Event]treeEventTree | EventTreeSpan-
Event tree or EventTreeSpan.
EventTree
Tree of events (has invividual events and event spans).
EventTree: TypeAlias = list[EventTreeNode]EventTreeSpan
Event tree node representing a span of events.
@dataclass
class EventTreeSpanAttributes
idstr-
Span id.
parent_idstr | None-
Parent span id.
typestr | None-
Optional ‘type’ field for span.
namestr-
Span name.
beginSpanBeginEvent-
Span begin event.
endSpanEndEvent | None-
Span end event (if any).
childrenlist[EventTreeNode]-
Children in the span.
EventTreeNode
Node in an event tree.
EventTreeNode: TypeAlias = Union["EventTreeSpan", Event]Timeline
timeline_build
Build a Timeline from a flat event list.
Transforms a flat event stream into a hierarchical Timeline tree with agent-centric interpretation. The pipeline has two phases:
Phase 1 — Structure extraction:
Uses event_tree() to parse span_begin/span_end events into a tree, then looks for top-level phase spans (“init”, “solvers”, “scorers”):
- If present, partitions events into init (setup), agent (solvers), and scoring sections.
- If absent, treats the entire event stream as the agent.
Phase 2 — Agent classification:
Within the agent section, spans are classified as agents or unrolled:
============================== ======================================= Span type Result ============================== ======================================= type="agent" TimelineSpan(span_type="agent") type="solver" TimelineSpan(span_type="agent") type="tool" + ModelEvents TimelineSpan(span_type="agent") ToolEvent with agent field TimelineSpan(span_type="agent") type="tool" (no models) Unrolled into parent Any other span type Unrolled into parent ============================== =======================================
“Unrolled” means the span wrapper is removed and its child events dissolve into the parent’s content list.
Phase 3 — Post-processing passes:
- Auto-branch detection (re-rolled ModelEvents with identical inputs)
- Utility agent classification (single-turn agents with different system prompts)
- Recursive branch classification
def timeline_build(
events: list[Event], *, name: str | None = None, description: str | None = None
) -> Timelineeventslist[Event]-
Flat list of Events from a transcript.
namestr | None-
Optional name for timeline (defaults to “Default”)
descriptionstr | None-
Optional description for timeline (defaults to ““)
timeline_dump
Serialize a Timeline to a JSON-compatible dict.
Converts a Timeline into a plain dictionary suitable for JSON serialization. Event objects within the timeline are replaced by their UUIDs, keeping the serialized form compact and self-referencing.
def timeline_dump(timeline: Timeline) -> dict[str, Any]timelineTimeline-
The Timeline to serialize.
timeline_filter
Return a new timeline with only spans matching the predicate.
Recursively walks the span tree, keeping TimelineSpan items where predicate(span) returns True. Non-matching spans and their entire subtrees are pruned. TimelineEvent items are always kept (they belong to the parent span).
Use this to pre-filter a timeline before passing it to timeline_messages().
def timeline_filter(
timeline: Timeline,
predicate: Callable[[TimelineSpan], bool],
) -> TimelinetimelineTimeline-
The timeline to filter.
predicateCallable[[TimelineSpan], bool]-
Function that receives a TimelineSpan and returns
Trueto keep it (and its subtree),Falseto prune it.
timeline_load
Deserialize a Timeline from a dict produced by timeline_dump.
Reconstructs a full Timeline by resolving the UUID strings stored in data back to their corresponding Event objects from events.
def timeline_load(data: dict[str, Any], events: list[Event]) -> Timelinedatadict[str, Any]-
A dict previously produced by
timeline_dump. eventslist[Event]-
The flat list of Event objects whose UUIDs appear in
data. Events without a UUID are ignored.
timeline_branch
Context manager for creating a timeline branch.
@contextlib.asynccontextmanager
async def timeline_branch(
*, name: str, from_span: str, from_message: str, id: str | None = None
) -> AsyncIterator[None]namestr-
Name of branch span.
from_spanstr-
Span where the branch originated.
from_messagestr-
Message id at the branch point.
idstr | None-
Optional span ID. Generated if not provided.
Timeline
A named timeline view over a transcript.
Multiple timelines allow different interpretations of the same event stream — e.g. a default agent-centric view alongside an alternative grouping or filtered view.
class Timeline(BaseModel)Methods
- render
-
Render an ASCII swimlane diagram of the timeline.
def render(self, width: int | None = None) -> strwidthint | None-
Total width of the output in characters. Defaults to 120.
TimelineEvent
Wraps a single Event.
class TimelineEvent(BaseModel)Methods
- start_time
-
Event timestamp (required field on all events).
def start_time(self) -> datetime - end_time
-
Event completion time if available, else timestamp.
def end_time(self) -> datetime - total_tokens
-
Tokens from this event (ModelEvent only).
Includes input_tokens_cache_read and input_tokens_cache_write in the total, as these represent actual token consumption for any LLM system using prompt caching. The sum of all token fields provides an accurate measure of total context window usage across all sources.
def total_tokens(self) -> int - idle_time
-
Seconds of idle time (always 0 for a single event).
def idle_time(self) -> float
TimelineSpan
A span of execution — agent, scorer, tool, or root.
class TimelineSpan(BaseModel)Methods
- start_time
-
Earliest start time among content (and optionally branches).
def start_time(self, include_branches: bool = True) -> datetimeinclude_branchesbool-
Include branches in time calcluation.
- end_time
-
Latest end time among content (and optionally branches).
def end_time(self, include_branches: bool = True) -> datetimeinclude_branchesbool-
Include branches in time calcluation.
- total_tokens
-
Sum of tokens from content (and optionally branches).
def total_tokens(self, include_branches: bool = True) -> intinclude_branchesbool-
Include branches in token calcluation.
- idle_time
-
Seconds of idle time within this span (and optionally branches).
def idle_time(self, include_branches: bool = True) -> floatinclude_branchesbool-
Include branches in time calcluation.
Outline
Hierarchical outline of events for an agent.
class Outline(BaseModel)OutlineNode
A node in an agent’s outline, referencing an event by UUID.
class OutlineNode(BaseModel)Eval Events
SampleInitEvent
Beginning of processing a Sample.
class SampleInitEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['sample_init']-
Event type.
sampleSample-
Sample.
stateJsonValue-
Initial state.
SampleLimitEvent
The sample was unable to finish processing due to a limit
class SampleLimitEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['sample_limit']-
Event type.
typeLiteral['message', 'time', 'working', 'token', 'cost', 'operator', 'custom']-
Type of limit that halted processing
messagestr-
A message associated with this limit
limitfloat | None-
The limit value (if any)
StateEvent
Change to the current TaskState
class StateEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['state']-
Event type.
changeslist[JsonChange]-
List of changes to the TaskState
StoreEvent
Change to data within the current Store.
class StoreEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['store']-
Event type.
changeslist[JsonChange]-
List of changes to the Store.
InputEvent
Input screen interaction.
class InputEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['input']-
Event type.
inputstr-
Input interaction (plain text).
input_ansistr-
Input interaction (ANSI).
ScoreEditEvent
Event recorded when a score is edited.
class ScoreEditEvent(BaseEvent)Attributes
uuidstr | None-
Unique identifer for event.
span_idstr | None-
Span the event occurred within.
timestampUtcDatetime-
Clock time at which event occurred.
working_startfloat-
Working time (within sample) at which the event occurred.
metadatadict[str, Any] | None-
Additional event metadata.
pendingbool | None-
Is this event pending?
eventLiteral['score_edit']-
Event type.
score_namestr-
Name of the score being edited.
editScoreEdit-
The edit being applied to the score.
Types
LoggingLevel
Logging level.
LoggingLevel = Literal[
"debug", "trace", "http", "sandbox", "info", "warning", "error", "critical"
]LoggingMessage
Message written to Python log.
class LoggingMessage(BaseModel)Attributes
namestr | None-
Logger name (e.g. ‘httpx’)
levelLoggingLevel-
Logging level.
messagestr-
Log message.
createdfloat-
Message created time.
filenamestr-
Logged from filename.
modulestr-
Logged from module.
linenoint-
Logged from line number.