ConversationHistoryConfig
Configuration for multi-turn conversation history.
Defined in: src/core/types/config.ts:355
Configuration for multi-turn conversation history.
Remarks
When enabled, the SDK accumulates user and assistant messages across turns and sends them to the LLM as context, enabling multi-turn conversations. The maxTurns setting controls how many turns are retained; oldest turns are dropped when the limit is reached.
Example
const conversationHistory: ConversationHistoryConfig = {
enabled: true,
maxTurns: 10,
};
See
- LLMMessage for the message format sent to the LLM
- CompositeVoiceConfig for where this is used
Properties
| Property | Type | Default value | Description | Defined in |
|---|---|---|---|---|
enabled | boolean | false | Whether conversation history is enabled. Remarks When true, all turns are accumulated and sent to the LLM as context. | src/core/types/config.ts:364 |
maxTokens? | number | undefined (no token limit) | Approximate token budget for conversation history. Remarks When set, the SDK estimates token count using a Math.ceil(text.length / 4) heuristic (roughly 1 token per 4 characters). Oldest non-system turns are removed until the total estimated token count fits within this budget. This is a coarse heuristic, not an exact tokenizer — actual token counts will vary by model and language. Use this as a safety net to prevent excessively large context windows, not as a precise limit. When both maxTurns and maxTokens are set, the more restrictive limit wins. | src/core/types/config.ts:398 |
maxTurns? | number | 0 | Maximum number of conversation turns to retain. Remarks A “turn” is a user + assistant message pair. Oldest turns are dropped when the limit is reached. Set to 0 for unlimited history. When both maxTurns and maxTokens are set, the more restrictive limit wins (i.e., both constraints are applied and the smallest resulting history is used). | src/core/types/config.ts:379 |
preserveSystemMessages? | boolean | true | Whether to preserve system messages during history trimming. Remarks When true (the default), system messages (role 'system') are never removed by turn-based or token-based trimming. They are separated before trimming and prepended back afterward, ensuring system instructions are always present in the LLM context. Set to false to treat system messages the same as user/assistant messages during trimming. | src/core/types/config.ts:414 |