Skip to content

ATIF export

glossogen export-atif writes a run's agents as ATIF (Agent Trajectory Interchange Format) trajectories, one JSON document per agent, or as one Inspect-format log for Docent. An ATIF trajectory holds the agent's prompts, responses, tool calls and token usage in a schema that other agent tooling reads.

glossogen export-atif veyru \
  --run-dir ./runs/veyru/1782395813 \
  --format atif \
  --out-dir ./atif

With --format atif, it logs one line for each trajectory that it writes, with the trajectory's step count. With --format inspect, it logs one line with the number of samples.

Flag Effect
--run-dir DIR the run to export (required)
--format FORMAT atif writes <agent_id>.json per agent; inspect writes one inspect_log.json (required)
--out-dir DIR where to write the files, created if missing (required)
--agent-id ID only this agent; omit for every agent
--round R exclusive cutoff, as for export-thread: keeps rounds 1..R-1

Trajectories are generated from the JSONL event log on each call. Nothing is written to the run directory.

Other ways to get ATIF

Surface Call
REST GET /api/g/{slug}/runs/{scenario}/{run_dir_name}/agents/{agent_id}/atif?round=R
MCP export_agent_atif with run_id, agent_id, cutoff_round
Raw zip the Export dialog's Raw run folders tab (ATIF by default), glossogen export --raw --trajectories atif, or "trajectory_format": "atif" on POST .../runs/export/raw; inspect in place of atif gives the Inspect log
Single-run zip always included in a run's zip download
Run page the Export Inspect log for Docent button downloads the run's Inspect log, which GET /api/g/{slug}/runs/{scenario}/{run_dir_name}/export/inspect also serves

REST and MCP return {"trajectories": [...]} for one agent. With atif, the raw zip writes every agent of every selected run under atif/ in that run's folder. With inspect, it writes one inspect_log.json at the zip root that holds every selected run. Exporting runs describes both.

How events map to steps

ATIF Comes from
session_id the run id, <scenario>/<run_dir_name>
agent the agent's agent_registered event: role and model, tool definitions; agent_id, provider, channels and the agent's model_settings (output cap, thinking level) under extra
system step the registered system prompt, then each context compaction summary
user step the prompt the runner opens each agent cycle with: the initial prompt on a fresh agent, the continue prompt after that
agent step each LLM response: text, reasoning_content, tool_calls
observation the tool results, matched to their call by tool_call_id
root extra scenario name, scenario_config, cutoff round, generation

Scenario injections, world events and the other agents' channel messages are not steps of their own. The model receives them as the results of its read_notifications and read_channel calls, and that is where a trajectory holds them. Round verdicts and the start and end of a postmortem phase are not steps either. An agent's own postmortem messages appear in its agent steps, as send_message calls. Read the event log or the CSV tables for the verdicts and the phases.

An agent step from the run above, with the tool result cut short:

{
  "step_id": 6,
  "timestamp": "2026-06-25T13:57:19.992503+00:00",
  "source": "agent",
  "message": "Let me check the comm link to see what happened, then engage the engineer in discussion.",
  "model_name": "claude-opus-4-7",
  "tool_calls": [
    {
      "tool_call_id": "toolu_01GwfhcK6SBU7CBmaENzoJG3",
      "function_name": "read_channel",
      "arguments": {"channel_id": "link", "last_n": 20}
    }
  ],
  "observation": {
    "results": [
      {
        "source_call_id": "toolu_01GwfhcK6SBU7CBmaENzoJG3",
        "content": "{\"current_round\": 1, \"messages\": [{\"round\": 1, \"sender\": \"Field Observer\", \"text\": \"Vri al"
      }
    ]
  },
  "extra": {"round_number": 1, "stop_reason": "tool_use"}
}

An agent step's timestamp is when its first tool call was invoked. Runs logged before 2026-10-15 stamped a response event when it was flushed, after its calls returned. For a slow tool, that is after events the agent had not yet seen. A response with no tool calls keeps its event's time, which in those older runs is its flush time. A runner-prompt step has no timestamp: the log records when a cycle's turns happened, not when its prompt was sent.

A cycle that raised before producing a response is recorded on the next agent step as extra.failed_cycles. Cycles that fail after the last response are recorded on the trajectory's root extra as failed_cycles_after_last_response.

Token usage is per cycle

The runner logs token usage once per agent cycle, on that cycle's last response. Only those steps carry metrics, and their llm_call_count is the number of responses in the cycle they close. A cycle can span many rounds: in the run above, the stabilization engineer's 109 steps hold one with metrics, closing a cycle of 107 responses:

{
  "llm_call_count": 107,
  "metrics": {
    "prompt_tokens": 34352270,
    "completion_tokens": 92070,
    "cached_tokens": 34164983,
    "cost_usd": 20.5544015,
    "extra": {"cache_creation_input_tokens": 186980, "reasoning_tokens": 0}
  }
}

