---
url: 'https://adk.nht.io/api/@nhtio/adk/common/classes/Message.md'
description: >-
  An immutable, validated conversation message from a human participant or the
  model.
---

# Class: Message

Defined in: [lib/classes/message.ts:152](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/message.ts#L152)

An immutable, validated conversation message from a human participant or the model.

## Remarks

Covers only `user` and `assistant` roles — system instructions, developer directives, and
tool results are not represented here. Constructed from a [RawMessage](../interfaces/RawMessage.md) via
`rawMessageSchema`. Temporal fields are normalised to Luxon `DateTime` instances at
construction time. Both `content` and `identity.representation` are [@nhtio/adk!Tokenizable](Tokenizable.md) so
token cost can be estimated inline.

A message may carry `content` (text), `attachments` (media), or both. The cross-field rule
on `rawMessageSchema` enforces that at least one is present. Downstream code that reaches
for `message.content` must handle the attachments-only case where `content` is `undefined`.

## Constructors

### Constructor

```ts
new Message(raw: RawMessage): Message;
```

Defined in: [lib/classes/message.ts:221](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/message.ts#L221)

#### Parameters

| Parameter | Type                                        | Description                                                 |
| --------- | ------------------------------------------- | ----------------------------------------------------------- |
| `raw`     | [`RawMessage`](../interfaces/RawMessage.md) | The raw message input validated against `rawMessageSchema`. |

#### Returns

`Message`

#### Throws

[@nhtio/adk!E\_INVALID\_INITIAL\_MESSAGE\_VALUE](../../exceptions/variables/E_INVALID_INITIAL_MESSAGE_VALUE.md) when `raw` does not satisfy the schema —
including the cross-field rule that at least one of `content` or `attachments` must be
present and non-empty.

## Properties

| Property                                        | Modifier   | Type                                                          | Default value      | Description                                                                                                                                                                                                                                                                                                                                                      | Defined in                                                                                                    |
| ----------------------------------------------- | ---------- | ------------------------------------------------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
|  `attachments` | `readonly` | readonly [`Media`](Media.md)\[]                                | `undefined`        | Media attachments carried by this message. **Remarks** Always defined as a frozen array — empty when the message has no attachments. Both `user` and `assistant` messages may carry attachments. Each entry carries its own `trustTier` and `modalityHazard`; the renderer wraps each in its own trust envelope independent of the message envelope.             | [lib/classes/message.ts:199](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/message.ts#L199) |
|  `content`         | `readonly` | [`Tokenizable`](Tokenizable.md) | `undefined`                | `undefined`        | The message content as a [@nhtio/adk!Tokenizable](Tokenizable.md) for inline token estimation, or `undefined` for attachments-only messages. **Remarks** `undefined` when the message was constructed with only `attachments`. Render code that needs the text portion must guard for the missing case rather than blindly calling `message.content.toString()`. | [lib/classes/message.ts:189](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/message.ts#L189) |
|  `createdAt`     | `readonly` | `DateTime`                                                    | `undefined`        | When this message was created.                                                                                                                                                                                                                                                                                                                                   | [lib/classes/message.ts:203](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/message.ts#L203) |
|  `id`                   | `readonly` | `string`                                                      | `undefined`        | Stable unique identifier for this message.                                                                                                                                                                                                                                                                                                                       | [lib/classes/message.ts:177](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/message.ts#L177) |
|  `identity`       | `readonly` | [`Identity`](Identity.md)                                     | `undefined`        | The identity of the participant who authored this message.                                                                                                                                                                                                                                                                                                       | [lib/classes/message.ts:201](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/message.ts#L201) |
|  `role`               | `readonly` | [`MessageRole`](../type-aliases/MessageRole.md)               | `undefined`        | Whether this message is from the human participant or the model.                                                                                                                                                                                                                                                                                                 | [lib/classes/message.ts:179](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/message.ts#L179) |
|  `updatedAt`     | `readonly` | `DateTime`                                                    | `undefined`        | When this message was last modified.                                                                                                                                                                                                                                                                                                                             | [lib/classes/message.ts:205](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/message.ts#L205) |
|  `schema`           | `static`   | `ObjectSchema`<[`RawMessage`](../interfaces/RawMessage.md)> | `rawMessageSchema` | Validator schema that accepts a [RawMessage](../interfaces/RawMessage.md) object. **Remarks** Reusable fragment for any schema that needs to validate or nest a message entry — for example, a collection schema that holds an array of messages.                                                                                                                | [lib/classes/message.ts:160](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/message.ts#L160) |

## Methods

### isMessage()

```ts
static isMessage(value: unknown): value is Message;
```

Defined in: [lib/classes/message.ts:172](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/message.ts#L172)

Returns `true` if `value` is a Message instance.

#### Parameters

| Parameter | Type      | Description        |
| --------- | --------- | ------------------ |
| `value`   | `unknown` | The value to test. |

#### Returns

`value is Message`

`true` when `value` is a Message instance.

#### Remarks

Uses [@nhtio/adk!isInstanceOf](../../guards/functions/isInstanceOf.md) for cross-realm safety — `instanceof` would fail for instances
created in a different module copy or VM context.
