Skip to content
TypeScript
2.5 KB
Raw Blame

Transcript schema

All parsing is defensive (zod, unknown fields allowed, malformed lines skipped). Common derivations:

  • subagentCount = tool_use with name ∈ {Task, Agent} (★ primary sort key)
  • skillFires = {Skill, SlashCommand}
  • mcpCalls = name.startsWith("mcp__")
  • tokens = sum of every assistant usage (input/output/cache_read/cache_creation), tracked separately

Claude Code (transcripts/claudeCode.ts) — two layouts

(A) inline sidechain (older / mock): isSidechain:true events live inside a subagent; the parentUuid chain attributes them to the spawning Task tool_use. Nested spawns nest via parent links.

(B) separate files (current cc, measured): subagent conversations are split into <session>/subagents/agent-<id>.jsonl + agent-<id>.meta.json; the main transcript has no sidechain. meta.toolUseId = the Task tool_use id that spawned this subagent → multi-level parent link. The cc runner copies subagents/ into the work dir as transcript_subagents/; the parser reads them as siblings and adds subagent tokens/tools to the totals (correcting what single-file parsing missed). subagentCount = number of agent files (all levels).

When layout B is present, inline Task tool_uses are treated only as spawns (counted as root tool calls) to avoid double-counting the same subagents.

Per-node detail extracted at every level: toolsUsed (frequency-compressed, e.g. Read×3), skillsUsed, steps (action order), logText.

Codex (transcripts/codex.ts)

codex exec --json thread events: thread.started (session), turn.started (numTurns), turn.completed.usage (tokens), item.completed (tools). Real codex has no in-process subagents (flat); only an explicit parent_idx (mock / legacy schema) is honored as nesting.

Multi-model agents (transcripts/defensive.ts)

opencode / openclaw / hermes outputs are only partially documented, so a single defensive parser recursively scans the output (JSONL events, a single JSON object, or plain text) for token fields (input_tokens/prompt_tokens/output_tokens/completion_tokens/cache*), tool/command events, a session id, and result text. In-process subagents are 0 unless an explicit task/subagent marker appears. Plain-text output (hermes -z) yields tokens=0 (honestly uncollected).

Synthetic transcripts (mock)

The mock runner emits the same shapes: cc → assistant + sidechain JSONL with Task tool_uses and a subagents/-free inline layout; codex → thread-event JSONL. This makes parsers fully testable offline.