LLMMessage
A single message in an LLM conversation.
Defined in: src/core/types/providers.ts:651
A single message in an LLM conversation.
Remarks
Represents one turn in a multi-turn conversation. The SDK accumulates these messages when ConversationHistoryConfig is enabled and passes them to generateFromMessages.
Example
const messages: LLMMessage[] = [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'What is the weather today?' },
{ role: 'assistant', content: 'I cannot check the weather, but I can help with other questions!' },
{ role: 'user', content: 'Tell me a joke instead.' },
];
See
- LLMProvider.generateFromMessages for using message arrays
- ConversationHistoryConfig for enabling multi-turn history
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
content | string | The text content of the message. | src/core/types/providers.ts:664 |
modality? | "voice" | "text" | How the message was produced. Remarks - 'voice' - Transcribed from speech via STT (default for user messages) - 'text' - Typed by the user via sendMessage() This is included in the conversation history so the LLM can adapt its response style (e.g., shorter for voice, richer formatting for text). Only meaningful for role: 'user' messages. | src/core/types/providers.ts:677 |
role | "system" | "user" | "assistant" | "tool" | The role of the message author. Remarks - 'system' - System instructions (typically the first message) - 'user' - User input (transcribed speech or typed text) - 'assistant' - Assistant response (LLM output) - 'tool' - Tool execution result (sent back after a tool call) | src/core/types/providers.ts:661 |
toolCallId? | string | The tool call ID this result belongs to (on tool messages). | src/core/types/providers.ts:683 |
toolCalls? | LLMToolCall[] | Tool calls requested by the assistant (on assistant messages). | src/core/types/providers.ts:680 |