Skip to content

SPEC-012: Viewer

  • Status: Implemented
  • Milestone: v0.4.0
  • Owners: lead maintainer

1. Purpose

Let anyone watch a recorded run as a replay in a web browser, step by step, with each agent's moves, reasoning, chat, costs and the result, instead of reading JSONL by hand. Like every other reader, the viewer is driven only by the run log (plan section 2: "the log is the product").

By default the viewer is a page generator, not a server: agentplaykit view turns a log into one self-contained HTML file and opens it. Live mode (--live) adds a small local server so the same page can follow a run while it is being played (ADR-0007).

2. Terms

Keywords MUST, SHOULD and MAY follow RFC 2119. - Run page: the HTML file generated for one run log. - Summary page: the HTML file generated for a multi-run summary (<name>-summary.json). - Current step: the step the replay is showing; the page shows the run as it was after the events of that step. - View hint: an optional view object a world declares in describe(), telling the viewer how to draw its observations. - Live mode: the run page served by a local live server and updated as new log events are written, while the run is still going. - Live server: the temporary HTTP server that live mode starts on the user's own machine.

3. Requirements

Command

  • VWR-001 agentplaykit view <log.jsonl> MUST write one run page, by default next to the log as <log>.html (or at --out PATH), print its path, and open it in the default browser unless --no-open is given.
  • VWR-002 agentplaykit view <name>-summary.json MUST write a summary page and a run page for each listed log that exists, linking each row of the summary to its run page.
  • VWR-003 A path that is not a run log or a summary, or a log that is not valid JSON lines, MUST fail with the standard one-line error naming the file and the fix (CLI-007), exit code 2.

Source of truth

  • VWR-004 Pages MUST be built only from the run log and, when it exists, its <log>.eval.json (SPEC-010). The viewer MUST NOT import worlds or agents or re-run anything.
  • VWR-005 An incomplete log (no run_end) MUST still produce a page, with a visible "incomplete run" notice. Event types the viewer does not know MUST be shown generically, never dropped (forward compatibility, LOG-004).

Safety

  • VWR-006 Log content is untrusted (it includes model output): the page MUST insert every log value as text, never as HTML, and the embedded data MUST be escaped so that no log content can end the script element that carries it.
  • VWR-007 A page MUST work offline and make no network requests: everything (data, script, styles) is inline, and a Content-Security-Policy meta tag MUST forbid loading anything from the network.

Run page content

  • VWR-008 The header MUST show the world (name, version), seed, each agent (id, kind, model and provider as reported in the log, capabilities), the limits, the result (reason, winners, scores), steps, total cost, duration, and evaluation results when present.
  • VWR-009 Replay controls MUST include first, previous, next, last, a step slider, play/pause with a speed setting, and the keys Left, Right, Space, Home and End.
  • VWR-010 For the current step the page MUST show who acted, the observation they saw, the action, its reasoning, the step result (legal, or the rejection error), usage and running cost, and any provider_error, agent_error, warning, forfeit or limit_hit events of that step.
  • VWR-011 A conversation panel MUST show every message up to the current step with sender, recipients (or "everyone") and step, and every message_dropped with its reason.
  • VWR-012 A world MAY declare a view hint. v0.4 defines {"type": "grid", "key": K, "rows": R, "cols": C}: the viewer MUST draw observation[K] (a list of R×C cells, row by row) as a grid, and when an action is an integer index into it, highlight that cell. Without a hint, or with an unknown type, the viewer MUST show the observation as formatted, collapsible JSON. The tic-tac-toe world MUST declare a 3×3 grid on board.
  • VWR-013 For simultaneous worlds the page MUST show all actions of a round together, so a viewer sees that the agents chose at the same time.

Summary page content

  • VWR-014 The summary page MUST show the summary's scenario, runs and seeds, reasons, outcomes, errors (EVL-015), steps and cost spread, and evaluator pass rates, and one row per run with seed, reason, steps, cost, winners and evaluation results.

Quality

  • VWR-015 Output MUST be deterministic: the same input files give byte-identical pages (no generation timestamps, random ids or absolute paths of the machine).
  • VWR-016 Pages MUST be usable at phone width (no horizontal page scroll at 360 px) and follow the system light or dark color scheme.
  • VWR-017 The viewer MUST add no runtime dependencies: the page template and script ship inside the package and the generator uses the standard library.
  • VWR-018 A run page for a 10,000-event log SHOULD open and step smoothly in a current browser.

