# AgentConnection
Source: https://docs.maelstrom-ai.co/0.2/reference/engine/interfaces/agentconnection/
Documentation revision: 89a8f5e9d10cedcf0b30376d7846113f06f26120
SDK manifests in this build: @maelstrom-co/react@0.2.1, @maelstrom-co/client@0.2.1, @maelstrom-co/connectors@0.2.1, @maelstrom-co/protocol@0.2.1, @maelstrom-co/engine@0.2.1
These docs follow this source revision. Manifest versions do not prove release compatibility; verify the installed package exports before using an API.

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

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](https://docs.maelstrom-ai.co/0.2/reference/engine/interfaces/openconnectionoptions/#acknowledgementtimeoutms), 30 seconds by default. A timeout fails the run and cancels queued work.

## Methods

### close()

> **close**(): `void`

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

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

#### Returns

`void`

* * *

### send()

> **send**(`input`): `Promise`<`void`\>

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

Accepts untrusted input. Resolves after handling it, without waiting for a later UI acknowledgement.

#### Parameters

##### input

`unknown`

#### Returns

`Promise`<`void`\>

* * *

### subscribe()

> **subscribe**(`listener`): () => `void`

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

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

#### Parameters

##### listener

(`event`) => `void`

#### Returns

() => `void`
