What [deliver_parts] did with a batch: whether the server accepted
every part, and how many of the batch’s transcript lines, from its start,
are now accepted or in the queue. Those need not be read again; the read
offset moves past them.
The variable visdom sets on an agent it has routed through the AI
Gateway, which then records the session itself: the agent’s name
(claude-code, codex). Nobody else sets it.
How much of a transcript one hook reads. A hook has a few seconds to send
in, and what it holds it holds parsed; a backlog larger than this (a
resumed session’s transcript, a server that was away) is caught up on over
the next hooks instead, each advancing the read offset by what it sent.
The developer’s choice of tracing mode for visdom (hooks or
gateway). A preference, not a fact about a running agent: an agent
started without visdom may well carry gateway here and still talk to
its provider directly.
Whether the session this hook of agent runs in is recorded by the AI
Gateway, given the value of GATEWAY_SESSION_ENV. Hooks inherit the
agent’s environment, so this is true for the events of an agent visdom
routed through the gateway. The capture hook then records nothing: the
same session captured twice would be a second, conflicting source.
Record-count offset arithmetic for the inline (fileless) path, mirroring the
byte-offset semantics of read_new_transcript_lines: returns
(send_offset, next_offset) where send_offset is stamped on the request as
transcript_offset (base for the server’s per-line chunk_index) and
next_offset is persisted to .stream_offset.
Derive the event-level tool-error flag from inline transcript records.
OpenCode tool events carry no tool_use_id, so extract_is_error_from_transcript
can’t run; instead the plugin forwards a toolResult record whose isError
signals the outcome. Amp’s records (type: "amp_message") carry Amp’s own
tool_result block instead, whose status is "error" only for a tool
that failed: a permission rejection and a non-zero exitCode are both
"done", as Amp reports them. Returns Some(true|false) for the first
tool result found, or None when there is none (non-tool events).
Returns (lines, start_offset, end_offset): start_offset is the seek
position read from offset_path (0 if absent), and end_offset is the
byte offset after the last line read (the old bytes_read).
Fileless agents (OpenCode) have no transcript for tracevault check to
count tool calls from: their records ride inline on each hook event. Append
one slim toolCall record per tool called in records to the session’s
tool_calls.jsonl and record that file as the session’s transcript. Only
the tool name is kept — arguments and outputs (file contents, bash stdout)
would grow the file for nothing. Records with no tool call write nothing.
Store transcript_path in the session’s metadata.json, which is where
tracevault check looks for the transcript it counts tool calls from.
Without it every session reports no tool calls, and a “must call X” policy
can never pass. Other keys in the file are kept. An empty path (Codex
before its first record) writes nothing, and an unchanged path skips the
write. The file is replaced atomically: parallel tool hooks of one session
run concurrently, and check must never read a half-written file.
Choose the transcript source for a stream event. Inline records (from a
plugin-based agent like OpenCode) win over the file-read result whenever the
hook event carries them — INCLUDING an empty vec, so an event with no new
records (e.g. OpenCode stop) preserves the prior record-count offset
instead of resetting it to the file-path’s 0.
Split a hook event whose transcript batch does not fit in one request
(MAX_REQUEST_BYTES) into several requests, so no line is dropped. A
request that fits is returned unchanged as the only part.
A lines-only Transcript request with req’s session, agent and context
fields but none of its event (type, tool payload, event_uuid), which the
server handles as transcript lines only. req’s lines are not copied.
Every field is listed, so a new one has to be decided on here.