Execution Replay

Execution replay lets you debug agent workflows by reviewing the exact sequence of events in a session. Replay every step to understand what happened and why.

Debugging made easy

Sessions capture every API call, event, and result. Use replay to trace failures without adding logging to your code.

Sessions

Every workflow and multi-step operation runs inside a session. Sessions record all events, API calls, and results in a timeline.

typescript
const session = await client.sessions.create({
name: "user-signup-debug",
});
// Run your workflow
const workflow = await client.workflows.createInboxAndWait({
waitType: "otp",
timeoutSeconds: 120,
sessionId: session.id,
});

Timeline

The timeline is a chronological list of every event in the session. Each event includes a timestamp, type, and payload.

typescript
const timeline = await client.sessions.timeline("sess_789");
for (const event of timeline.events) {
console.log(event.timestamp);
console.log(event.type); // "inbox.created", "email.received", etc.
console.log(event.payload); // Full event data
}
Timeline Response
{
"events": [
{
"timestamp": "2024-06-12T10:00:00Z",
"type": "session.created",
"payload": { "sessionId": "sess_789" }
},
{
"timestamp": "2024-06-12T10:00:01Z",
"type": "inbox.created",
"payload": { "inboxId": "inb_123", "emailAddress": "..." }
},
{
"timestamp": "2024-06-12T10:00:05Z",
"type": "wait.created",
"payload": { "waitId": "wait_456", "type": "otp" }
},
{
"timestamp": "2024-06-12T10:02:30Z",
"type": "email.received",
"payload": { "messageId": "msg_789", "subject": "Your code" }
},
{
"timestamp": "2024-06-12T10:02:31Z",
"type": "extraction.completed",
"payload": { "type": "otp", "value": "123456", "confidence": 0.98 }
},
{
"timestamp": "2024-06-12T10:02:31Z",
"type": "wait.completed",
"payload": { "waitId": "wait_456", "result": "123456" }
}
]
}

Replaying a Session

Replay reconstructs the session step-by-step, allowing you to inspect the state at each point.

typescript
const replay = await client.sessions.replay("sess_789");
for (const step of replay.steps) {
console.log(step.index); // 0, 1, 2, ...
console.log(step.timestamp); // When this step occurred
console.log(step.action); // "create_inbox", "wait", "extract"
console.log(step.input); // API request parameters
console.log(step.output); // API response data
console.log(step.durationMs); // How long this step took
}

Debugging with Replay

  • Step durations — Identify slow operations (e.g., long waits)
  • Input/output inspection — See exactly what was sent and received
  • Error tracing — Find the exact step where a failure occurred
  • Confidence analysis — Check extraction confidence scores at each step

Pro tip

Compare successful and failed replays side-by-side to spot differences in inputs, timing, or email content.

Dashboard Replay

You can also view and replay sessions visually in the AgentInbox dashboard.

Go to Sessions in the dashboard, select a session, and click Replay to see a visual timeline with expandable steps.

Related Documentation