Skip to content

readTranscriptTail

readTranscriptTail(path, maxBytes?): string

Defined in: src/activity.ts:158

Read only the last maxBytes bytes of a JSONL transcript file.

When the file is larger than maxBytes the read starts mid-file; the leading partial line (up to and including the first \n) is dropped so a truncated record is never fed to the parser. When the whole file fits, the content is returned intact. Throws on read errors (e.g. missing file) so callers can handle with their existing try/catch → null patterns.

Degradation edge: if the tail window contains NO newline — a single JSONL record larger than maxBytes (pathological; a multi-hundred-KB tool result) — the leading-partial drop yields "" and the caller gets a null signal for this tick. This is acceptable and transient: it self-heals as soon as a newer complete record lands (the next record’s bytes bring a \n into the window).

string

number = MAX_TAIL_BYTES

string