DefaultConversationState
Default conversation state implementation extracted from Runtime.
Handles:
- Session load/create/save/delete via SessionStore
- Message appending with normalization
- Turn counting
- Working memory access
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DefaultConversationState(config): DefaultConversationState;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”DefaultConversationState
Methods
Section titled “Methods”appendAssistantMessage()
Section titled “appendAssistantMessage()”appendAssistantMessage(session, text): void;Append an assistant message to the session history.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”ConversationState.appendAssistantMessage
appendMessage()
Section titled “appendMessage()”appendMessage(session, message): void;Append a raw ModelMessage to the session history.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”ConversationState.appendMessage
appendUserMessage()
Section titled “appendUserMessage()”appendUserMessage(session, text): void;Append a user message to the session history.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”ConversationState.appendUserMessage
bumpSessionTurn()
Section titled “bumpSessionTurn()”bumpSessionTurn(session): number;Increment and return the new turn number.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”ConversationState.bumpSessionTurn
createSession()
Section titled “createSession()”createSession( id, defaultAgentId, userId?, opts?): Session;Create a fresh session with defaults.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”ConversationState.createSession
delete()
Section titled “delete()”delete(sessionId): Promise<void>;Delete a session from the backing store.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”getSessionTurn()
Section titled “getSessionTurn()”getSessionTurn(session): number;Get the current turn number for the session.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”ConversationState.getSessionTurn
load()
Section titled “load()”load(sessionId, userId?): Promise<Session>;Load an existing session or create a new one.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”Promise<Session>
Implementation of
Section titled “Implementation of”save()
Section titled “save()”save(session): Promise<void>;Persist session to the backing store.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”touchSession()
Section titled “touchSession()”touchSession(session): void;Update the session’s updatedAt timestamp.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”ConversationState.touchSession
workingMemory()
Section titled “workingMemory()”workingMemory(session): WorkingMemory;Get a WorkingMemory wrapper for the session.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|