Skip to content

ConversationState

Manages session lifecycle: load, save, delete, message append, turn counting. Shared by Runtime and VoiceEngine.

appendAssistantMessage(session, text): void;

Append an assistant message to the session history.

Parameter Type

session

Session

text

string

void


appendMessage(session, message): void;

Append a raw ModelMessage to the session history.

Parameter Type

session

Session

message

ModelMessage

void


appendUserMessage(session, text): void;

Append a user message to the session history.

Parameter Type

session

Session

text

string

void


bumpSessionTurn(session): number;

Increment and return the new turn number.

Parameter Type

session

Session

number


createSession(
id,
defaultAgentId,
userId?,
opts?): Session;

Create a fresh session with defaults.

Parameter Type

id

string

defaultAgentId

string

userId?

string

opts?

{ channelId?: ChannelId; conversationId?: string; }

opts.channelId?

ChannelId

opts.conversationId?

string

Session


delete(sessionId): Promise<void>;

Delete a session from the backing store.

Parameter Type

sessionId

string

Promise<void>


getSessionTurn(session): number;

Get the current turn number for the session.

Parameter Type

session

Session

number


load(sessionId, userId?): Promise<Session>;

Load an existing session or create a new one.

Parameter Type

sessionId

string

userId?

string

Promise<Session>


save(session): Promise<void>;

Persist session to the backing store.

Parameter Type

session

Session

Promise<void>


touchSession(session): void;

Update the session’s updatedAt timestamp.

Parameter Type

session

Session

void


workingMemory(session): WorkingMemory;

Get a WorkingMemory wrapper for the session.

Parameter Type

session

Session

WorkingMemory