API Reference
TracerOptions
Defined in: observability/tracer.ts:44
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
flushOnEnd? | boolean | Auto-drain the async write queue when the run ends (on the agent_end event). The loop awaits that event, so runAgent resolves only once the trace is fully written — you never have to call flush() yourself. Default true; set false to manage draining manually (e.g. a writer reused across runs). No effect without write. | observability/tracer.ts:70 |
limit? | number | Keep at most this many entries (ring buffer). Default: unbounded. | observability/tracer.ts:72 |
log? | (line) => void | Synchronous live JSON logging: called with JSON.stringify(entry) inline as each entry is recorded. Use for cheap sinks (an array, console.log). For file/network I/O prefer write (async, batched, off the hot path). | observability/tracer.ts:54 |
meta? | TraceMeta | Seed run metadata (model, params, system, ...) up front. | observability/tracer.ts:74 |
now? | () => number | Clock, injectable for deterministic tests. Defaults to Date.now. | observability/tracer.ts:46 |
onEntry? | (entry) => void | Called with each entry as it's recorded — e.g. to live-print a trace. | observability/tracer.ts:48 |
write? | (lines) => void | Promise<void> | Async batched JSON logging: receives compact JSON lines in batches, off the agent loop's hot path (fire-and-forget, queued). Wire to a file/socket, e.g. { write: (lines) => appendFile("trace.jsonl", lines.join("\n") + "\n") }. Call await tracer.flush() at run end so the tail isn't lost. | observability/tracer.ts:61 |
writerOptions? | AsyncWriterOptions | Tuning for the async write queue (batch size, backpressure threshold). | observability/tracer.ts:63 |