inspect_ai.event
Core Events
ModelEvent
Call to a language model.
class ModelEvent(BaseEvent)Attributes
eventLiteral['model']-
Event type.
modelstr-
Model name.
rolestr | None-
Model role.
inputlist[ChatMessage]-
Model input (list of messages).
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.
cacheLiteral['read', 'write'] | None-
Was this a cache read or write.
callModelCall | None-
Raw call made to model API.
completeddatetime | 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
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.
completeddatetime | 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.
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?
ApprovalEvent
Tool approval.
class ApprovalEvent(BaseEvent)Attributes
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
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.
completeddatetime | None-
Time that sandbox action completed (see
timestampfor started)
InfoEvent
Event with custom info/data.
class InfoEvent(BaseEvent)Attributes
eventLiteral['info']-
Event type.
sourcestr | None-
Optional source for info event.
dataJsonValue-
Data provided with event.
LoggerEvent
Log message recorded with Python logger.
class LoggerEvent(BaseEvent)Attributes
eventLiteral['logger']-
Event type.
messageLoggingMessage-
Logging message
ErrorEvent
Event with sample error.
class ErrorEvent(BaseEvent)Attributes
eventLiteral['error']-
Event type.
errorEvalError-
Sample error
SpanBeginEvent
Mark the beginning of a transcript span.
class SpanBeginEvent(BaseEvent)Attributes
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
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_sequence
Flatten a span forest back into a properly ordered seqeunce.
def event_sequence(tree: EventTree) -> Iterable[Event]treeEventTree-
Event tree
EventTree
Tree of events (has invividual events and event spans).
EventTree: TypeAlias = list[EventNode]EventNode
Node in an event tree.
EventNode: TypeAlias = Union["SpanNode", Event]SpanNode
Event tree node representing a span of events.
@dataclass
class SpanNodeAttributes
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[EventNode]-
Children in the span.
Eval Events
SampleInitEvent
Beginning of processing a Sample.
class SampleInitEvent(BaseEvent)Attributes
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
eventLiteral['sample_limit']-
Event type.
typeLiteral['message', 'time', 'working', 'token', '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
eventLiteral['state']-
Event type.
changeslist[JsonChange]-
List of changes to the TaskState
StoreEvent
Change to data within the current Store.
class StoreEvent(BaseEvent)Attributes
eventLiteral['store']-
Event type.
changeslist[JsonChange]-
List of changes to the Store.
InputEvent
Input screen interaction.
class InputEvent(BaseEvent)Attributes
eventLiteral['input']-
Event type.
inputstr-
Input interaction (plain text).
input_ansistr-
Input interaction (ANSI).
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
eventLiteral['score']-
Event type.
scoreScore-
Score value.
targetstr | list[str] | None-
“Sample target.
intermediatebool-
Was this an intermediate scoring?
ScoreEditEvent
Event recorded when a score is edited.
class ScoreEditEvent(BaseEvent)Attributes
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.