Replay Export

Export a recorded run as self-contained HTML, JSON, Mermaid, or OpenTelemetry OTLP

praisonai replay export turns a recorded run into a file you can share, diff, diagram, or send to any OpenTelemetry backend.

python
from praisonaiagents import Agent
from praisonai.replay import record, export, load_events

with record() as rec:
    Agent(name="writer", instructions="Draft a short blog post").start("AI agents")

with open(f"{rec.run_id}.html", "w", encoding="utf-8") as f:
    f.write(export.to_html(load_events(rec.path)))
Diagram

Replay Export

🤖 Recorded run

🔒 Redact

🌐 HTML

📄 JSON

📊 Mermaid

📡 OTLP

Quick Start

  1. Export to HTML
    bash
    praisonai replay export run-1a2b3c4d5e6f

    Writes ./run-1a2b3c4d5e6f.html — open it in any browser, offline.

  2. Pick another format

    JSON

    bash
    praisonai replay export run-1a2b3c4d5e6f --format json -o run.json

    Mermaid

    bash
    praisonai replay export run-1a2b3c4d5e6f --format mermaid -o run.mmd

    OTLP

    bash
    praisonai replay export run-1a2b3c4d5e6f --format otel -o run.otlp.json

Formats

--formatPythonOutputUse it to
html (default)to_html(events, *, redact=True, graph=None, title=None)One self-contained HTML pageShare a run with anyone
jsonto_json(events, *, redact=True, indent=2){"schema": "praisonai.replay/1", "run_id", "graph", "events"}Diff runs or feed other tools
mermaidto_mermaid(events, *, redact=True)Mermaid sequenceDiagramPaste a diagram into a README or PR
otelto_otlp_json(events, *, redact=True, service_name="praisonai")OTLP/JSON ExportTraceServiceRequestLoad into Jaeger, Tempo, Honeycomb, etc.

Options

OptionDefaultDescription
RUN—Run id or path to a trace file
--format, -fhtmlhtml, json, mermaid, or otel
--output, -ostdout (html: ./<run>.html)Write to a file
--no-redactoffExport as recorded, without removing secrets/PII

Redaction

Every export is redacted by default — secrets are found by key name and secret/PII patterns are scrubbed from free text.

DataResult
Values under secret-looking keys (api_key, token, …)[REDACTED]
Numbers under those keys (prompt_tokens, max_tokens)Kept — they are counters
Free text (prompts, outputs)Secret and PII patterns scrubbed

Self-Contained HTML

The HTML file has zero external references — no CDN, nothing fetched when it opens — so it works air-gapped.

You haveThe page shows
praisonai[ui] installedThe full replay timeline, with its renderer inlined
No UI installedA built-in table timeline

OpenTelemetry (OTLP)

--format otel writes an OTLP/JSON trace using the OpenTelemetry GenAI semantic conventions, with no OpenTelemetry dependency.

bash
praisonai replay export run-1a2b3c4d5e6f --format otel -o run.otlp.json
curl -X POST http://localhost:4318/v1/traces \
  -H "Content-Type: application/json" \
  --data @run.otlp.json
SpanCovers
invoke_workflowThe whole run
invoke_agentOne agent
chatOne LLM call
execute_toolOne tool call
task / step / approvalWorkflow structure

Attributes include gen_ai.operation.name, gen_ai.agent.name, gen_ai.request.model, and gen_ai.usage.input_tokens. Ids are deterministic, so exporting the same run twice gives the same trace.


Python

python
import json
from praisonai.replay import export, load_events

events = load_events("run-1a2b3c4d5e6f")

open("run.html", "w", encoding="utf-8").write(export.to_html(events))
open("run.json", "w", encoding="utf-8").write(export.to_json(events))
open("run.mmd", "w", encoding="utf-8").write(export.to_mermaid(events))
open("run.otlp.json", "w", encoding="utf-8").write(json.dumps(export.to_otlp_json(events)))

Best Practices

Share HTML, not the server

Send the HTML file instead of exposing replay view on the network.

Use OTLP for long-term storage

Your existing tracing backend already handles retention and search — send it --format otel.


Related