Open Agent Loops
API Reference

AsyncWriterOptions

@open-agent-loops/core


Defined in: observability/async-writer.ts:19

AsyncWriter — a fire-and-forget, queued, batched JSON-line writer for traces.

The agent loop calls enqueue(line) synchronously and (almost always) returns immediately: the line is pushed onto an in-memory queue and a background drain is scheduled on the next microtask. Writes are batched (up to batchSize per call) and ordered (one write() in flight at a time), so a slow or async sink — a file, a socket — never runs on the hot path.

Backpressure is block-until-drained: only when the queue reaches maxQueue does enqueue return a promise (resolving once the queue drains), so a caller that awaits it — the tracer's sink, which the loop awaits — is throttled instead of letting the queue grow without bound.

Writer errors are isolated: a throwing/rejecting write() is caught and counted (errors), never surfaced into the run it observes. Zero deps.

Properties

PropertyTypeDescriptionDefined in
batchSize?numberMax lines handed to write() per call. Default 100.observability/async-writer.ts:21
maxQueue?numberQueue high-water mark; enqueue applies backpressure at or above it. Default 1000.observability/async-writer.ts:23

On this page