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:

  • Background task drains. The task command boots with traceDefault: false. Turns executed by the task runner are not recorded unless you opt in explicitly.
  • 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; task drains and the sidecar do not.
trueAlways trace, whatever the entry point. This is how you record background task runs.
falseNever trace, including interactive sessions.

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

maxBytesPerSession (default 10 MB) is a hard cap on one session’s file. Once a trace hits it, writes stop β€” the file does not rotate and the session keeps running untraced.

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>

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_call")' ~/.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:

{
"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.

Why local-first

Traces are one of the files that make the runtime inspectable, and one of the reasons the state directory is sensitive.

Approval gates

What stopped for approval during a turn, and why it is in the trace.

CLI Reference

Every command and flag, trace included.

Troubleshooting

Using a trace to work out why a turn went the way it did.