Skip to main content

Overview

The SessionLink struct represents metadata about an AI session that contributed to a commit. Each anchor can have multiple session links, tracking which AI tools were involved and their resource usage.
session_id
string
required
Unique identifier for the AI session.
agent
string
required
Name of the AI agent/tool (e.g., “cursor”, “claude”, “windsurf”).
model
string
The AI model used in this session (e.g., “claude-sonnet-4-20250514”, “gpt-4o”).
How this session was linked to the commit.See LinkType enum for possible values.
input_tokens
integer
Number of input tokens consumed by this session.
output_tokens
integer
Number of output tokens generated by this session.
cache_read_tokens
integer
Number of tokens read from cache.
cache_creation_tokens
integer
Number of tokens written to cache.
duration_secs
integer
Duration of the session in seconds.
tool_calls
integer
Number of tool/function calls made during the session.
files_touched
string[]
List of file paths that the AI agent modified or created.
is_subagent
boolean
default:false
Whether this session was spawned as a subagent of another session.

LinkType Enum

Describes how a session was linked to a commit.
ValueDescription
explicitFrom lifecycle hooks - we know for certain
inferredFrom time-window matching - best guess

Example JSON

{
  "session_id": "sess-1",
  "agent": "cursor",
  "model": "claude-sonnet-4-20250514",
  "link_type": "explicit",
  "input_tokens": 15420,
  "output_tokens": 3821,
  "cache_read_tokens": 48392,
  "cache_creation_tokens": 15420,
  "duration_secs": 145,
  "tool_calls": 23,
  "files_touched": [
    "src/main.rs",
    "src/lib.rs",
    "tests/integration_test.rs"
  ],
  "is_subagent": false
}
Optional fields like model, input_tokens, output_tokens, cache_read_tokens, cache_creation_tokens, duration_secs, tool_calls, and files_touched are omitted from JSON when null or not available.

Usage Context

  • Anchor - The parent commit structure that contains session links
  • FileChange - Per-file attribution that uses session data
  • Contributor - High-level contributor info derived from sessions

Build docs developers (and LLMs) love