AgentStateController
Manages active agent resolution, handoff recording, and agent state. Shared by Runtime and VoiceEngine.
Methods
Section titled “Methods”clearAgent()
Section titled “clearAgent()”clearAgent(session, agentId): void;Remove per-agent state from session.agentStates. No-op if absent.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
getActiveAgent()
Section titled “getActiveAgent()”getActiveAgent(session, fallbackAgentId): string;Resolve the active agent ID, falling back to the provided default.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”string
getAgentState()
Section titled “getAgentState()”getAgentState<T>(session, agentId): T | undefined;Read per-agent state with optional type assertion. Returns undefined if absent or empty.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
|
|
|
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”T | undefined
isCircularHandoff()
Section titled “isCircularHandoff()”isCircularHandoff( handoffStack, agentId, maxVisits?): boolean;Check whether visiting the given agent would constitute a circular handoff. Returns true if the agent has been visited >= maxVisits times in the handoff stack.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”boolean
recordHandoff()
Section titled “recordHandoff()”recordHandoff(args): void;Record a handoff in the session’s handoff history.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”void
setActiveAgent()
Section titled “setActiveAgent()”setActiveAgent(session, agentId): void;Set the active agent on the session.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”void
setAgentState()
Section titled “setAgentState()”setAgentState( session, agentId, state): void;Replace per-agent state fully (no merge). Use when the state is a single opaque blob.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”void
updateAgentState()
Section titled “updateAgentState()”updateAgentState( session, agentId, state): void;Update per-agent state stored in session.agentStates. Merges with existing state.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”void