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.

python
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)
Diagram

PraisonAI Replay

🎬 Run

💾 Record

📺 View

📤 Export

🔁 Rerun

Quick Start

  1. 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}")
  2. Record every run of a YAML file

    Add save_replay: true at the top of agents.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 summary
    bash
    praisonai agents.yaml
  3. Record a one-off run

    Pass --save instead of editing the YAML:

    bash
    praisonai agents.yaml --save
    praisonai workflow run my-workflow.yaml --save
    praisonai recipe run my-recipe --save
  4. Look at the run
    bash
    praisonai replay list
    praisonai replay view run-1a2b3c4d5e6f

Choose Your Path

Diagram

Yes

No

Yes

No

Yes

No

🎯 What do you want?

Watch it live?

praisonai replay view agents.yaml

Every run of this YAML?

save_replay: true

Writing Python?

with record live=True

praisonai agents.yaml –save

You want to…Use
Watch a run live in the browserpraisonai replay view agents.yaml
Record every run of an agents.yamlsave_replay: true
Record one run from the CLIpraisonai agents.yaml --save
Full control from Pythonwith 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

Diagram
run-xxx.jsonlrecord()AgentYourun-xxx.jsonlrecord()AgentYouwith record()session_startstart()agent / task / tool / LLM eventsappend event (redacted)session_endrun_id + path
Event typeStatus / dataDescription
session_start / session_end—Session boundaries
workflow_start / workflow_endstatus, graphTeam or flow run boundaries
task_start / task_endcompleted / failed / skippedTeam-level task
step_start / step_endcompleted / failed / skipped / cached, chosen routeAgentFlow step (sync, async, nested)
agent_start / agent_end—Agent lifecycle
agent_handoffkind: handoff or delegateAgent 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_responsetokens, cost, duration, modelLLM calls, including the LiteLLM path (Chat Completions + Responses API, sync and async)
approval_requested / approval_decidedapproved, reasonA 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.

FieldWhenWhat
step_end.data.variablesA 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.

python
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 / Loop branches now keep their own branch_id and 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.

Diagram

review → step:review

draft → step:draft

review → step:review#2

python
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
Scenarionode_id behaviour
Same handler at two sequential positionsEach position gets its own id (step:review, step:review#2)
Same handler in both then and else of IfEach branch gets its own id
Same handler in two slots of a Loop bodyEach slot gets its own id
Same handler across loop iterationsSame id on every pass — the #N suffix is positional, not a run counter
Same pattern object (If, Loop, Parallel) at two positionsEach occurrence gets its own id (step:if, step:if#2)
Repeat membersKeep one id per object across repeats

CLI Commands

CommandPurpose
praisonai replay listList recorded runs
`praisonai replay view [RUN \agents.yaml]`Open the browser timeline — Replay View
praisonai replay export RUNHTML, JSON, Mermaid, or OTLP — Replay Export
praisonai replay rerun RUN --from NODERe-run from a step — Replay Rerun
`praisonai replay flow RUN \agents.yaml`Flow graph (`–format ascii\json\mermaid`)
praisonai replay context RUNInteractive step-through in the terminal
praisonai replay show RUNDump events (non-interactive)
praisonai replay delete RUNDelete a trace
praisonai replay cleanupRemove 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:

bash
praisonai replay flow agents.yaml --format mermaid

A 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.

bash
praisonai replay show run-1a2b3c4d5e6f --agent researcher
praisonai replay show run-1a2b3c4d5e6f --type agent_start
praisonai replay show run-1a2b3c4d5e6f --json

Where Traces Live

Traces are JSONL files, one per run, found in this order:

PriorityLocation
1$PRAISONAI_TRACES_DIR
2$PRAISON_HOME/traces
3~/.praison/traces (default)
bash
export PRAISONAI_TRACES_DIR=./traces
praisonai agents.yaml --save

Best 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