Skip to content

AgentConnection

Defined in: packages/engine/src/lib/agent-session/connection.ts:78

One connection’s ordered Agent Session event stream.

Capacity is bounded per connection:

  • At most 32 utterances are pending, including the one being planned or awaiting acknowledgement. A further utterance receives an error event with code queue_full and is not remembered, so it can be sent again.
  • At most 4,096 input IDs are remembered, with no eviction, so a repeated input is always ignored. After that, a new utterance receives an error event with code session_capacity. The host must open a new connection to continue.
  • Each UI change waits for acknowledgement for at most OpenConnectionOptions.acknowledgementTimeoutMs, 30 seconds by default. On the UI-only route a timeout fails the run and cancels queued work. On an agent connection a timeout of a change_screen change answers the goals that depend on it unknown, leaves a goal with a clarification verdict at needs_clarification, and lets the next queued Screen Change start.

The agent loop is experimental in 0.3 and may change in any minor release.

close(): void

Defined in: packages/engine/src/lib/agent-session/connection.ts:92

Aborts pending work and releases listeners. Idempotent; no later events are emitted.

void


send(input): Promise<void>

Defined in: packages/engine/src/lib/agent-session/connection.ts:88

Accepts untrusted input. An utterance resolves according to its route: the UI-only route resolves when it emits ui_change, before the later ui_applied; an Agent Run route resolves when the run finishes, so a change_screen call can keep it pending until ui_applied or the acknowledgement timeout. Sends queued behind earlier work can also remain pending. Input sent after close() is dropped without an event or a diagnostic.

unknown

Promise<void>


subscribe(listener): () => void

Defined in: packages/engine/src/lib/agent-session/connection.ts:90

Observes future events in emission order. Returns an unsubscribe function; there is no replay.

(event) => void

() => void