Skip to main content

Module event_mapping

Module event_mapping 

Source
Expand description

Provider-neutral event mapping from Runner output to SessionEvent.

This module defines the RunnerOutput enum representing raw Runner events and the map_runner_output function that maps them uniformly to SessionEvent variants — guaranteeing identical type sequences regardless of which LLM provider powered the turn.

§Provider Parity

The mapping is the key enforcement point for Requirement 5.1 and 5.5: an identical ManagedAgentDef run against any provider MUST produce byte-identical SessionEvent type sequences. The provider-specific differences (tool call format, stop reasons, streaming deltas) are normalized here before entering the session event stream.

§Architecture

Runner (provider-specific events)
  │
  ▼
RunnerOutput (normalized intermediate)
  │
  ▼
map_runner_output(output, seq) → SessionEvent (provider-neutral)

The session loop calls map_runner_output for each event emitted by the Runner, producing a uniform stream that is then checkpointed and broadcast.

Enums§

RunnerOutput
Represents a Runner output event that needs to be mapped to a SessionEvent.
ToolKind
Tool classification used to determine which RunnerOutput variant to produce.

Functions§

custom_tool_use_id
Extracts the custom tool use ID from a RunnerOutput, if it’s a custom tool call.
map_runner_output
Maps a RunnerOutput to a SessionEvent with the given sequence number.
requires_parking
Returns true if the given RunnerOutput represents a custom tool call that requires parking (waiting for client response).