bodhi-realtime-agent / AgentContext
Interface: AgentContext
Defined in: src/types/agent.ts:15
Runtime context passed to agent lifecycle hooks (onEnter, onExit, onTurnCompleted). Provides read access to session state and the ability to inject messages.
Properties
agentName
agentName:
string
Defined in: src/types/agent.ts:19
Name of the agent receiving this context.
sessionId
sessionId:
string
Defined in: src/types/agent.ts:17
Current session identifier.
Methods
getMemoryFacts()
getMemoryFacts():
MemoryFact[]
Defined in: src/types/agent.ts:25
Retrieve all memory facts currently stored for this user.
Returns
getRecentTurns()
getRecentTurns(
count?):ConversationItem[]
Defined in: src/types/agent.ts:23
Retrieve the most recent conversation turns (default 10).
Parameters
count?
number
Returns
injectSystemMessage()
injectSystemMessage(
text):void
Defined in: src/types/agent.ts:21
Inject a system-level message into the conversation (visible to the model on next turn).
Parameters
text
string
Returns
void
requestTransfer()
requestTransfer(
toAgent):void
Defined in: src/types/agent.ts:27
Request an asynchronous transfer to another agent (fires on next tick to avoid re-entrancy).
Parameters
toAgent
string
Returns
void
sendAudioToClient()?
optionalsendAudioToClient(data):void
Defined in: src/types/agent.ts:35
Send raw PCM audio to the connected client as a binary frame.
Parameters
data
Buffer
Returns
void
sendJsonToClient()
sendJsonToClient(
message):void
Defined in: src/types/agent.ts:33
Send a JSON message to the connected client (core frames + registered ClientProtocolServerExtensions; unregistered frames fail to compile).
Parameters
message
AnyServerToClientMessage
Returns
void
setExternalAudioHandler()?
optionalsetExternalAudioHandler(handler):void
Defined in: src/types/agent.ts:37
Register/unregister an external audio handler for client mic frames.
Parameters
handler
((data) => void) | null
Returns
void
stopBufferingAndDrain()
stopBufferingAndDrain(
handler):void
Defined in: src/types/agent.ts:30
Stop buffering client audio and drain buffered chunks through the handler. Used by external audio agents (e.g., Twilio) to flush audio accumulated during the dial gap.
Parameters
handler
(chunk) => void
Returns
void