Skip to content

BeforeInvocationEvent

Defined in: src/hooks/events.ts:159

Event triggered at the beginning of a new agent request. Fired before any model inference or tool execution occurs.

new BeforeInvocationEvent(data): BeforeInvocationEvent;

Defined in: src/hooks/events.ts:177

ParameterType
data{ agent: LocalAgent; invocationState: InvocationState; messages?: Message[]; } & HookableEventData

BeforeInvocationEvent

HookableEvent.constructor

readonly invocationContext?: InvocationContext;

Defined in: src/hooks/events.ts:100

The request this event belongs to (undefined outside one); pass it to InvokeOptions.invocationContext to join it.

HookableEvent.invocationContext


readonly type: "beforeInvocationEvent";

Defined in: src/hooks/events.ts:160


readonly agent: LocalAgent;

Defined in: src/hooks/events.ts:161


readonly invocationState: InvocationState;

Defined in: src/hooks/events.ts:162


messages: Message[];

Defined in: src/hooks/events.ts:168

Input messages for this invocation. Hook callbacks may mutate this array or replace it before processing.


cancel: string | boolean = false;

Defined in: src/hooks/events.ts:175

Set by hook callbacks to cancel this invocation. When set to true, a default cancel message is used. When set to a string, that string is used as the assistant response message.

toJSON(): Pick<BeforeInvocationEvent, "type">;

Defined in: src/hooks/events.ts:188

Serializes for wire transport, excluding the agent reference, invocationState, and messages. Called automatically by JSON.stringify().

Pick<BeforeInvocationEvent, "type">