PraisonAI Replay
Record a run, watch it live, export it, re-run it from any step — all local
PraisonAI Replay records everything your agents do to a local file, so you can watch the run, share it, or re-run it from any step — no cloud service, no account.
from praisonaiagents import Agent
from praisonai.replay import record
with record() as rec:
Agent(name="writer", instructions="Draft a short blog post").start("AI agents")
print(rec.run_id, rec.path)Quick Start
- Record from Python
Wrap any agent, team, or flow in
record():python from praisonaiagents import Agent from praisonai.replay import record with record(live=True) as rec: Agent(name="writer", instructions="Draft a short blog post").start("AI agents") print(f"Saved {rec.run_id} to {rec.path}") - Record every run of a YAML file
Add
save_replay: trueat the top ofagents.yaml:yaml save_replay: true roles: researcher: role: Researcher goal: Collect sources backstory: You find what matters. tasks: research: description: Research the topic expected_output: A summarybash praisonai agents.yaml - Record a one-off run
Pass
--saveinstead of editing the YAML:bash praisonai agents.yaml --save praisonai workflow run my-workflow.yaml --save praisonai recipe run my-recipe --save - Look at the run
bash praisonai replay list praisonai replay view run-1a2b3c4d5e6f
Choose Your Path
| You want to… | Use |
|---|---|
| Watch a run live in the browser | praisonai replay view agents.yaml |
Record every run of an agents.yaml | save_replay: true |
| Record one run from the CLI | praisonai agents.yaml --save |
| Full control from Python | with record(live=True): |
If your handlers set variables (StepResult(variables={...})), the recording captures them, and replay rerun restores them when it reuses earlier steps.
How It Works
| Event type | Status / data | Description |
|---|---|---|
session_start / session_end | — | Session boundaries |
workflow_start / workflow_end | status, graph | Team or flow run boundaries |
task_start / task_end | completed / failed / skipped | Team-level task |
step_start / step_end | completed / failed / skipped / cached, chosen route | AgentFlow step (sync, async, nested) |
agent_start / agent_end | — | Agent lifecycle |
agent_handoff | kind: handoff or delegate | Agent hand-off, or a hierarchical manager delegating a task |
message_added | — | Context message appended |
tool_call_start / tool_call_end | — | Tool execution |
llm_request / llm_response | tokens, cost, duration, model | LLM calls, including the LiteLLM path (Chat Completions + Responses API, sync and async) |
approval_requested / approval_decided | approved, reason | A person approves a tool call or task output; instant decisions stay silent |
context_snapshot | — | Full context state captured |
AGENT_END carries data["status"]: "completed", "failed" (the agent raised), or "cancelled". An unnamed agent (Agent(instructions=...)) uses node_id="agent:Agent", matching its id in to_graph(agent). Both sync (start/chat) and async (astart/achat) runs record LLM_REQUEST / LLM_RESPONSE.
Streamed turns (agent.start(..., stream=True)) record AGENT_START / AGENT_END like chat(), with agent_end status cancelled when the reader stops the stream early (PR #6087).
Every event is redacted before it is written, and every event carries the run id — including events from nested teams and flows.
| Field | When | What |
|---|---|---|
step_end.data.variables | A step’s handler returned StepResult(variables={...}) | The variables the step set, with secret-keyed values redacted. Replay Rerun uses them to restore those variables. |
Node ids on events
Events can carry a node_id that matches a node from Graph Export, such as task:write, step:draft or agent:Researcher.
from praisonai.replay import ContextTraceReader
for event in ContextTraceReader("my-session"):
if event.node_id:
print(event.node_id, event.event_type.value)Run id inheritance
Every event in a team or flow run carries the same run_id, and nested teams and flows inherit the outer run’s id automatically.
What’s fixed
- Concurrent
Parallel/Loopbranches now keep their ownbranch_idand sequence numbers. - Unknown event types are preserved when loading a trace instead of becoming
context_snapshot.
Node IDs & Reused Steps
Every step gets a stable node_id built from its name and position, so one handler reused at two positions shows up as two separate nodes.
from praisonaiagents import AgentFlow
def review(ctx):
return "ok"
def draft(ctx):
return "drafted"
flow = AgentFlow(steps=[review, draft, review])
flow.run("go")
# step_start / step_end node_ids:
# step:review step:draft step:review#2| Scenario | node_id behaviour |
|---|---|
| Same handler at two sequential positions | Each position gets its own id (step:review, step:review#2) |
Same handler in both then and else of If | Each branch gets its own id |
Same handler in two slots of a Loop body | Each slot gets its own id |
| Same handler across loop iterations | Same id on every pass — the #N suffix is positional, not a run counter |
Same pattern object (If, Loop, Parallel) at two positions | Each occurrence gets its own id (step:if, step:if#2) |
Repeat members | Keep one id per object across repeats |
CLI Commands
| Command | Purpose | |||
|---|---|---|---|---|
praisonai replay list | List recorded runs | |||
| `praisonai replay view [RUN \ | agents.yaml]` | Open the browser timeline — Replay View | ||
praisonai replay export RUN | HTML, JSON, Mermaid, or OTLP — Replay Export | |||
praisonai replay rerun RUN --from NODE | Re-run from a step — Replay Rerun | |||
| `praisonai replay flow RUN \ | agents.yaml` | Flow graph (`–format ascii\ | json\ | mermaid`) |
praisonai replay context RUN | Interactive step-through in the terminal | |||
praisonai replay show RUN | Dump events (non-interactive) | |||
praisonai replay delete RUN | Delete a trace | |||
praisonai replay cleanup | Remove old traces | |||
praisonai replay watch [agents.yaml] | Open a live page with a Run button (Embed Replay) |
Flow graph before a run
Pass a YAML file to replay flow to see its graph without any LLM call:
praisonai replay flow agents.yaml --format mermaidA team YAML’s static graph uses the same node ids its run will emit.
Terminal step-through
In replay context: Enter/n next, p previous, `g
go to event, q` quit.
praisonai replay show run-1a2b3c4d5e6f --agent researcher
praisonai replay show run-1a2b3c4d5e6f --type agent_start
praisonai replay show run-1a2b3c4d5e6f --jsonWhere Traces Live
Traces are JSONL files, one per run, found in this order:
| Priority | Location |
|---|---|
| 1 | $PRAISONAI_TRACES_DIR |
| 2 | $PRAISON_HOME/traces |
| 3 | ~/.praison/traces (default) |
export PRAISONAI_TRACES_DIR=./traces
praisonai agents.yaml --saveBest Practices
Use save_replay for YAML you iterate on
save_replay: true records every run, so you always have the last run to view or re-run.
Use live=True when watching
live=True writes every event as it happens, so praisonai replay view --live follows the run without delay.
Keep exports redacted
Recordings and exports are redacted by default — only use --no-redact for files that stay on your machine.
Run cleanup periodically
praisonai replay cleanup --max-age 7 keeps trace storage from growing unbounded.
Related
Watch a run live or replay it in the browser
Replay ExportSelf-contained HTML, JSON, Mermaid, or OTLP
Replay RerunRe-run a recorded run from any step
Record APIrecord() and save_replay: true in detail
Safe streaming fallback retries
EvaluationScore agent runs
Graph ExportDraw a team or flow; its node ids match event node_id