Skip to content

bodhi-realtime-agent / MainAgent

Interface: MainAgent ​

Defined in: src/types/agent.ts:45

Defines a top-level voice agent that Gemini interacts with directly. Each agent has its own system instructions, tool set, and lifecycle hooks. Agents are registered with VoiceSession and selected via agent transfers.

Properties ​

audioMode? ​

optional audioMode?: "llm" | "external"

Defined in: src/types/agent.ts:60

Audio routing mode. 'llm' (default): audio flows through LLM transport. 'external': agent manages its own audio path (e.g., Twilio phone bridge). When 'external', LLM transport is disconnected during this agent's turn.


googleSearch? ​

optional googleSearch?: boolean

Defined in: src/types/agent.ts:54

Enable Gemini's built-in Google Search grounding for this agent.

Deprecated ​

Use providerOptions.googleSearch instead.


greeting? ​

optional greeting?: string

Defined in: src/types/agent.ts:69

Optional greeting prompt sent to Gemini when this agent activates and a client is connected. Gemini will generate a spoken response based on this prompt.


instructions ​

instructions: string | (() => string)

Defined in: src/types/agent.ts:49

System instructions sent to Gemini. Can be a static string or a factory function.


knowledgeBase? ​

optional knowledgeBase?: KnowledgeBaseConfig

Defined in: src/types/agent.ts:74

Knowledge base configuration for grounding this agent with domain-specific documents. Documents are delivered via prompt injection, tool-based retrieval, or both (auto mode).


language? ​

optional language?: string

Defined in: src/types/agent.ts:58

IETF BCP 47 language tag for this agent (e.g., 'zh-CN', 'es-ES', 'ja-JP'). When set, a language directive is prepended to the system instruction.


name ​

name: string

Defined in: src/types/agent.ts:47

Unique name used for routing (e.g. "main", "math_expert").


providerOptions? ​

optional providerOptions?: Record<string, unknown>

Defined in: src/types/agent.ts:56

Provider-specific options passed to the transport during agent transfer.


tools ​

tools: ToolDefinition[]

Defined in: src/types/agent.ts:51

Tools available to Gemini when this agent is active.

Methods ​

onEnter()? ​

optional onEnter(ctx): Promise<void>

Defined in: src/types/agent.ts:62

Called when this agent becomes the active agent (after a transfer or initial start).

Parameters ​

ctx ​

AgentContext

Returns ​

Promise<void>


onExit()? ​

optional onExit(ctx): Promise<void>

Defined in: src/types/agent.ts:64

Called when this agent is being replaced by another agent.

Parameters ​

ctx ​

AgentContext

Returns ​

Promise<void>


onTurnCompleted()? ​

optional onTurnCompleted(ctx, transcript): Promise<void>

Defined in: src/types/agent.ts:66

Called after each completed turn while this agent is active.

Parameters ​

ctx ​

AgentContext

transcript ​

string

Returns ​

Promise<void>

Built with VitePress