Interface AgentHooks<UserData, ContextT>

interface AgentHooks<UserData, ContextT> {
    llmNode?: ((ctx, chatCtx, toolCtx, modelSettings) => AgentHookNodeResult<string | ChatChunk>);
    onEnter?: ((ctx) => void | Promise<void>);
    onExit?: ((ctx) => void | Promise<void>);
    onUserTurnCompleted?: ((ctx, chatCtx, newMessage) => void | Promise<void>);
    realtimeAudioOutputNode?: ((ctx, audio, modelSettings) => AgentHookNodeResult<AudioFrame>);
    sttNode?: ((ctx, audio, modelSettings) => AgentHookNodeResult<string | SpeechEvent>);
    transcriptionNode?: ((ctx, text, modelSettings) => AgentHookNodeResult<string | TimedString>);
    ttsNode?: ((ctx, text, modelSettings) => AgentHookNodeResult<AudioFrame>);
}

Type Parameters

Hierarchy (view full)

Properties

llmNode?: ((ctx, chatCtx, toolCtx, modelSettings) => AgentHookNodeResult<string | ChatChunk>)

Produces LLM chunks or text from the current chat and tool context.

Type declaration

onEnter?: ((ctx) => void | Promise<void>)

Called when the agent becomes active in a session.

Type declaration

    • (ctx): void | Promise<void>
    • Parameters

      Returns void | Promise<void>

onExit?: ((ctx) => void | Promise<void>)

Called when the agent is leaving the active session.

Type declaration

    • (ctx): void | Promise<void>
    • Parameters

      Returns void | Promise<void>

onUserTurnCompleted?: ((ctx, chatCtx, newMessage) => void | Promise<void>)

Called after the user's turn has been committed to the chat context.

Type declaration

realtimeAudioOutputNode?: ((ctx, audio, modelSettings) => AgentHookNodeResult<AudioFrame>)

Processes realtime model audio before it is sent to the agent output.

Type declaration

sttNode?: ((ctx, audio, modelSettings) => AgentHookNodeResult<string | SpeechEvent>)

Transforms incoming audio into speech events or transcript text for the agent.

Type declaration

transcriptionNode?: ((ctx, text, modelSettings) => AgentHookNodeResult<string | TimedString>)

Transforms the agent's output transcript before it is forwarded.

Type declaration

ttsNode?: ((ctx, text, modelSettings) => AgentHookNodeResult<AudioFrame>)

Synthesizes agent text into audio frames for playout.

Type declaration