bodhi-realtime-agent / FrameworkHooks
Interface: FrameworkHooks
Defined in: types/hooks.ts:10
Optional lifecycle hooks for observability, logging, and metrics. All hooks are synchronous and fire-and-forget — exceptions are caught and logged. Register hooks via VoiceSessionConfig or HooksManager.register().
Methods
onAgentTransfer()?
optionalonAgentTransfer(event):void
Defined in: types/hooks.ts:57
Fires after an agent transfer completes (reconnection included).
Parameters
event
fromAgent
string
reconnectMs
number
sessionId
string
toAgent
string
Returns
void
onError()?
optionalonError(event):void
Defined in: types/hooks.ts:80
Fires on any framework error. Use for centralized error logging/alerting.
Parameters
event
component
string
error
Error
sessionId?
string
severity
"error" | "warn" | "fatal"
Returns
void
onMemoryExtraction()?
optionalonMemoryExtraction(event):void
Defined in: types/hooks.ts:73
Fires after the memory distiller extracts facts from conversation.
Parameters
event
durationMs
number
factsExtracted
number
userId
string
Returns
void
onSessionEnd()?
optionalonSessionEnd(event):void
Defined in: types/hooks.ts:19
Fires when the session transitions to CLOSED.
Parameters
event
durationMs
number
reason
string
sessionId
string
Returns
void
onSessionStart()?
optionalonSessionStart(event):void
Defined in: types/hooks.ts:12
Fires when the Gemini connection becomes ACTIVE for the first time.
Parameters
event
agentName
string
sessionId
string
userId
string
Returns
void
onSubagentStep()?
optionalonSubagentStep(event):void
Defined in: types/hooks.ts:65
Fires after each step of a background subagent's LLM execution.
Parameters
event
stepNumber
number
subagentName
string
tokensUsed
number
toolCalls
string[]
Returns
void
onToolCall()?
optionalonToolCall(event):void
Defined in: types/hooks.ts:40
Fires when Gemini requests a tool invocation (before execution).
Parameters
event
agentName
string
execution
sessionId
string
toolCallId
string
toolName
string
Returns
void
onToolResult()?
optionalonToolResult(event):void
Defined in: types/hooks.ts:49
Fires after a tool completes, is cancelled, or errors.
Parameters
event
durationMs
number
error?
string
status
"completed" | "cancelled" | "error"
toolCallId
string
Returns
void
onTurnLatency()?
optionalonTurnLatency(event):void
Defined in: types/hooks.ts:26
Fires at the end of each turn with segment-level latency breakdown.
Parameters
event
segments
{ backendToClientMs?: number; backendToGeminiMs?: number; clientToBackendMs?: number; geminiProcessingMs?: number; geminiToBackendMs?: number; totalE2EMs: number; }
segments.backendToClientMs?
number
segments.backendToGeminiMs?
number
segments.clientToBackendMs?
number
segments.geminiProcessingMs?
number
segments.geminiToBackendMs?
number
segments.totalE2EMs
number
sessionId
string
turnId
string
Returns
void