ConversationManager
Manages multi-turn conversation history for the LLM pipeline.
Defined in: src/core/collaborators/ConversationManager.ts:25
Manages multi-turn conversation history for the LLM pipeline.
Remarks
Handles accumulation of user and assistant messages, enforces the maxTurns limit, and builds I/O context messages that inform the LLM about the current interaction modality (voice vs text).
Constructors
Constructor
new ConversationManager(config?, logger?): ConversationManager;
Defined in: src/core/collaborators/ConversationManager.ts:28
Parameters
| Parameter | Type |
|---|---|
config? | ConversationHistoryConfig |
logger? | Logger |
Returns
ConversationManager
Accessors
enabled
Get Signature
get enabled(): boolean;
Defined in: src/core/collaborators/ConversationManager.ts:34
Whether conversation history is enabled in the configuration.
Returns
boolean
Methods
addAssistantMessage()
addAssistantMessage(text): void;
Defined in: src/core/collaborators/ConversationManager.ts:60
Add an assistant message to the conversation history.
Parameters
| Parameter | Type | Description |
|---|---|---|
text | string | The assistant’s response text. |
Returns
void
addMessage()
addMessage(message): void;
Defined in: src/core/collaborators/ConversationManager.ts:75
Add an arbitrary message to the conversation history.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | LLMMessage | The message to add. |
Returns
void
Remarks
Used for tool-call messages (role: ‘assistant’ with toolCalls, or role: ‘tool’ with toolCallId) that don’t fit the simple user/assistant pattern.
addUserMessage()
addUserMessage(text, modality?): void;
Defined in: src/core/collaborators/ConversationManager.ts:44
Add a user message to the conversation history.
Parameters
| Parameter | Type | Description |
|---|---|---|
text | string | The user’s message text. |
modality? | "voice" | "text" | How the message was input (‘voice’ or ‘text’). |
Returns
void
buildIOContextMessage()
buildIOContextMessage(
modality,
inputMuted,
outputMuted): LLMMessage;
Defined in: src/core/collaborators/ConversationManager.ts:114
Build an I/O context system message that tells the LLM about the current interaction modality.
Parameters
| Parameter | Type | Description |
|---|---|---|
modality | "voice" | "text" | How this specific message was input. |
inputMuted | boolean | Whether the microphone is currently muted. |
outputMuted | boolean | Whether audio output is currently muted. |
Returns
An LLMMessage with role ‘system’ describing the I/O context.
clear()
clear(): void;
Defined in: src/core/collaborators/ConversationManager.ts:100
Clears all accumulated conversation history.
Returns
void
getMessages()
getMessages(): LLMMessage[];
Defined in: src/core/collaborators/ConversationManager.ts:82
Returns a shallow copy of the current conversation history.
Returns
getMessagesForLLM()
getMessagesForLLM(
modality,
inputMuted,
outputMuted): LLMMessage[];
Defined in: src/core/collaborators/ConversationManager.ts:155
Get the full message list for an LLM call, including I/O context and conversation history.
Parameters
| Parameter | Type | Description |
|---|---|---|
modality | "voice" | "text" | How this specific message was input. |
inputMuted | boolean | Whether the microphone is currently muted. |
outputMuted | boolean | Whether audio output is currently muted. |
Returns
Array of LLMMessage ready to send to the LLM.
getMessagesRef()
getMessagesRef(): LLMMessage[];
Defined in: src/core/collaborators/ConversationManager.ts:93
Returns the raw internal history array (by reference).
Returns
Remarks
Used by CompositeVoice when building message arrays for tool loops that need to mutate the array in place.