replay_session

Function replay_session 

Source
pub async fn replay_session(
    config: SessionConfig,
    builder: LiveSessionBuilder,
    entries: &[WireEntry],
) -> Result<ReplaySession, AgentError>
Expand description

Replay a recorded wire log through the real L1 processor, offline.

  • config is used to open the replay transport (its re-encoded setup message becomes the first outbound frame, mirroring the original run). Use the same configuration as the recorded session for a faithful setup comparison. No network is touched and no credential is used.
  • builder supplies the control plane: dispatcher, phases, extractors, watchers, state, callbacks. Attach the original tool implementations to re-execute tools deterministically; without a dispatcher, recorded tool calls surface as events but produce no responses.
  • entries is the recorded log; only its inbound frames are replayed (outbound entries are kept in the log purely for comparison/audit).

Frames are delivered as fast as the session consumes them, but the session reads time from a ManualClock that moves to each frame’s recorded capture time as it is delivered (this replaces any clock the builder set). Temporal patterns, phase durations, resolver cache expiry and the session: timing signals therefore see the original gaps between frames, whatever the replay’s own speed.

The session processes frames asynchronously, so before the clock jumps by REPLAY_SYNC_STEP or more, the next frame waits until both event lanes have handled every event of the frames before it (the router runs in lockstep during a replay). An earlier frame is then evaluated at its own time, not a later one. Jumps smaller than the step are not waited for, which keeps dense audio fast and bounds the timing error at the step. The replay is gated: nothing past the setup handshake flows until ReplaySession::release is called, so subscribe to events first.