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

# SessionEventReducer

> Folds raw notifications into typed s, correlating tool calls by id and accumulating message text.

Folds raw `session/update` notifications into typed [SessionEvent](https://docs.devin.ai/sdk/reference/types/SessionEvent.md)s,
correlating tool calls by id and accumulating message text. One reducer per
consumer — a turn, a replay, or a session-wide `events()` stream; feed
updates in arrival order.

## Constructor

```typescript
SessionEventReducer(): SessionEventReducer
```

### Returns

`SessionEventReducer`

## Properties

**lastMessageText** `undefined | string` *required*

The full text of the most recent message with any text, if any. Messages
that carry only non-text content (citation resources, for instance) are
skipped.

**text** `string` *required*

The agent's message text accumulated so far; distinct messages are separated by blank lines.

**toolCalls** `ToolCall[]` *required*

**Type:** `ToolCall[]`

Merged tool-call snapshots seen so far, in first-seen order.

## Methods

### handle()

```typescript
handle(update: SessionUpdate): SessionEvent
```

Fold one raw update into the state and return its typed event.

#### Parameters

**update** `SessionUpdate` *required*

#### Returns

`SessionEvent`

### toolCall()

```typescript
toolCall(id: string): undefined | ToolCall
```

The merged snapshot for a tool call id, if seen.

#### Parameters

**id** `string` *required*

#### Returns

`undefined | ToolCall`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.