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:
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
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’srun.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.
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. Thellm_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:
Extract ordered tool sequences
Count adjacent tool transitions
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, withparentRunId 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:
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).
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 inanalysis.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.