Skip to content

SPEC-003: Run log

  • Status: Implemented
  • Milestone: M1
  • Owners: lead maintainer

1. Purpose

The log is the product. Everything a viewer, evaluator or report needs MUST be in it; nothing is recomputed by rerunning. This spec fixes the format first because everything reads it. Machine-readable form: specs/schemas/runlog.schema.json.

2. Terms

  • Log: a UTF-8 JSONL file, one event per line. Event: one JSON object.
  • Log version: integer log_version, starting at 1.

3. Requirements

Format

  • LOG-001 A log MUST be UTF-8 JSON Lines: one JSON object per line, \n separators, no blank lines.
  • LOG-002 Every event MUST contain type (string), seq (integer, 0 for the first event, increasing by 1) and ts (UTC ISO-8601 timestamp).
  • LOG-003 The first event MUST be run_start and the last MUST be run_end. A log without run_end is incomplete and tools MUST say so.
  • LOG-004 Every log MUST validate against runlog.schema.json; unknown event types and fields MUST be ignored by readers (forward compatibility), but MUST NOT be emitted by this version.

Event types

  • LOG-005 run_start MUST contain: log_version, run_id, seed, world (name, version), agents (list of id, kind, model if known, capabilities), limits, scenario_sha256, and versions (agentplaykit, python, platform).
  • LOG-006 turn_start MUST contain step and to_act.
  • LOG-007 observation MUST contain agent, step and the observation data exactly as sent.
  • LOG-008 action MUST contain agent, step, the submitted action and optional reasoning.
  • LOG-009 step_result MUST contain agent, step, ok, error, done, rewards, info.
  • LOG-010 message MUST contain from, to (agent ID, list, or "*" for public), text and step (SPEC-008).
  • LOG-011 usage MUST contain agent, step, input_tokens, output_tokens, cost_usd, provider, model (as the provider reports) and cumulative total_cost_usd.
  • LOG-012 provider_error and agent_error MUST be separate event types, each with agent, step, message and, for provider errors, attempt and retryable.
  • LOG-013 forfeit MUST contain agent, reason; limit_hit MUST contain limit (steps, time, cost) and value.
  • LOG-019 message_dropped MUST contain from, to, text, step and reason (SPEC-008 MSG-011).
  • LOG-020 warning MUST contain message and MAY contain agent; it records conditions a reader should know about, such as an agent whose cost is unknown.
  • LOG-021 usage MAY also contain mode ("tool" or "text", how the action was obtained) and estimated (true when token counts were estimated). limit_hit.limit MAY also be "tokens".
  • LOG-022 run_start.world MUST carry the world's view when its describe() declares one (SPEC-012). Additive; readers MUST treat a missing view as "no hint".
  • LOG-014 run_end MUST contain reason (finished, step_limit, time_limit, budget_exceeded, forfeit, world_error, aborted), outcome (winners, scores, or null), steps, total_cost_usd and duration_s.

Integrity and safety

  • LOG-015 Only core writes the log, and it MUST flush each event so a crashed run keeps what happened.
  • LOG-016 Secrets MUST be redacted before writing (SEC-002). Redaction replaces the value with "[REDACTED]".
  • LOG-017 Given the same config, seed and recorded agent replies, the log MUST be byte-identical apart from ts, run_id, duration_s and versions; golden tests pin the format with these fields normalized.
  • LOG-023 Each run_start.agents[] entry MUST carry use (the scenario reference as written) when the run comes from a scenario, and name when the scenario gives one (SPEC-013 RPT-001). Additive; readers MUST treat both as optional.
  • LOG-024 run_end.outcome MAY carry extra world data such as checks and sandbox (SPEC-014). run_end MUST carry error (redacted, SEC-002) when the run ended world_error or aborted. Additive; readers MUST treat both as optional.
  • LOG-018 A schema change that breaks readers MUST bump log_version and add a migration note.

4. Acceptance criteria

Requirement Test ID Notes
LOG-001..004 LOG-001..LOG-004 every test-suite log validates against the schema
LOG-005..014 LOG-005..LOG-014 one sample per event type
LOG-015..016 LOG-015, LOG-016 crash mid-run; planted fake key never appears
LOG-017 LOG-017 golden log
LOG-018 LOG-018 schema carries log_version const

5. Examples

{"seq":0,"ts":"2026-11-30T10:00:00Z","type":"run_start","log_version":1,"run_id":"r1","seed":7,"world":{"name":"tic-tac-toe","version":"1"},"agents":[{"id":"x","kind":"scripted"},{"id":"o","kind":"scripted"}],"limits":{"max_steps":50},"scenario_sha256":"…","versions":{"agentplaykit":"0.1.0","python":"3.12.0","platform":"linux"}}
{"seq":1,"ts":"2026-11-30T10:00:00Z","type":"turn_start","step":0,"to_act":["x"]}

6. Open questions

  • Compress large logs (.jsonl.gz)? Deferred.
  • Store full raw provider responses? Default no (cost, secrets); optional later.

7. Change log

  • 2026-11-30: Initial draft.
  • 2026-11-30: Accepted by the lead maintainer.
  • 2026-11-30: Added LOG-019 (message_dropped event). Additive; log_version stays 1 before the first release.
  • 2026-11-30: Added LOG-020 (warning) and LOG-021 (usage mode/estimated, token limit). Additive.
  • 2026-11-30: Implemented in v0.1.0; every requirement has a test (PRO-004, PRO-011).
  • 2026-11-30: The reference world ox is renamed tic-tac-toe (ADR-0006); no alias.
  • 2026-12-01: Added LOG-022 (world.view), with SPEC-012. log_version stays 1.
  • 2026-12-01: Added LOG-023 (agent use and name in run_start), with SPEC-013. log_version stays 1.
  • 2026-12-01: Added LOG-024 (run_end.error, extra outcome data), with SPEC-014. log_version stays 1.