Skip to content

bodhi-realtime-agent / ToolContext

Interface: ToolContext ​

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

Runtime context provided to a tool's execute function. Includes identifiers for correlation and an AbortSignal for cancellation.

Properties ​

abortSignal ​

abortSignal: AbortSignal

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

Aborted when the tool call is cancelled (user interruption or timeout).


agentName ​

agentName: string

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

Name of the agent that owns this tool.


sessionId ​

sessionId: string

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

Session in which this tool call is happening.


toolCallId ​

toolCallId: string

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

Unique identifier for this specific tool invocation.

Methods ​

sendJsonToClient()? ​

optional sendJsonToClient<T>(message): void

Defined in: src/types/tool.ts:67

Send a JSON message to the connected client (delivered as a WebSocket text frame). Core frames, registered ClientProtocolServerExtensions, or an application HostClientFrame whose type is not a core frame type; malformed core frames fail to compile.

Type Parameters ​

T ​

T extends string

Parameters ​

message ​

AnyServerToClientMessage | HostClientFrame<T>

Returns ​

void


setDirective()? ​

optional setDirective(key, value, scope?): void

Defined in: src/types/tool.ts:81

Set an active directive by category key. Directives are reinforced every turn via sendClientContent injection, keeping them fresh in Gemini's context to prevent behavioral drift. Pass null to clear a directive.

Parameters ​

key ​

string

value ​

string | null

scope? ​

"session" | "agent"

— 'session' persists across agent transfers (e.g. pacing); 'agent' (default) is cleared on agent transfer.

Returns ​

void

Built with VitePress