Skip to main content
This page describes Agent Journal 1.11.0 (1.x). It does not apply to 2.0, the current line on main, which has a different format; see Which Journal do I need?. These queries return empty or wrong results on 2.0 packages.
JsonFileStorage writes one events.jsonl file per run. DuckDB can read all runs for an experiment directly; no import step or fixed table schema is required. The examples below assume this path:
Pass union_by_name = true because different event types have different fields. Quote "@type" because the discriminator contains @. Header rows have @type = 'header', so event filters exclude them.

Count tool calls

A durationMs of -1 means the CLI did not measure the call (Grok, Codex and Junie since 1.11.0); the filter keeps it out of the average.

Tokens by run

Ask DuckDB to add the source filename, then join the run’s run.json for its track and parent. Four token fields carry distinct quantities: inputTokens excludes cache reads, cacheReadTokens and cacheCreationTokens are the cache traffic, and thinkingTokens (Codex reasoning, Claude extended thinking) is a subset of outputTokens, so do not add it on top.
A Codex root and its children are separate rows with separate counts; Codex’s root total does not include its children. A Claude Code main loop and its sub-agents are also separate rows, and the sum of their input and cache columns equals the call’s modelUsage when the CLI ran with --forward-subagent-text.

Cost by run, with availability

A cost of 0 is not evidence that a call was free. The llm_call metadata says whether the CLI reported a cost: costAvailable=false with costSource=unreported (Codex, Antigravity) means unknown, and costSource=included_in_parent (a Claude Code sub-agent) means the parent’s figure already contains it. Calls that report a cost (Claude Code’s main loop, Gemini, Grok, Junie) carry no costAvailable key, so treat a missing key as reported.
cost_usd is NULL where the CLI reported nothing. A total over several runs is only a total of the reported part; keep the count of unreported calls next to it:
On the synthetic Claude and Codex sub-agent journals from the sub-agent capture guide, this reports 9 calls, 8 without a cost of their own, and 0.50 USD reported: the Claude call’s cost, once.

Extract ordered tool sequences

Count adjacent tool transitions

Transition counts describe recorded behavior; they do not establish a quality threshold by themselves. Interpret them with task outcomes, run configuration, and enough repeated trials for the comparison you intend to make.

Sub-agent runs: count items, or total an execution tree

Since Agent Journal 1.11.0 a Claude Code or Codex sub-agent is a run directory of its own, with parentRunId set and the tag track=subagent in its run.json. Which runs to keep depends on the question. Counting experiment items. A query that treats every run directory as one item would count each sub-agent as an item, at a cost of 0 and without the item’s own configuration. For item counts, pass rates and per-item cost, exclude the sub-agent runs by the tag, and only by the tag:
Do not exclude on parentRunId alone: it is a general field, and an ordinary nested run that sets it is a legitimate item. Analysing sub-agents or whole executions. Keep the sub-agent runs. To list the children of each root with their reported status:
spawn_tool_use_id equals the id of the spawning tool_call event in the parent’s events.jsonl, which is the join between a parent’s step and the child’s run. For Codex children status_meaning is last_observed_turn: FINISHED means the last observed turn completed, not that a thread-terminal event was seen. To total an execution tree, walk parentRunId from each root with a recursive query. The cost rule: a tree’s cost is known when every call either reported a cost or is a Claude Code sub-agent whose cost is inside its parent’s; a Codex tree has no known cost. The tokens are partial when a spawn produced no record (subagentsWithoutTrack on the parent’s llm_call).
On the two synthetic journals this gives the Claude tree (5 runs, depth 2) 71 input and 3,700 cache-read tokens with a tree cost of 0.50 USD, and the Codex tree (4 runs, depth 1) 1,250 input and 830 cache-read tokens with no cost; both are marked partial because one spawn in each produced no record. The header’s producerVersion tells a file written by 1.11.0 from an earlier one; several Claude Code and Codex token values changed meaning at that boundary, so do not compare them across it without the table in the release notes.

Analyze derived events separately

Per-step cost attribution and step outcomes live in analysis.jsonl, not events.jsonl. Read that file with the same read_ndjson_auto(..., union_by_name = true) pattern. Use the run directory or stream header for run identity, and join an analysis stepId to the execution event’s stable id when the event has one.
DuckDB reads the JSONL files directly, but Agent Journal’s Java loadEvents and loadDerivedEvents methods currently load the requested file into memory. Use DuckDB or another streaming data tool for large cross-run analysis.