Agent Trajectory Interchange Format (ATIF)

July 17, 2026 · View on GitHub

VT Code implements the Agent Trajectory Interchange Format (ATIF) v1.4, a standardized JSON-based specification for logging complete agent interaction histories. ATIF trajectories are usable across debugging, visualization, Supervised Fine-Tuning (SFT), and Reinforcement Learning (RL) pipelines.

For the full specification, see the ATIF RFC.

Overview

When enabled, VT Code exports an atif-trajectory.json file alongside the existing .jsonl trajectory log at session end. The file captures the complete session: user messages, agent responses, tool executions, observations, and per-step/aggregate LLM metrics.

Configuration

Enable ATIF export in vtcode.toml:

[telemetry]
atif_enabled = true

The ATIF export is independent of trajectory_enabled — you can enable one without the other.

Output location: ~/.vtcode/sessions/atif-trajectory-<session-id>-<timestamp>.json

Schema

ATIF v1.4 defines these core types:

Root-Level Trajectory

FieldTypeStatusDescription
schema_versionStringRequired"ATIF-v1.4"
session_idStringRequiredUnique identifier for the agent run
agentObjectRequiredAgent configuration (name, version, model)
stepsArrayRequiredOrdered interaction steps
notesStringOptionalDeveloper notes
final_metricsObjectOptionalAggregate metrics for the full trajectory
extraObjectOptionalCustom root-level metadata

Step Object

FieldTypeStatusDescription
step_idIntegerRequiredOrdinal index (starting from 1)
timestampStringOptionalISO 8601 timestamp
sourceStringRequired"system", "user", or "agent"
model_nameStringOptionalLLM model used (agent steps only)
messageStringRequiredStep content
reasoning_contentStringOptionalAgent internal reasoning
tool_callsArrayOptionalTool/function invocations
observationObjectOptionalEnvironment feedback
metricsObjectOptionalPer-step LLM metrics
extraObjectOptionalCustom step-level metadata

Metrics

FieldTypeDescription
prompt_tokensIntegerTotal input tokens (cached + non-cached)
completion_tokensIntegerTokens generated by the model
cached_tokensIntegerSubset of prompt_tokens that were cache hits
cost_usdFloatEstimated cost for this step
logprobsArrayLog probabilities for RL training
completion_token_idsArrayToken IDs for RL training
prompt_token_idsArrayInput token IDs

Final Metrics

FieldTypeDescription
total_prompt_tokensIntegerSum of all prompt tokens
total_completion_tokensIntegerSum of all completion tokens
total_cached_tokensIntegerSum of all cached tokens
total_cost_usdFloatTotal estimated cost
total_stepsIntegerTotal number of steps

VT Code Event Mapping

VT Code converts its internal ThreadEvent stream to ATIF steps:

VT Code EventATIF SourceNotes
AgentMessageagentAgent text response
PlanagentPlanning workflow content
ReasoningagentModel reasoning/thinking
ToolInvocation + ToolOutputagentPaired into single step with tool_calls + observation
CommandExecutionagentShell command with output
McpToolCallagentMCP tool invocation
TurnCompletedsystemTurn boundary with usage metrics
TurnFailedsystemFailed turn with error message
FileChangesystemFile modification summary
WebSearchsystemSearch query and results
HarnesssystemContinuation/verification events
CompactBoundarysystemContext compaction event

Lifecycle events (TurnStarted, ItemStarted, ItemUpdated, PlanDelta) are skipped — only terminal states are exported.

Implementation

The ATIF implementation lives in crates/common/vtcode-exec-events/src/atif.rs with:

  • Schema types: Trajectory, AtifAgent, Step, AtifToolCall, Observation, ObservationResult, StepMetrics, FinalMetrics
  • AtifTrajectoryBuilder: Stateful collector that converts live ThreadEvent streams into ATIF trajectories. Implements EventEmitter for direct integration with the event pipeline.
  • Tool call pairing: ToolInvocation events are buffered until matching ToolOutput arrives, then merged into a single ATIF step with both tool_calls and observation.

Rust Usage

use vtcode_exec_events::atif::*;

// Create builder
let agent = AtifAgent::vtcode().with_model("gemini-2.5-flash");
let mut builder = AtifTrajectoryBuilder::new(agent);

// Feed ThreadEvents as they arrive
builder.process_event(&thread_event);

// Finalize
let trajectory = builder.finish(None);
let json = serde_json::to_string_pretty(&trajectory)?;

Example Output

{
  "schema_version": "ATIF-v1.4",
  "session_id": "session-abc123",
  "agent": {
    "name": "vtcode",
    "version": "0.96.15",
    "model_name": "gemini-2.5-flash"
  },
  "steps": [
    {
      "step_id": 1,
      "timestamp": "2025-04-05T10:30:00Z",
      "source": "agent",
      "message": "I'll read the file for you."
    },
    {
      "step_id": 2,
      "timestamp": "2025-04-05T10:30:02Z",
      "source": "agent",
      "tool_calls": [
        {
          "tool_call_id": "tc_0",
          "function_name": "exec_command",
          "arguments": { "cmd": "sed -n '1,80p' src/main.rs" }
        }
      ],
      "observation": {
        "results": [
          {
            "source_call_id": "tc_0",
            "content": "fn main() { println!(\"Hello\"); }"
          }
        ]
      }
    },
    {
      "step_id": 3,
      "timestamp": "2025-04-05T10:30:05Z",
      "source": "system",
      "message": "turn_completed",
      "metrics": {
        "prompt_tokens": 520,
        "completion_tokens": 80,
        "cached_tokens": 100
      }
    }
  ],
  "final_metrics": {
    "total_prompt_tokens": 520,
    "total_completion_tokens": 80,
    "total_cached_tokens": 100,
    "total_steps": 3
  }
}

Schema Versions

VersionChanges
ATIF-v1.4 (current)Added prompt_token_ids for prompt token analysis
ATIF-v1.3Added completion_token_ids for RL training
ATIF-v1.2Extended observation to support system steps
ATIF-v1.1Added extra field at root level
ATIF-v1.0Initial specification

Interoperability

VT Code's ATIF trajectories are compatible with:

  • Harbor evaluation framework and trajectory validator
  • Any tool consuming ATIF-compliant JSON (debugging, visualization, SFT/RL pipelines)
  • Other ATIF-producing agents: OpenHands, Mini-SWE-Agent, Gemini CLI, Claude Code, Codex