Skip to content

BeforeModelCallEvent

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

Event triggered just before the model is invoked. Fired before sending messages to the model for inference.

new BeforeModelCallEvent(data): BeforeModelCallEvent;

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

ParameterType
data{ agent: LocalAgent; model: Model; invocationState: InvocationState; projectedInputTokens?: number; }
data.agentLocalAgent
data.modelModel
data.invocationStateInvocationState
data.projectedInputTokens?number

BeforeModelCallEvent

HookableEvent.constructor

readonly type: "beforeModelCallEvent";

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


readonly agent: LocalAgent;

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


readonly model: Model;

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


readonly invocationState: InvocationState;

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


cancel: string | boolean = false;

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

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


readonly optional projectedInputTokens?: number;

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

Projected input token count for the upcoming model call. Computed by the agent loop from message metadata and token estimation. Available for hooks and plugins (e.g. conversation managers) to make proactive decisions about context management.

toJSON(): Pick<BeforeModelCallEvent, "type" | "projectedInputTokens">;

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

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

Pick<BeforeModelCallEvent, "type" | "projectedInputTokens">