> ## 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.

# ports.messages

> `readonly` **messages**: [`AgentHarnessMessagePort`](/docs/agent-sdk/harness-sdk/ports/messages#agentharnessmessageport)

## On the Agent Runtime

[The runtime adapter](/docs/agent-sdk/harness-sdk/adapters/runtime#on-the-agent-runtime) builds the port from `host`, which carries the protected members of the `Agent` class.

```ts theme={null}
// runtime-adapter.ts
const last = ((count) => count === undefined ? host.messages.last() : host.messages.last(count));
const messages = Object.freeze({
  append: (message) => host.messages.append(message),
  appendMany: (batch) => host.messages.appendMany(batch),
  all: () => host.messages.all(),
  last,
  count: () => host.messages.count(),
});
```

* `append()` calls [`this.messages.append()`](/docs/agent-sdk/interface/messages#append), which assigns the message's `seq` and writes its row in one commit.
* `appendMany()` calls [`this.messages.appendMany()`](/docs/agent-sdk/interface/messages#appendmany), which commits the whole batch together.
* `all()` calls [`this.messages.all()`](/docs/agent-sdk/interface/messages#all), which returns the whole history in order.
* `last()` calls [`this.messages.last()`](/docs/agent-sdk/interface/messages#last), with the count when one is given.
* `count()` calls [`this.messages.count()`](/docs/agent-sdk/interface/messages#count). The log is append-only, so the count is also the `seq` of the last message.
* [`AgentMessage`](/docs/agent-sdk/interface/messages#agentmessage) and [`StoredMessage`](/docs/agent-sdk/interface/messages#storedmessage) are the runtime SDK's own types.

## AgentHarnessMessagePort

Existing Agent message-log semantics, without framework conversion helpers.

**Methods**
**all()**

> **all**(): `Promise`\<`StoredMessage`\[]>

**Returns**
`Promise`\<`StoredMessage`\[]>

**append()**

> **append**(`message`): `Promise`\<`number`>

**Parameters**

| Parameter | Type |
| - | - |
| `message` | `AgentMessage` |

**Returns**
`Promise`\<`number`>

**appendMany()**

> **appendMany**(`messages`): `Promise`\<`number`>

**Parameters**

| Parameter | Type |
| - | - |
| `messages` | `AgentMessage`\[] |

**Returns**
`Promise`\<`number`>

**count()**

> **count**(): `Promise`\<`number`>

**Returns**
`Promise`\<`number`>

**last()**
**Call Signature**

> **last**(): `Promise`\<`StoredMessage` | `undefined`>

**Returns**
`Promise`\<`StoredMessage` | `undefined`>

**Call Signature**

> **last**(`count`): `Promise`\<`StoredMessage`\[]>

**Parameters**

| Parameter | Type |
| - | - |
| `count` | `number` |

**Returns**
`Promise`\<`StoredMessage`\[]>
