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§
- Runner
Output - Represents a Runner output event that needs to be mapped to a SessionEvent.
- Tool
Kind - Tool classification used to determine which
RunnerOutputvariant 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
RunnerOutputto aSessionEventwith the given sequence number. - requires_
parking - Returns
trueif the givenRunnerOutputrepresents a custom tool call that requires parking (waiting for client response).