The replay module lets you look inside completed agent runs, compare two runs side-by-side, and re-execute a past run with different configuration — all without touching trace files manually.Documentation Index
Fetch the complete documentation index at: https://docs.definable.ai/llms.txt
Use this file to discover all available pages before exploring further.
Quick Example
Inspecting a Run
Build aReplay from any of these sources:
Replay Fields
| Field | Type | Description |
|---|---|---|
run_id | str | Run identifier |
session_id | str | Session identifier |
agent_name | str | Agent name |
model | str | Model used |
input | Any | Original input |
content | Any | Final output content |
messages | List | Full conversation messages |
tool_calls | List[ToolCallRecord] | All tool executions with timing |
tokens | ReplayTokens | Aggregated token usage |
cost | Optional[float] | Total cost in USD |
duration | Optional[float] | Total duration in milliseconds |
steps | List[ReplayStep] | Step-by-step timeline |
knowledge_retrievals | List[KnowledgeRetrievalRecord] | RAG retrieval records |
memory_recalls | List[MemoryRecallRecord] | Memory recall records |
status | str | "completed", "error", or "cancelled" |
error | Optional[str] | Error message (if status is "error") |
ReplayTokens
| Field | Type | Description |
|---|---|---|
input_tokens | int | Prompt tokens |
output_tokens | int | Completion tokens |
total_tokens | int | Total tokens |
reasoning_tokens | int | Reasoning/thinking tokens |
cache_read_tokens | int | Tokens read from cache |
cache_write_tokens | int | Tokens written to cache |
ToolCallRecord
| Field | Type | Description |
|---|---|---|
tool_name | str | Tool function name |
tool_args | Dict | Arguments passed |
result | Optional[str] | Tool return value |
error | Optional[bool] | Whether the call errored |
duration_ms | Optional[float] | Execution time |
Comparing Runs
Compare two runs to see what changed:ReplayComparison Fields
| Field | Type | Description |
|---|---|---|
original | Replay | First run |
replayed | Replay | Second run |
content_diff | Optional[str] | Unified diff of output content |
cost_diff | Optional[float] | Cost difference (b − a) |
token_diff | int | Token difference (b − a) |
duration_diff | Optional[float] | Duration difference (b − a) |
tool_calls_diff | ToolCallsDiff | Added, removed, and common tool calls |
compare_runs directly:
Re-Executing with Overrides
Pass override arguments toreplay() to re-run the same input with different configuration. This returns a new RunOutput instead of a Replay:
Re-execution makes a live API call. The original input is extracted from the replay and sent to the model with your overrides applied.
Async API
All replay methods have async equivalents:compare() and compare_runs() are synchronous (no I/O involved).
Construction Methods
| Method | Input | Description |
|---|---|---|
Replay.from_run_output(run_output) | RunOutput | Build from a just-completed run |
Replay.from_events(events, run_id=) | List[Event] | Build from deserialized trace events |
Replay.from_trace_file(path, run_id=) | str | Path | Build from a JSONL trace file |
agent.replay(run_output=) | RunOutput | Convenience wrapper (returns Replay or RunOutput) |
agent.replay(trace_file=) | str | Load from trace file |
agent.replay(events=) | List[Event] | Load from events |
Tracing
Configure JSONL trace export for replay sources.
Cost Tracking
Understand token metrics and pricing used in comparisons.