> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# onEvents()

> **onEvents**(`listener`, `opts?`): () => `void`

Subscribe to the agent's event stream (attach mode with `"events"`
subscribed). Events arrive in `seq` order; pass `{ from }` to receive only
events with `seq >= from`. Returns an unsubscribe function.

**Parameters**

| Parameter | Type |
| - | - |
| `listener` | `EventListener` |
| `opts` | \{ `from?`: `number`; } |
| `opts.from?` | `number` |

**Returns**

() => `void`

## The Event Stream

Each [`this.events.emit`](/docs/agent-sdk/interface/events#emit) on the agent arrives as one [`AgentEvent`](#agentevent). The first connection replays the events the agent retains. Without [`resume`](/docs/agent-sdk/client-sdk/constructor#agentclientoptions), every reconnect replays them again. A listener then receives earlier events more than once.

A listener receives only the events that arrive after it is added. The client keeps no copy of past events.

## AgentEvent

One item of the agent's event stream, as delivered to `onEvents` listeners.

**Properties**

**at**

> `readonly` **at**: `Date`

Wall-clock stamp at emit time; informational (ordering is by `seq`).

***

**payload**

> `readonly` **payload**: `unknown`

The event's payload, exactly as the agent emitted it.

***

**seq**

> `readonly` **seq**: `number`

Monotonic position in the event stream; also the resume cursor.

***

**type**

> `readonly` **type**: `string`

The event kind the agent chose when emitting (e.g. `"progress"`).