Live mode

  • VWR-019 agentplaykit play <scenario> --live MUST open the run page in live mode before the first turn and keep it updated while the run plays. agentplaykit view --live <log.jsonl> MUST follow a log that another process is writing.
  • VWR-020 Live mode MUST use the same run page as the static page, fed from the log file as it grows: the live server streams each new log event to the page (server-sent events), and the page SHOULD show it within one second of it being written. The log stays the only source; the runner is not changed and is never slowed down by a watching page.
  • VWR-021 While live, the page MUST follow the latest step and show which agent it is waiting for (a turn_start with no action yet, for example "waiting for x…"). Moving to an earlier step MUST pause following; a "Live" control MUST resume it.
  • VWR-022 When run_end arrives, the page MUST show the result and stop streaming, and play --live MUST also write the static run page of VWR-001. A page that loses its connection before run_end MUST say so and keep what it has shown.
  • VWR-023 With --runs N, live mode MUST follow each run in turn and, after the last one, show the summary page of VWR-014.
  • VWR-024 The live server MUST listen only on 127.0.0.1, on a free port chosen at start, and MUST require a random token of at least 128 bits in every request path. It MUST reject requests whose Host header is not 127.0.0.1:<port> or localhost:<port>, MUST answer only GET requests for the run page and its event stream, and MUST NOT send CORS headers.
  • VWR-025 The live server MUST stop when the run has ended and the page has received run_end (or 30 seconds after run_end if no page is connected), or when the user presses Ctrl+C. It MUST NOT keep running in the background.
  • VWR-026 In live mode the Content-Security-Policy MUST allow connections only to the live server's own origin; every rule of VWR-006 and VWR-007 still applies to the page.

Changes to other specs on acceptance

  • SPEC-001, new ENV-019: describe() MAY include view (VWR-012); it MUST be plain data.
  • SPEC-007, new CLI-013: the view command (VWR-001 to VWR-003) and the --live flag on play and view (VWR-019).
  • SPEC-003, new LOG-022: run_start.world MUST carry the world's view when it declares one. Additive; log_version stays 1. Logs from earlier versions have no view and use the JSON fallback.

4. Acceptance criteria

Requirement Test ID Notes
VWR-001..003 VWR-001..VWR-003 CLI tests with --no-open; pinned error messages
VWR-004..005 VWR-004, VWR-005 data embedded equals the log; truncated log; unknown event
VWR-006..007 VWR-006, VWR-007 </script> and HTML payloads in reasoning and chat; no http(s):// loads; CSP present
VWR-008..014 VWR-008..VWR-014 real browser tests (Playwright) on tic-tac-toe, rps, chat and summary pages; skipped where no browser is installed
VWR-015..018 VWR-015..VWR-018 byte-identical output; 360 px screenshot check; dependency scan; generated 10,000-event log
VWR-019..023 VWR-019..VWR-023 a test writes a log slowly while a client follows the stream; browser test follows a live run to its end
VWR-024..026 VWR-024..VWR-026 bound address, missing or wrong token, wrong Host, POST and CORS checks; server exits after run_end; CSP in live mode

5. Examples

agentplaykit play examples/tic-tac-toe-chat/scenario.yaml
agentplaykit view runs/tic-tac-toe-chat-7.jsonl          # writes and opens runs/tic-tac-toe-chat-7.html
agentplaykit play examples/treasure/scenario.yaml --runs 20
agentplaykit view runs/treasure-summary.json             # summary page linking to 20 run pages
agentplaykit play examples/tic-tac-toe-llm/scenario.yaml --live   # watch a model play as it happens
class TicTacToe(Environment):
    def describe(self):
        return {
            **super().describe(),
            "view": {"type": "grid", "key": "board", "rows": 3, "cols": 3},
        }

6. Open questions

  • More view types (for example a 2D position on a grid, as in the treasure world, or a scoreboard) after v0.4.
  • Comparing two runs side by side.
  • Watching from another device, or sharing a live run publicly (needs a hosted service; see the roadmap). Live mode is for the user's own machine only.

7. Change log

  • 2026-12-01: Initial draft.
  • 2026-12-01: Added live mode (VWR-019 to VWR-026) on review.
  • 2026-12-01: Accepted by the lead maintainer.
  • 2026-12-01: Implemented in v0.4.0.