prompt_tokens includes cached tokens, as ATIF defines it. reasoning_tokens is the share of completion_tokens spent thinking. It is 0 when the model did not think, when its provider reports no breakdown, and in runs logged before 2026-10-30, like this one. The export cannot tell these apart. cost_usd uses the platform's pricing table, and it is absent for a model that table does not price.

final_metrics sums the steps played in this run. A copied step keeps its metrics, but its source run already counts that spend, so the totals leave it out. When no played step carries metrics, the token and cost totals are absent rather than zero: the same run's field observer never closed a cycle, so its 176 steps carry no metrics and its final_metrics holds only total_steps.

Tool definitions

agent.tool_definitions lists each tool the agent was offered, with its name, description and JSON input_schema. agent.extra.tool_definitions_source says where they came from:

Source Meaning
recorded logged on the agent's agent_registered event when the run launched
reconstructed the run predates that, so the scenario was rebuilt from its recorded config and its tools listed at export time
names_only neither worked, for instance the scenario is not loaded in this process, so each entry has a name only

A reconstructed schema describes the code installed at export time, not the code the run used. Tool descriptions get edited, and some read knob values, which is why the rebuild uses the run's recorded config rather than a preset.

The definitions follow the order of tool_names on the agent's agent_registered event, for each of the three sources in the table above. That order depends on the glossogen version that logged the event:

  • v0.31.19 or later: the order in which the model received the tools;
  • v0.1.14 to v0.31.18: alphabetical order;
  • before v0.1.14: the base tools, then the tools that the agent's config listed. From 31 Mar 2026, the base tools came in an order that varied from one process to the next. A base tool that the config also listed appears once in the export, at its first position.

When a seat keeps its model across a resume, a fork-at-round or a replace-agent run, the export takes the seat's tools from its first agent_registered event. After a resume, that event can come from an earlier process of the same run. After a fork-at-round or a replace-agent run, it can come from the source run. The definitions then follow the order of the glossogen version that logged that event.

Swapped and replaced seats

A seat produces one trajectory per generation. A new generation starts at an in-run swap, at the first launch of a replace-agent or cross-run run's replaced seat, and at any re-registration under a different model. Files are named <agent_id>.gen1.json, <agent_id>.gen2.json and so on, with matching trajectory_ids. A resume under the same model continues the same trajectory, with a continue-prompt step where the relaunched runner picked the agent up.

A swapped-in generation's system step is the prompt the swap seeded its agent with: the swap's own when the scheduled event set one, otherwise the seat's registered prompt. The event records which, so a swap logged before that was recorded shows the registered prompt either way.

Copied context

A step with "is_copied_context": true is history the agent received rather than played in this run. Which steps carry it depends on how the run was made:

Run Copied steps
fork-at-round every step up to the boundary event its manifest names
replace-agent the same for the agents that kept their seats, and for the predecessor's generation of the replaced seat, which is all copied. The replaced seat's new generation opens with its seed: the predecessor's tool calls on the channels it was allowed to see
cross-run replace-agent the same, except the imported seat's seed is its history from the run it came from
in-run swap the swapped-in trajectory opens with its seed, built at the swap round
plain --resume none, since it continues the same run

A seed is rebuilt with the filter the run used when it launched, and its steps have no timestamp or metrics, since the history they come from records neither. In the replace-agent run veyru/1780729770, the replaced field observer has two files: gen1 holds the predecessor's 71 steps, all copied, and gen2 has 78 steps, 71 of them seed, followed by the continue prompt and the steps played after the boundary.

Checking a file against the spec

The spec's Pydantic models ship in the harbor package. This validates an exported file against them without adding that package to the project:

uv run --no-project --python 3.12 --prerelease=allow --with harbor python -c '
import json, sys
from harbor.models.trajectories import Trajectory
Trajectory.model_validate(json.load(open(sys.argv[1])))
print("valid")' ./atif/field_observer.json

The Inspect format

Inspect is an evaluation framework, and an Inspect log is its log file. glossogen export-atif --format inspect writes the ATIF trajectories as one Inspect log, inspect_log.json, which Docent imports with Add Data > Upload Inspect Log. Each trajectory becomes one sample, which is Inspect's record of one conversation. Each step becomes one or more chat messages:

ATIF step Inspect message
system step a system message
user step a user message
agent step an assistant message with the reasoning, the text and the tool calls
each observation result a tool message with the call's id and its function name

A sample's metadata holds the run id, the scenario, the agent id, the model, the provider, the generation and the scenario config. A system, user or assistant message's metadata holds its step id, whether the step is copied context, and the step's extra. A tool message's metadata holds only its step id. The log holds only the fields that Docent's importer reads, so Inspect's own tools do not open it.

A run's page in the web UI has an Export Inspect log for Docent button, which downloads the same log for that one run.

Next