Skip to main content

Module trace

Module trace 

Source
Expand description

Agent Trace storage layer for VT Code.

This module provides file-based storage for Agent Trace records, supporting reading/writing traces to .vtcode/traces/ directory.

§Overview

Agent Trace is an open specification for tracking AI-generated code. See https://agent-trace.dev/ for the full specification.

§Usage

use vtcode_core::trace::{TraceStore, TraceGenerator, TraceContext};

// Create context for generating traces
let ctx = TraceContext::new("claude-opus-4", "anthropic")
    .with_workspace_path("/my/workspace")
    .with_session_id("session-123")
    .with_turn_number(1);

// Generate trace from diff tracker (after apply_patch)
if let Some(trace) = TraceGenerator::from_diff_tracker(&tracker, &ctx) {
    // Store the trace
    let store = TraceStore::for_workspace("/my/workspace");
    store.write_trace(&trace)?;
}

Structs§

Contributor
The contributor that produced a code contribution.
RelatedResource
A related resource linked to a conversation.
ToolInfo
Information about the tool that generated the trace.
TraceContext
Information needed to create a trace from file changes.
TraceConversation
A conversation that contributed code to a file.
TraceFile
A file with attributed conversation ranges.
TraceGenerator
Generate Agent Trace records from tracked file changes.
TraceIndex
Index file for quick lookup of traces by file path.
TraceMetadata
Additional metadata for trace records.
TraceRange
A range of lines with attribution information.
TraceRecord
A complete Agent Trace record tracking AI contributions to code.
TraceRecordBuilder
Builder for constructing trace records incrementally.
TraceStore
Trace storage for reading and writing Agent Trace records.
VcsInfo
Version control system information.
VtCodeMetadata
VT Code specific metadata in traces.

Enums§

ContributorType
Type of contributor for code attribution.
HashAlgorithm
Hash algorithm for content hashes.
VcsType
Supported version control system types.

Constants§

AGENT_TRACE_MIME_TYPE
MIME type for Agent Trace records.
AGENT_TRACE_VERSION
Current Agent Trace specification version.
TRACES_DIR
Default directory name for trace storage.

Functions§

compute_content_hash
Compute a content hash using the default algorithm (MurmurHash3).
compute_content_hash_with
Compute a content hash using the specified algorithm.
get_git_head_revision
Get the current git HEAD revision.
normalize_model_id
Convert a model string to models.dev convention format.