Skip to content

Traces and replay

A trace is the full record of what a session actually did: every turn, every step, the prompt that went to the model, the completion that came back, and each tool call with its arguments and result. One append-only NDJSON file per session, on your disk, readable in any text editor.

Traces answer the questions logs cannot. Why did the agent pick that tool? What exactly was in the prompt when it went wrong? And — via replay — has anything changed underneath a session since it ran?

Tracing is on by default

The interactive entry points all record. run, tui, and serve boot the runtime with traceDefault: true, so a fresh install traces every session you drive by hand.

Two things do not trace by default:

  • The task command. task run, task tick and task create boot with traceDefault: false, so tasks they run are not recorded unless you opt in explicitly. Tasks the background scheduler runs inside tui or serve are traced like any other turn, because they run in that traced runtime.
  • The sidecar. Embedded hosts stay silent unless configured.

The config key is tri-state, which is what makes that split work:

{
"tracing": {
"trace": {
"enabled": null,
"maxBytesPerSession": 10485760
}
}
}
tracing.trace.enabledMeaning
null (default)Defer to the entry point. run / tui / serve trace; the task command and the sidecar do not.
trueAlways trace, whatever the entry point. This is how you record task runs started from the task command.
falseNever trace, including interactive sessions.

An explicit true or false always wins over the entry-point default.

maxBytesPerSession (default 10 MiB, 10485760 bytes) caps one session’s file. When a write would cross it, the oldest events are dropped: the file is rewritten to about half the cap, keeping the opening session_started line, and a trace_truncated marker records how many events and bytes were lost. Recording then continues. An event too large to fit on its own is skipped.

To change the cap, set the key directly:

Terminal window
atomic-agent config set tracing.trace.maxBytesPerSession 52428800

Where traces live

<stateDir>/traces/<sessionId>.ndjson

With the default state directory that is ~/.atomic-agent/traces/. Override the root with ATOMIC_AGENT_STATE_DIR.

Commands

Terminal window
atomic-agent trace list [--limit N]
atomic-agent trace show <sessionId> [--step N] [--raw]
atomic-agent trace export <sessionId> [--format ndjson|json]
atomic-agent trace replay <sessionId> [--step N]

Summarise the most recent trace files in the traces directory.

Terminal window
atomic-agent trace list --limit 20

Replay and prompt drift

replay does not re-run the agent. It answers a narrower and more useful question: would this session get the same prompt prefix today?

The stable prefix is the byte-identical head of every prompt — persona, tool catalog, skill index, capabilities. Replay reconstructs it from the current runtime and compares hashes with the ones the trace recorded. A mismatch means something underneath the session changed: a tool was added or removed, a skill was installed or disabled, or capabilities shifted.

The exit code is the part to script against:

Exit codeMeaning
0No drift. The current runtime reproduces the recorded prefix.
2Drift detected on at least one step.
1The command failed — no such session, unreadable file, bad arguments.
Terminal window
atomic-agent trace replay s-1234 || echo "prefix changed since this session ran"

Reading a trace directly

The file is NDJSON, so the usual tools work:

Terminal window
# Every tool call in a session
jq -c 'select(.type == "tool_invocation")' ~/.atomic-agent/traces/s-1234.ndjson
# Follow a live session
tail -f ~/.atomic-agent/traces/s-1234.ndjson

Turning tracing off

If you would rather record nothing, set the key to false:

Terminal window
atomic-agent config set tracing.trace.enabled false

which leaves this in config.json:

{
"tracing": {
"trace": {
"enabled": false
}
}
}

That covers every entry point, interactive ones included. Existing files stay on disk — delete <stateDir>/traces/ yourself if you want them gone.