transcript

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package transcript is the agent conversation contract: the harness-neutral turn vocabulary every agent CLI's stream is projected onto, the prefixed JSONL line format that carries turns out of the agent pod on stdout, and the gzipped ConfigMap the owning controller persists them into.

Turns ride the same stdout as the envelope's stage results but under their own prefix, so the two streams stay disjoint: a run emits hundreds of turns and one result, and the controller's result path must not have to walk the former to find the latter.

The in-pod recorder and the status server both round-trip through this package, so the capture and playback shapes cannot drift.

Index

Constants

View Source
const (
	DefaultMaxTurnBytes  = 2048
	DefaultMaxTurns      = 500
	DefaultMaxTotalBytes = 512 << 10
)

Recording bounds. A transcript is persisted in a ConfigMap, so the total is sized to leave headroom under the 1 MiB object cap even before gzip; the per-turn cap keeps one runaway tool result from consuming the whole budget.

View Source
const Prefix = "PATCHY-TURN: "

Prefix marks a turn line on the agent-runner's stdout. It is deliberately distinct from envelope.Prefix: the controller's result path scans for stage results, and a run's few hundred turns must not ride that slice.

View Source
const Redacted = "«redacted»"

Redacted replaces any credential value found in captured text.

View Source
const Version = 1

Version is the current turn schema version.

Variables

This section is empty.

Functions

func Encode

func Encode(t Turn) (string, error)

Encode renders a turn as its stdout line, without the trailing newline.

func HasPrefix

func HasPrefix(line []byte) bool

HasPrefix reports whether a log line is a turn line. Callers scanning for some other prefix use it to skip turns cheaply, without a full decode.

func Truncate

func Truncate(s string, limit int) (string, bool)

Truncate caps s at limit bytes on a rune boundary (the API server rejects invalid UTF-8, and a turn is stored in a ConfigMap). It reports whether it cut anything.

func Truncated

func Truncated(turns []Turn) bool

Truncated reports whether any turn in a recorded transcript was cut, so a reader can be told the record is partial. It is derived from the turns themselves rather than reported alongside them: what survived into storage is the only honest account of what was kept.

Types

type Kind

type Kind string

Kind discriminates what a turn carries.

const (
	KindText       Kind = "text"
	KindThinking   Kind = "thinking"
	KindToolUse    Kind = "tool_use"
	KindToolResult Kind = "tool_result"
	KindNotice     Kind = "notice"
)

The turn kinds. Notice is the recorder's own voice — session banners, truncation, and budget aborts — and never the agent's.

type Limits

type Limits struct {
	MaxTurnBytes  int
	MaxTurns      int
	MaxTotalBytes int
}

Limits bounds one recording. A zero field takes the package default; a negative field disables that bound.

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

Recorder normalises, bounds, redacts, and sequences the turns of one run. It is the single gate every captured turn passes through, so the live stream and the persisted transcript can never disagree.

Recorder is safe for concurrent use, though the runner's line observer calls it from one goroutine.

func NewRecorder

func NewRecorder(limits Limits, secrets []string, emit func(Turn)) *Recorder

NewRecorder returns a recorder that hands each admitted turn to emit. secrets are literal credential values scrubbed from every captured field: the pod holds the model API key and a tool result can echo the environment.

func (*Recorder) Notice

func (r *Recorder) Notice(format string, args ...any)

Notice emits a recorder-voiced turn — a budget abort, a stage banner. It is bounded like any other turn but is never itself the cause of truncation.

func (*Recorder) Record

func (r *Recorder) Record(t Turn)

Record admits one turn: it stamps the sequence and time, redacts, caps the text, and emits. Turns arriving after a bound is hit are dropped, and the first drop emits a closing notice so the reader knows the record is partial.

func (*Recorder) RecordAll

func (r *Recorder) RecordAll(turns []Turn)

RecordAll admits a batch, preserving order.

func (*Recorder) Stats

func (r *Recorder) Stats() (turns int, truncated bool)

Stats reports what the recorder admitted, for the stage result.

type Role

type Role string

Role is who produced a turn.

const (
	RoleAssistant Role = "assistant"
	RoleUser      Role = "user"
	RoleSystem    Role = "system"
)

The roles. Tool results are reported by the harness as user-role turns, matching how the model sees them.

type Turn

type Turn struct {
	V         int    `json:"v"`
	Seq       int    `json:"seq"`
	At        string `json:"at,omitempty"`
	Role      Role   `json:"role"`
	Kind      Kind   `json:"kind"`
	Tool      string `json:"tool,omitempty"`
	Text      string `json:"text,omitempty"`
	Truncated bool   `json:"truncated,omitempty"`
}

Turn is one entry in an agent's conversation, normalised across harnesses. Text carries the message body, the tool invocation's rendered input, or the tool result's excerpt depending on Kind; Truncated reports that the recorder capped it.

func Decode

func Decode(line []byte) (Turn, bool)

Decode recovers a turn from one log line; ok is false for any line that is not a turn line.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL