See More

{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://coding.sh/schema.json", "title": "coding.sh/trace v0", "description": "The coding.sh trace format: an AgentEvent (one normalized event) or a Session (the row ingest builds from a session's events). Validate one of them with #/$defs/AgentEvent or #/$defs/Session. Generated from packages/coding.sh/src/schema/index.ts by scripts/json-schema.ts.", "anyOf": [ { "$ref": "#/$defs/AgentEvent" }, { "$ref": "#/$defs/Session" } ], "$defs": { "AgentEvent": { "type": "object", "properties": { "id": { "description": "Deterministic: sha256(agent, sessionId, source line/offset). Re-ingest is idempotent.", "type": "string" }, "v": { "const": 0 }, "sessionId": { "type": "string" }, "turnId": { "type": "string" }, "parentId": { "description": "Parent event (subagent or nested tool).", "type": "string" }, "ts": { "description": "Milliseconds since epoch. For spans, the start time.", "type": "number" }, "durationMs": { "description": "Wall time of the thing this event describes (tool call, model call, turn), when known.", "type": "number" }, "traceId": { "description": "OpenTelemetry ids when the event came from (or is exported as) a span.", "type": "string" }, "spanId": { "type": "string" }, "parentSpanId": { "type": "string" }, "subagentId": { "description": "Subagent this event belongs to, when the agent runs subagents inside one session.", "type": "string" }, "source": { "description": "Capture path that produced the event, for cross-path dedupe: \"hook\" | \"transcript\" | \"otel-span\" | \"otel-log\" | \"wrapper\" | …", "type": "string" }, "agent": { "$ref": "#/$defs/AgentId" }, "agentVersion": { "type": "string" }, "model": { "type": "string" }, "kind": { "$ref": "#/$defs/EventKind" }, "cwd": { "description": "Working directory the agent ran in.", "type": "string" }, "repo": { "$ref": "#/$defs/RepoState" }, "payload": { "description": "Kind-specific, small (< 4 KB after normalization). Conventions:\n- user.message / assistant.message: { text }\n user.message also { from?: \"agent\" }: an agent sent the prompt, not the person (T3 Code's\n provider, MCP and server prompts, notifications, delegated results, other threads' messages).\n- llm.call: { provider?, requestModel?, responseModel?, ttftMs?, stopReason?,\n tokensPerSec?, ok, error? } — one model API call; durationMs on the event.\n durationMs, ttftMs and tokensPerSec are absent when the source does not show when\n the request went out (a transcript read from the middle of a response, lines written late)\n- subagent.start: { subagentId, type?, description?, prompt? }\n- subagent.end: { subagentId, ok?, result? (truncated), childSessionId? }\n- tool.start: { tool, toolUseId, input, server? (MCP server name) }\n- tool.end: { tool, toolUseId, ok, durationMs?, output? (truncated), cut? (the agent's\n harness cut the output before the model saw it: adapters/_shared/cut.ts OutputCut) }\n (both: wrapper? — a call that runs other tool calls, e.g. a Codex code-mode\n cell; its calls point at it by parentId and only they count in session stats)\n- file.change: { path, op: \"add\"|\"modify\"|\"delete\", additions?, deletions? }\n- test.result: { runner?, passed, failed, skipped? }\n- context.compact: { trigger: \"auto\"|\"manual\", tokensBefore? }\n- error: { message, source?, statusCode?, errorType?, errorClass?, rateLimitType?, retryAfterMs?, retryAttempt? }\n- session.end: { reason?, reportedUsage? (Claude Code's cost-state: costUsd, apiDurationMs, costUsdByModel) }\n- span: { name, attributes } — an OTel span with no better mapping\n- any kind: payload.reportedUsage = totals an agent span reports (not summed, avoids double counting)\n\nPairing keys (how consumers match the two halves of a span-like pair):\n- tool.start ↔ tool.end: same sessionId + payload.toolUseId.\n- subagent.start ↔ subagent.end: same sessionId + payload.subagentId (also on\n event.subagentId for events the subagent itself emits). The child's own\n session, when it has one, is named by childSessionId on either event and\n carries `session.start` payload { parentSessionId, subagentId, … }.\n- llm.call has no pair: one event per model call, durationMs on the event.\n\nUsage convention: `usage` holds the tokens/cost of THIS event only, so\nsumming `usage` over a session's events gives its total. An event that\nmerely repeats a running or final total (an agent span, a session summary)\nputs it in payload.reportedUsage instead, never in `usage`.\nAnything larger is moved to a blob and referenced from `blobs`.", "type": "object" }, "blobs": { "description": "Blob refs: full tool output, diffs, raw source payload (\"raw\" is always blobs[0] when kept).", "type": "array", "items": { "$ref": "#/$defs/BlobRef" } }, "usage": { "$ref": "#/$defs/Usage" }, "runId": { "description": "Run id when the event came from a coding.sh eval run (CODING_SH_RUN_ID).", "type": "string" }, "project": { "description": "Project the event belongs to (`coding.sh serve` sets it from the ingest\nkey). Unset means \"default\", which is all local data.", "type": "string" } }, "required": [ "id", "v", "sessionId", "ts", "agent", "kind", "payload" ], "additionalProperties": false }, "AgentId": { "type": "string", "examples": [ "claude-code", "codex", "opencode", "cursor", "gemini-cli", "antigravity", "copilot-cli", "amp", "pi", "droid", "goose", "aider", "devin", "t3code", "wrapper" ] }, "BlobRef": { "description": "sha256 hex of the uncompressed content.", "type": "string" }, "CacheBreakStats": { "description": "Session.stats.cacheBreaks: model calls whose prompt prefix was no longer cached,\nso tokens read from cache on the previous call were billed again at the write\n(or full input) rate.", "type": "object", "properties": { "count": { "type": "number" }, "lostTokens": { "description": "Prompt tokens that were cached before the break and paid for again.", "type": "number" }, "extraUsd": { "description": "USD the re-billing cost over cache-read prices; set only when every break's model has a price.", "type": "number" }, "byCause": { "type": "object", "properties": { "compaction": { "type": "object", "properties": { "count": { "type": "number" }, "lostTokens": { "type": "number" }, "extraUsd": { "type": "number" } }, "required": [ "count", "lostTokens" ], "additionalProperties": false }, "idle": { "type": "object", "properties": { "count": { "type": "number" }, "lostTokens": { "type": "number" }, "extraUsd": { "type": "number" } }, "required": [ "count", "lostTokens" ], "additionalProperties": false }, "model-switch": { "type": "object", "properties": { "count": { "type": "number" }, "lostTokens": { "type": "number" }, "extraUsd": { "type": "number" } }, "required": [ "count", "lostTokens" ], "additionalProperties": false }, "other": { "type": "object", "properties": { "count": { "type": "number" }, "lostTokens": { "type": "number" }, "extraUsd": { "type": "number" } }, "required": [ "count", "lostTokens" ], "additionalProperties": false } }, "additionalProperties": false }, "byIdle": { "description": "The idle breaks (byCause.idle) split by where the wait was. Unset when none was idle.", "type": "object", "properties": { "wait": { "type": "object", "properties": { "count": { "type": "number" }, "lostTokens": { "type": "number" }, "extraUsd": { "type": "number" } }, "required": [ "count", "lostTokens" ], "additionalProperties": false }, "subagent": { "type": "object", "properties": { "count": { "type": "number" }, "lostTokens": { "type": "number" }, "extraUsd": { "type": "number" } }, "required": [ "count", "lostTokens" ], "additionalProperties": false }, "away": { "type": "object", "properties": { "count": { "type": "number" }, "lostTokens": { "type": "number" }, "extraUsd": { "type": "number" } }, "required": [ "count", "lostTokens" ], "additionalProperties": false } }, "additionalProperties": false }, "unpriced": { "description": "Breaks on models with no price (extraUsd is then left out).", "type": "number" } }, "required": [ "count", "lostTokens", "byCause" ], "additionalProperties": false }, "CallTally": { "description": "Session.stats.edits and Session.stats.shells: tool calls of one kind that ended, and how many of them failed for real.", "type": "object", "properties": { "calls": { "type": "number" }, "failed": { "description": "Calls that failed for real (core/failures.ts): not a shell command whose exit 1 is an answer\n(no match, a probe, files that differ), not a call the person stopped. Absent when none.", "type": "number" } }, "required": [ "calls" ], "additionalProperties": false }, "CompactionRefetchStats": { "description": "Session.stats.compactionRefetches: read-only calls that fetched again a result a\ncompaction took out of the context, with nothing written to it in between.", "type": "object", "properties": { "calls": { "description": "Reads after a compaction that matched a read from before it; each dropped result counts once.", "type": "number" }, "tokens": { "description": "Estimated tokens those reads re-sent: output characters / 4.", "type": "number" }, "compactions": { "description": "Compactions that at least one of those reads followed.", "type": "number" } }, "required": [ "calls", "tokens", "compactions" ], "additionalProperties": false }, "CostByTokenType": { "description": "USD by token type: cache reads, cache writes (1-hour writes included), uncached input and output.", "type": "object", "properties": { "cacheRead": { "type": "number" }, "cacheWrite": { "type": "number" }, "input": { "type": "number" }, "output": { "type": "number" } }, "required": [ "cacheRead", "cacheWrite", "input", "output" ], "additionalProperties": false }, "DuplicateUsage": { "description": "Usage a session did not count because another model call already covered it (a nested span, a repeated response id).", "type": "object", "properties": { "calls": { "type": "number" }, "tokens": { "type": "number" }, "costUsd": { "type": "number" } }, "required": [ "calls", "tokens" ], "additionalProperties": false }, "DurableAttempt": { "description": "One attempt of a durable workflow step (DurableStats.steps[].attempts). Times are ms since epoch.", "type": "object", "properties": { "n": { "description": "Attempt number: as the engine reported it, else by start order.", "type": "number" }, "startedAt": { "type": "number" }, "endedAt": { "type": "number" }, "ok": { "type": "boolean" }, "error": { "type": "string" }, "replay": { "description": "The engine re-ran recorded history here; nothing under it is counted again.", "type": "boolean" }, "instance": { "description": "Process that ran it (service.instance.id, faas.instance, host:pid).", "type": "string" }, "version": { "type": "string" }, "spanId": { "description": "Span id, for linking to the timeline.", "type": "string" } }, "required": [ "n", "startedAt", "endedAt", "ok" ], "additionalProperties": false }, "DurableResume": { "description": "A point where the run continued after a break: a crash, a deploy, a worker restart or a durable wait.", "type": "object", "properties": { "at": { "type": "number" }, "reason": { "enum": [ "crash", "deploy", "restart", "wait" ] }, "step": { "description": "Step the run resumed at, and the span of the attempt that ran first.", "type": "string" }, "spanId": { "type": "string" }, "fromInstance": { "type": "string" }, "toInstance": { "type": "string" }, "fromVersion": { "type": "string" }, "toVersion": { "type": "string" }, "afterMs": { "description": "How long the run was stopped before it resumed.", "type": "number" } }, "required": [ "at", "reason" ], "additionalProperties": false }, "DurableStats": { "description": "One durable workflow run (Session.stats.durable), folded from the\npayload.durable tags the OTLP mapper puts on its spans (src/otel/durable.ts).", "type": "object", "properties": { "engine": { "type": "string" }, "runId": { "description": "The engine's run id.", "type": "string" }, "workflow": { "type": "string" }, "steps": { "type": "array", "items": { "$ref": "#/$defs/DurableStep" } }, "stepCount": { "description": "Steps in the run when `steps` keeps only some of them (retried, failed and unreported first).", "type": "number" }, "retries": { "description": "Step attempts beyond each step's first, reported or not.", "type": "number" }, "failedAttempts": { "type": "number" }, "replays": { "description": "Replayed spans seen (history re-run; not counted as new work).", "type": "number" }, "replayedCalls": { "description": "Model calls under replay spans, left out of usage.", "type": "number" }, "waits": { "type": "array", "items": { "$ref": "#/$defs/DurableWait" } }, "resumes": { "type": "array", "items": { "$ref": "#/$defs/DurableResume" } }, "instances": { "description": "Processes that worked on the run.", "type": "number" }, "wallMs": { "description": "First to last activity of the run.", "type": "number" }, "activeMs": { "description": "Time something ran: the union of step attempts, invocations and model/tool calls.", "type": "number" }, "waitMs": { "description": "Time inside explicit durable waits.", "type": "number" }, "idleMs": { "description": "wallMs − activeMs: waits, retry backoff, queueing and downtime.", "type": "number" } }, "required": [ "engine", "runId", "steps", "retries", "failedAttempts", "replays", "waits", "resumes", "instances", "wallMs", "activeMs", "waitMs", "idleMs" ], "additionalProperties": false }, "DurableStep": { "description": "A durable workflow step and its attempts, in start order.", "type": "object", "properties": { "name": { "type": "string" }, "id": { "description": "Stable step id (step.id, activity id) when the engine gives one.", "type": "string" }, "attempts": { "type": "array", "items": { "$ref": "#/$defs/DurableAttempt" } }, "unreported": { "description": "Attempts the run made but never reported (a gap in attempt numbers, or time before the first reported attempt).", "type": "number" }, "unreportedMs": { "description": "Time between scheduling and the first reported attempt, when an earlier attempt went unreported.", "type": "number" }, "unreportedRanMs": { "description": "Of unreportedMs, how long the lost attempt's process was still seen working (to its last export); the rest is lost.", "type": "number" }, "ok": { "type": "boolean" } }, "required": [ "name", "attempts", "ok" ], "additionalProperties": false }, "DurableWait": { "description": "A durable sleep or wait for an event (not busy time).", "type": "object", "properties": { "startedAt": { "type": "number" }, "endedAt": { "type": "number" }, "name": { "type": "string" } }, "required": [ "startedAt" ], "additionalProperties": false }, "EventKind": { "enum": [ "session.start", "session.end", "user.message", "assistant.message", "llm.call", "tool.start", "tool.end", "context.compact", "turn.end", "subagent.start", "subagent.end", "file.change", "test.result", "notification", "span", "error" ] }, "HookContextStats": { "description": "Session.stats.hookContext: text hooks added to the model's context\n(`notification` events with `payload.kind: \"hook.context\"`), counted and\nsized (characters / 4), in all and by source: `plugin:`, `plugin` (a\nplugin not installed where the session was parsed), `settings` (a hook from\na settings file) or `unknown` (the agent recorded no command).", "type": "object", "properties": { "count": { "type": "number" }, "tokens": { "type": "number" }, "bySource": { "type": "object", "additionalProperties": { "type": "object", "properties": { "count": { "type": "number" }, "tokens": { "type": "number" } }, "required": [ "count", "tokens" ], "additionalProperties": false } } }, "required": [ "count", "tokens", "bySource" ], "additionalProperties": false }, "LatencyStats": { "description": "Latency aggregates kept on Session.stats.latency. All milliseconds.", "type": "object", "properties": { "wallMs": { "type": "number" }, "llmCalls": { "type": "number" }, "llmMs": { "type": "number" }, "llmP50Ms": { "type": "number" }, "llmP95Ms": { "type": "number" }, "ttftP50Ms": { "type": "number" }, "toolMs": { "type": "number" }, "toolP95Ms": { "type": "number" }, "subagents": { "type": "number" } }, "additionalProperties": false }, "LlmErrors": { "description": "Session.stats.llmErrors: how many model calls failed, and why the first one did.", "type": "object", "properties": { "count": { "type": "number" }, "statusCode": { "description": "HTTP status of the first failed call, when it had one.", "type": "number" }, "error": { "description": "The first failed call's error message, up to 300 characters.", "type": "string" } }, "required": [ "count" ], "additionalProperties": false }, "MemoryUse": { "description": "Session.stats.memoryUse: one memory or instruction file a session used, or a\nskill its events name without a path.", "type": "object", "properties": { "use": { "description": "`loaded`: the agent put the file in its context. `read`: a tool read it, or the skill ran. `wrote`: a tool or a file change wrote it.", "enum": [ "loaded", "read", "wrote" ] }, "path": { "description": "The file, as an absolute path (`~/…` when the event wrote it so). Unset for a skill named without one.", "type": "string" }, "skill": { "description": "A skill named without a path: `harness audit` matches it to the SKILL.md files on disk.", "type": "string" }, "by": { "description": "With `skill`: `tool` when a Skill tool call named it, `harness` when the agent's record of loaded skills did.", "enum": [ "tool", "harness" ] }, "ts": { "description": "The last time, in ms since the epoch.", "type": "number" } }, "required": [ "use", "ts" ], "additionalProperties": false }, "ModelSwitch": { "description": "Session.stats.modelSwitch: the model changed mid-session (core/models.ts): a\nfallback the agent recorded (a switch and back included), any change inside a\nsubagent, or a main-thread hand-over from one model to another. The fields\nname the first switch; the counts cover them all.", "type": "object", "properties": { "from": { "type": "string" }, "to": { "type": "string" }, "at": { "description": "ts of the first call on `to`.", "type": "number" }, "trigger": { "description": "What came right before: a fallback the agent recorded, `from`'s last call was refused\nor failed, or a /model command. Unset when unknown.", "enum": [ "fallback", "refusal", "error", "command" ] }, "reason": { "description": "For a recorded fallback: why, as the agent said (`overloaded`, `refusal`, `model_not_found`, …).", "type": "string" }, "subagent": { "description": "The first switch was inside a subagent (a subagent's own session, or one in this session).", "type": "boolean" }, "count": { "description": "Switches in the session, when more than one. A return to the model a switch left is not one.", "type": "number" }, "switchedCalls": { "description": "Model calls that ran on a model a switch moved to (until the scope went back).", "type": "number" }, "extraUsd": { "description": "What those calls cost at their model's list prices minus what the same tokens cost at the\nlist prices of the model the switch left (standard rates); negative when the other model is\ncheaper. Unset when either model has no price.", "type": "number" } }, "required": [ "from", "to", "at" ], "additionalProperties": false }, "PullRequestRef": { "description": "One entry of Session.stats.prs: a pull request the session touched, from what its own tool calls\nprinted or named (core/sessions.ts foldPrs; no network call).\n- `opened`: `gh pr create` printed its URL, or `gh pr reopen` ran.\n- `merged`: `gh pr merge` ran (not an `--auto` merge still waiting), or gh printed that it merged it.\n- `closed`: `gh pr close` ran.\n- `linked`: the session named it without changing it: a host tool linked or watched it (T3 Code's\n `link_pull_request`), a `git push` or a `gh pr` command printed its URL. It never replaces another state.", "type": "object", "properties": { "url": { "description": "The PR's web URL. Unset when the session named it by number and never saw its repo.", "type": "string" }, "repo": { "description": "`owner/name`, from the URL, `--repo`, or a repo the session's push or gh output named. Unset when none did.", "type": "string" }, "number": { "type": "number" }, "state": { "enum": [ "opened", "merged", "closed", "linked" ] }, "at": { "description": "When the session saw that state (ms since the epoch): the last one it saw wins.", "type": "number" }, "own": { "description": "Set when the session pushed to the PR (the push printed its URL) or linked it to its own thread\n(T3 Code's `link_pull_request`): the PR carries its work, so its merge settles the work's review.\nAbsent otherwise.", "const": true } }, "required": [ "number", "state", "at" ], "additionalProperties": false }, "RepoState": { "type": "object", "properties": { "root": { "description": "Absolute path of the repository root.", "type": "string" }, "head": { "description": "HEAD commit at the time of the event (\"\" for an unborn branch).", "type": "string" }, "snapshot": { "description": "Snapshot commit in the shadow repo capturing the full working tree.", "type": "string" }, "partial": { "description": "True when the snapshot fell back to tracked-files-only.", "type": "boolean" }, "branch": { "type": "string" }, "main": { "description": "Root of the repo's main worktree, when `root` is a linked worktree (`git worktree add`,\nor a worktree an agent made for a task). Absent in a main checkout. Repo filters and\ngroups count a worktree's sessions under this repo; `root` stays where the agent ran.", "type": "string" } }, "required": [ "root", "head" ], "additionalProperties": false }, "RetrievalStats": { "description": "Session.stats.retrieval: how a session found what it worked on. A read shows a file's content\n(Read, `cat`, `sed`, `head`, Get-Content, `git show :`); a search looks for or lists\nfiles (Grep, Glob, `grep`, `rg`, `find`, `ls`, Select-String, Get-ChildItem). A shell line that\nreads and searches counts as both.", "type": "object", "properties": { "reads": { "description": "Tool calls that read a file, failed ones included.", "type": "number" }, "filesRead": { "description": "Distinct files those reads named. A read that failed, or whose path is a variable or a glob, names none.", "type": "number" }, "editedAfterRead": { "description": "Of the files read, those the session edited after reading them (an edit tool or a shell write).", "type": "number" }, "searches": { "description": "Tool calls that searched for or listed files.", "type": "number" }, "emptySearches": { "description": "Searches that found nothing: no output, \"No matches found\" or \"No files found\", or exit status 1 with nothing printed. Unset when none.", "type": "number" }, "web": { "description": "Web searches and page fetches (WebSearch, WebFetch). Unset when none.", "type": "number" }, "beforeFirstEdit": { "description": "Tool calls that read or searched before the session's first edit (a call that does both counts once). Unset when the session edited nothing.", "type": "number" } }, "required": [ "reads", "filesRead", "editedAfterRead", "searches" ], "additionalProperties": false }, "Session": { "type": "object", "properties": { "id": { "type": "string" }, "agent": { "description": "The agent that ran, also when a host app drove it (a T3 Code thread that ran Claude Code is \"claude-code\").", "$ref": "#/$defs/AgentId" }, "host": { "description": "The host app that drove the agent (\"t3code\" when T3 Code ran it). Absent\nwhen no host drove the session, and for a host thread that never started\nan agent (its agent is the host's id).", "type": "string" }, "provider": { "description": "The agent a host app ran: the same as `agent` when `host` is set (\"codex\",\n\"claude-code\", or the host's driver name). Kept for older readers.", "type": "string" }, "agentVersion": { "type": "string" }, "model": { "type": "string" }, "cwd": { "type": "string" }, "repo": { "$ref": "#/$defs/RepoState" }, "title": { "description": "First user prompt, truncated to 280 chars, for lists.", "type": "string" }, "startedAt": { "type": "number" }, "endedAt": { "description": "ts of the session.end event. Sessions keyed by conversation rather than by\na process (OTel: every event has an \"otel-*\" source, the session id is a\nconversation id such as gen_ai.conversation.id rather than one of its\ntraceIds, and no session.end ever arrives) use the end of the last event\nseen (ts + durationMs for events stamped at their start, ts for *.end\nevents), so the value moves forward as more turns arrive. Log-keyed OTel\nsessions (no traceId at all) and sessions known only from a backfilled\ntranscript do the same. Trace-keyed OTel sessions end with their root\nspan. A session with a tool call still open and no session.end (or only\na transcript's quiet marker) did not finish: it has none. Unset = still\nrunning/unknown.", "type": "number" }, "stats": { "description": "Aggregates maintained at ingest.", "type": "object", "properties": { "events": { "type": "number" }, "turns": { "type": "number" }, "toolCalls": { "type": "number" }, "toolErrors": { "description": "Tool calls that failed for real (core/failures.ts). A shell command whose\nexit 1 is an answer (`rg` found nothing, `test -f` was false, `diff` saw a\ndifference) and a call the user stopped are counted apart, below.", "type": "number" }, "benignToolErrors": { "description": "Failed tool calls whose exit 1 is an answer: no match, a probe, files that differ. Absent when none.", "type": "number" }, "interruptedToolCalls": { "description": "Tool calls the user or the harness stopped (Ctrl-C, a rejected prompt). Absent when none.", "type": "number" }, "filesChanged": { "type": "number" }, "testsPassed": { "type": "number" }, "testsFailed": { "type": "number" }, "usage": { "$ref": "#/$defs/Usage" }, "duplicateUsage": { "description": "Model-call usage left out of `usage` because an enclosing call or an earlier copy of the same response already counted it.", "$ref": "#/$defs/DuplicateUsage" }, "latency": { "$ref": "#/$defs/LatencyStats" }, "llmErrors": { "description": "Failed model calls: llm.call with `ok: false` or an HTTP status of 400 or more. Unset when none failed.", "$ref": "#/$defs/LlmErrors" }, "models": { "description": "Model calls by model, when more than one model made them (core/models.ts).", "type": "object", "additionalProperties": { "type": "number" } }, "modelSwitch": { "description": "Model switches mid-session (the first one, how many, what the switched calls cost extra); it also tags the session `model:switch`.", "$ref": "#/$defs/ModelSwitch" }, "durable": { "description": "Set when the session is one run of a durable workflow engine (Vercel Workflow, Temporal, …).", "$ref": "#/$defs/DurableStats" }, "derails": { "description": "Where the session went off the rails (looping, failure-streak, churn, no-progress, stalled, context-thrash), earliest first.", "type": "array", "items": { "$ref": "#/$defs/SessionDerail" } }, "phases": { "description": "The session's phases (core/outline.ts) when it has more than one: start, resumes, compactions, long idle gaps.", "type": "array", "items": { "$ref": "#/$defs/SessionPhase" } }, "waste": { "description": "Read-only calls repeated with an unchanged result (core/waste.ts). Unset when none repeated.", "$ref": "#/$defs/WasteStats" }, "compactionRefetches": { "description": "Read-only calls that fetched again what a compaction dropped (core/waste.ts). Unset when none did.", "$ref": "#/$defs/CompactionRefetchStats" }, "retrieval": { "description": "Reads, searches and web calls, and the files read and then edited (core/retrieval.ts). Unset when the session read, searched and fetched nothing.", "$ref": "#/$defs/RetrievalStats" }, "cacheBreaks": { "description": "Model calls that found the prompt cache gone and paid for the prompt again (core/cache-breaks.ts). Unset when none did.", "$ref": "#/$defs/CacheBreakStats" }, "launch": { "description": "How the agent was launched: `headless` (`claude -p`, an Agent SDK, `codex exec`) or\n`interactive` (a terminal UI, an IDE, or a T3 Code thread a person started). A host app's\nlaunch wins over the agent's own start. Unset when neither says.", "enum": [ "headless", "interactive" ] }, "inheritedTokens": { "description": "A fork subagent (Claude Code's `subagent_type: \"fork\"`): tokens of the parent's context it\nstarted with (the prompt and output of the parent's call that started it). Its own calls\nread that context from the prompt cache and count in `usage`; the parent's calls count only\nin the parent. Unset for other sessions.", "type": "number" }, "hookContext": { "description": "Text hooks added to the model's context, by source (`plugin:`, `settings`, …). Unset when no hook added any.", "$ref": "#/$defs/HookContextStats" }, "weightEdits": { "description": "Weight edits and checkpoints the session recorded; they also tag the session `weights:edited` and `weights:checkpoint`. Unset when it recorded neither.", "$ref": "#/$defs/WeightEditStats" }, "memoryUse": { "description": "Memory and instruction files (AGENTS.md, rules, skills, Claude auto-memory) the\nsession's events name, in the order first seen: what `harness audit` counts\n(core/memory-use.ts). Unset when its events name none.", "type": "array", "items": { "$ref": "#/$defs/MemoryUse" } }, "redactions": { "description": "Values redaction replaced before storage, by rule kind (`anthropic-key`, `password`, …): counts, never\nthe values. A vendor token kind also tags the session `secret:exposed`. Unset when nothing was redacted.", "type": "object", "additionalProperties": { "type": "number" } }, "unapprovedActions": { "description": "Destructive or paid commands the agent ran without a user turn approving them (core/unapproved.ts); it also flags the session `unapproved-action`. Unset when none.", "$ref": "#/$defs/UnapprovedActions" }, "endInferred": { "description": "True when Session.endedAt is the last activity seen rather than a session.end (a session known\nonly from its transcript, a conversation-keyed OTel or SDK session): it may still be running.\nUnset when the end is real or there is no end.", "const": true }, "waiting": { "description": "What the session waits on from the user (a permission prompt, a question, a plan, or the next\nprompt), as of its last event (core/waiting.ts). Unset when nothing waits.", "$ref": "#/$defs/Waiting" }, "waits": { "description": "How often and how long the session waited on the person (permission prompts, questions, plans,\nhost requests, and turns in a session launched interactively), and how often the person\nsteered a running turn (core/wait-stats.ts). Unset when it never waited and nobody steered.", "$ref": "#/$defs/WaitStats" }, "prs": { "description": "Pull requests the session opened, merged, closed or linked, oldest first: every one it opened, merged or closed, and the 20 latest it only linked. Unset when it touched none.", "type": "array", "items": { "$ref": "#/$defs/PullRequestRef" } }, "turnsByModel": { "description": "Turns by the model that ran them: how many, how the person's next prompt pushed back, how many\nthe person stopped, and how long they ran (core/turn-stats.ts). Only in a session launched\ninteractively that is not a subagent; the key \"\" holds the turns of a session with no model.\nUnset in other sessions, and when the person sent no prompt.", "type": "object", "additionalProperties": { "$ref": "#/$defs/TurnTally" } }, "edits": { "description": "File-edit calls (write, edit, patch, delete) on every thread, and how many failed for real (core/turn-stats.ts). Unset when none ended.", "$ref": "#/$defs/CallTally" }, "shells": { "description": "Shell calls on every thread, and how many failed for real (core/turn-stats.ts). Unset when none ended.", "$ref": "#/$defs/CallTally" }, "foldError": { "description": "Why coding.sh could not fold this session's stored events into its stats (a coding.sh bug, not\nthe agent's): the row then holds only what the events say directly (agent, start, end, cwd,\nevent count), and the session is tagged `fold:error`. `coding.sh ingest` folds it again. Unset\nwhen the fold worked.", "type": "string" } }, "required": [ "events", "turns", "toolCalls", "toolErrors", "filesChanged" ], "additionalProperties": false }, "flags": { "description": "Detected failure patterns, e.g. \"premature-completion\".", "type": "array", "items": { "type": "string" } }, "runId": { "type": "string" }, "endSnapshot": { "description": "Snapshot at session end, for diffs.", "type": "string" }, "parent": { "description": "Set when this session is a subagent of another session (own transcript / child trace).\nIngest links a child from either its `session.start` payload\n`{ parentSessionId, parentEventId?, subagentId?, subagentType? }` or the parent's\n`subagent.start|end` payload `childSessionId`. Adapters should prefer the former.\nA workflow agent's link also names its run, from the same payload's `workflowId`,\n`workflowName`, `workflowPhase` and `workflowLabel`: `coding.sh work` makes one item per run.", "type": "object", "properties": { "sessionId": { "type": "string" }, "eventId": { "type": "string" }, "subagentId": { "type": "string" }, "type": { "type": "string" }, "workflowId": { "description": "The workflow run that started this session: one id per run of a workflow script.", "type": "string" }, "workflowName": { "description": "The workflow's name (\"round 7\").", "type": "string" }, "phase": { "description": "The phase of the run the agent belongs to (\"research\", \"build\").", "type": "string" }, "label": { "description": "The agent's label inside its phase.", "type": "string" } }, "required": [ "sessionId" ], "additionalProperties": false }, "traceIds": { "description": "OTel trace ids that contributed to this session (first seen first, capped at 256). Filled by buildSession from events' traceId.", "type": "array", "items": { "type": "string" } }, "project": { "description": "Project, copied from the events by buildSession. Unset means \"default\".", "type": "string" }, "parseVersion": { "description": "Adapter.parseVersion of the code that produced this session's rows, set when\ningest first creates the session and kept as later events arrive (so it is\nthe oldest parse in the session). Older than the adapter's: re-parsed from\nits transcript or spool (core/reparse.ts). Unset: not produced by an\nadapter's ingest (OTel, SDK batches), never re-parsed automatically.\nA store keeps the stored value when an upsert leaves it unset.", "type": "number" } }, "required": [ "id", "agent", "startedAt", "stats", "flags" ], "additionalProperties": false }, "SessionDerail": { "description": "One derail episode on Session.stats.derails: where it started and what happened.", "type": "object", "properties": { "flag": { "description": "\"looping\", \"failure-streak\", \"churn\", \"no-progress\", \"stalled\" or \"context-thrash\".", "type": "string" }, "ts": { "description": "Onset time (ms epoch) and event.", "type": "number" }, "eventId": { "type": "string" }, "index": { "description": "Index of the onset event in the session's events sorted by time.", "type": "number" }, "endTs": { "description": "When it was last seen.", "type": "number" }, "detail": { "type": "string" } }, "required": [ "flag", "ts", "eventId", "index", "endTs", "detail" ], "additionalProperties": false }, "SessionPhase": { "description": "One phase of a long session on Session.stats.phases (core/outline.ts).", "type": "object", "properties": { "n": { "description": "1-based.", "type": "number" }, "kind": { "enum": [ "start", "resume", "compaction", "idle" ] }, "trigger": { "description": "compaction: \"auto\" or \"manual\".", "type": "string" }, "gapMs": { "description": "idle/resume: the gap before it, ms.", "type": "number" }, "startTs": { "type": "number" }, "endTs": { "description": "ts of its last event.", "type": "number" }, "from": { "description": "Index range [from, to) into the time-sorted events, and the first event's id (a deep link).", "type": "number" }, "to": { "type": "number" }, "eventId": { "type": "string" }, "events": { "type": "number" }, "prompts": { "type": "number" }, "toolCalls": { "type": "number" }, "toolErrors": { "type": "number" }, "filesChanged": { "type": "number" }, "tests": { "description": "Last test result in the phase.", "type": "object", "properties": { "passed": { "type": "number" }, "failed": { "type": "number" } }, "required": [ "passed", "failed" ], "additionalProperties": false }, "tokens": { "type": "number" }, "costUsd": { "type": "number" }, "title": { "description": "First prompt in the phase, up to 120 characters.", "type": "string" } }, "required": [ "n", "kind", "startTs", "endTs", "from", "to", "eventId", "events", "prompts", "toolCalls", "toolErrors", "filesChanged", "tokens" ], "additionalProperties": false }, "TurnTally": { "description": "One model's turns in Session.stats.turnsByModel (core/turn-stats.ts). A turn is a prompt the\nperson sent and the agent's work until their next prompt.", "type": "object", "properties": { "turns": { "description": "Turns the model ran: it made most of the turn's main-thread model calls, or the turn made none and it is the session's model.", "type": "number" }, "replied": { "description": "Turns the person answered with a prompt that has text: what `pushback` counts out of. Absent when none.", "type": "number" }, "pushback": { "description": "Those prompts that name one of the four kinds of pushback on the turn before them, by kind. Other corrections are not counted. Absent when none did.", "type": "object", "properties": { "intent": { "type": "number" }, "undo": { "type": "number" }, "redo": { "type": "number" }, "broken": { "type": "number" } }, "additionalProperties": false }, "cancelled": { "description": "Turns the person stopped, of the turns whose capture records it. Absent when none.", "type": "number" }, "cancelNotRecorded": { "description": "Turns whose capture does not record a turn the person stopped (docs/ADAPTERS.md): an agent that\nrecords none, a T3 Code thread built from T3 Code's own store, or a Claude Code turn whose prompt\nhas no text (metadata mode), came from its OpenTelemetry export, or came from hooks that have not\nseen the turn end. Absent when none.", "type": "number" }, "durationsMs": { "description": "How long turns ran (ms), from the prompt to the end of the turn's last work, for up to 500 turns. Absent when none did any work.", "type": "array", "items": { "type": "number" } } }, "required": [ "turns" ], "additionalProperties": false }, "UnapprovedActions": { "description": "Session.stats.unapprovedActions: destructive or paid commands the agent ran when the user's last turn had not\napproved them (it did not ask for the action, pre-approve it or say yes to the agent's question).", "type": "object", "properties": { "count": { "type": "number" }, "byKind": { "type": "object", "properties": { "rm-rf": { "type": "number" }, "git-reset-hard": { "type": "number" }, "git-clean": { "type": "number" }, "git-discard": { "type": "number" }, "git-push-force": { "type": "number" }, "db-drop": { "type": "number" }, "forced-subcommand": { "type": "number" }, "data-dir": { "type": "number" }, "paid": { "type": "number" } }, "additionalProperties": false }, "first": { "description": "The first one: its kind, its command (up to 200 characters), when, and whether a tool call had failed since the user's last turn.", "type": "object", "properties": { "kind": { "$ref": "#/$defs/UnapprovedKind" }, "command": { "type": "string" }, "at": { "type": "number" }, "afterError": { "type": "boolean" } }, "required": [ "kind", "command", "at" ], "additionalProperties": false } }, "required": [ "count", "byKind", "first" ], "additionalProperties": false }, "UnapprovedKind": { "description": "What an unapproved action did (core/unapproved.ts): `rm -rf` outside temp and build dirs; `git reset --hard`,\n`git clean -f`, or `git checkout|restore .` with no commit or stash first; `git push --force`; dropping or\ntruncating a database; a tool's own `--yes`/`--force` on a repair, reinit, migrate, delete or purge\nsubcommand; deleting, moving or overwriting a data file or dir; a paid cloud or API batch job.", "enum": [ "rm-rf", "git-reset-hard", "git-clean", "git-discard", "git-push-force", "db-drop", "forced-subcommand", "data-dir", "paid" ] }, "Usage": { "type": "object", "properties": { "inputTokens": { "type": "number" }, "outputTokens": { "type": "number" }, "cacheReadTokens": { "type": "number" }, "cacheWriteTokens": { "type": "number" }, "costUsd": { "description": "Reported (agent or gateway) or, when `estimatedCostUsd` covers it, computed from the price table.", "type": "number" }, "estimatedCostUsd": { "description": "Session totals only: the part of `costUsd` computed from token counts and list\nprices rather than reported (events say so with `payload.costEstimated`).", "type": "number" }, "estimatedCostByTier": { "description": "Session totals only: the part of `estimatedCostUsd` priced at non-standard\nrates, keyed by the calls' `payload.priceTier` (`batch`, `long-context`, ...).", "type": "object", "additionalProperties": { "type": "number" } }, "estimatedCostByTokenType": { "description": "Session totals only: `estimatedCostUsd` split by token type, the sum of the\ncalls' `payload.costByTokenType`. Absent when an estimated call has no split.", "$ref": "#/$defs/CostByTokenType" } }, "additionalProperties": false }, "WaitStats": { "description": "Session.stats.waits: how often and how long the session waited on the person, and on what\n(core/wait-stats.ts). A wait ends when the person answers: its tool call ends, its host request\nresolves, or the person's next prompt arrives.", "type": "object", "properties": { "count": { "description": "Waits counted, every kind, `open` ones included.", "type": "number" }, "ms": { "description": "Their summed length (ms). Waits on different threads at the same time each count.", "type": "number" }, "medianMs": { "description": "The median length (ms) of every kind's waits, when count is over one: the typical wait, which a\nfew long ones (a session picked up the next day) do not move as they move `ms`.", "type": "number" }, "byKind": { "type": "object", "properties": { "permission": { "$ref": "#/$defs/WaitTotal" }, "question": { "$ref": "#/$defs/WaitTotal" }, "plan": { "$ref": "#/$defs/WaitTotal" }, "turn": { "$ref": "#/$defs/WaitTotal" }, "request": { "$ref": "#/$defs/WaitTotal" } }, "additionalProperties": false }, "open": { "description": "Waits nobody answered, counted up to the session's end, a resume, or its last event (included\nin count and ms). Absent when none.", "type": "object", "properties": { "count": { "type": "number" }, "ms": { "type": "number" } }, "required": [ "count", "ms" ], "additionalProperties": false }, "agent": { "description": "Turn waits that an agent's prompt ended instead of the person's (a task notification, a\ndelegated task's result, a message another thread sent), or that ended when the agent went on by\nitself. Not in count or ms. Absent when none.", "type": "object", "properties": { "count": { "type": "number" }, "ms": { "type": "number" } }, "required": [ "count", "ms" ], "additionalProperties": false }, "steers": { "description": "Prompts the person sent while the main thread's turn was still running. Absent when none.", "type": "number" }, "capped": { "description": "Waits cut to 12 hours (each counts 12 hours). Absent when none.", "type": "number" } }, "required": [ "count", "ms", "byKind" ], "additionalProperties": false }, "WaitTotal": { "description": "One kind's waits in Session.stats.waits.", "type": "object", "properties": { "count": { "type": "number" }, "ms": { "description": "Their summed length (ms).", "type": "number" }, "medianMs": { "description": "The median length (ms), when count is over one.", "type": "number" }, "open": { "description": "How many of them nobody answered. Absent when none.", "type": "number" } }, "required": [ "count", "ms" ], "additionalProperties": false }, "Waiting": { "description": "Session.stats.waiting: what the session waits on from the user, as of its last event (core/waiting.ts).\n- `permission`: the agent asked to approve a tool call (a permission notification from its hook).\n- `question`: a question tool call (AskUserQuestion, request_user_input, …) is open.\n- `plan`: a plan-approval call (ExitPlanMode) is open.\n- `turn`: the main thread's turn ended in a session launched interactively.", "type": "object", "properties": { "kind": { "enum": [ "permission", "question", "plan", "turn" ] }, "at": { "description": "When the wait began (ms since the epoch).", "type": "number" }, "toolUseId": { "description": "The open tool call the wait is on, when the agent named it.", "type": "string" }, "text": { "description": "The prompt, question or plan, redacted, up to 300 characters.", "type": "string" } }, "required": [ "kind", "at" ], "additionalProperties": false }, "WasteStats": { "description": "Session.stats.waste: duplicate fetches, read-only tool calls (Read, Grep, a\n`cat`, an MCP get) repeated while the first result was still in context and\nunchanged, so the repeat re-sent tokens the model already had.", "type": "object", "properties": { "duplicateFetches": { "type": "number" }, "duplicateFetchTokens": { "description": "Estimated tokens the repeats re-sent: output characters / 4.", "type": "number" }, "readOnlyCalls": { "description": "All read-only calls in the session, the base for a duplicate share.", "type": "number" } }, "required": [ "duplicateFetches", "duplicateFetchTokens", "readOnlyCalls" ], "additionalProperties": false }, "WeightEditStats": { "description": "Session.stats.weightEdits: weight edits the session recorded (`notification`\nevents with `payload.kind: \"weights.edit\"`), and the checkpoints it recorded\n(`payload.kind: \"weights.checkpoint\"`).", "type": "object", "properties": { "events": { "description": "Edits recorded. 0 for a session that recorded a checkpoint and no edit.", "type": "number" }, "tensors": { "description": "Distinct tensor names edited. Unset when no edit kept its name, as in metadata capture.", "type": "number" }, "weightsChanged": { "description": "The edits' `changed` counts added up: a weight two edits changed counts twice.", "type": "number" }, "checkpoints": { "description": "SHA-256 of each weights file the session recorded as a checkpoint: distinct, in\narrival order, at most 16. The value `coding.sh exp run --weights` takes. Unset when\nthe session recorded no checkpoint.", "type": "array", "items": { "type": "string" } } }, "required": [ "events", "weightsChanged" ], "additionalProperties": false } } }