Skip to content

AfterModelCallEvent

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

Event triggered after the model invocation completes. Fired after the model finishes generating a response, whether successful or failed. Uses reverse callback ordering for proper cleanup semantics.

Note: stopData may be undefined if an error occurs before the model completes.

new AfterModelCallEvent(data): AfterModelCallEvent;

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

ParameterType
data{ agent: LocalAgent; model: Model; invocationState: InvocationState; attemptCount: number; stopData?: ModelStopResponse; error?: Error; }
data.agentLocalAgent
data.modelModel
data.invocationStateInvocationState
data.attemptCountnumber
data.stopData?ModelStopResponse
data.error?Error

AfterModelCallEvent

HookableEvent.constructor

readonly type: "afterModelCallEvent";

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


readonly agent: LocalAgent;

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


readonly model: Model;

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


readonly optional stopData?: ModelStopResponse;

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


readonly optional error?: Error;

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


readonly invocationState: InvocationState;

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


readonly attemptCount: number;

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

1-indexed count of model attempts for this turn, including the attempt that just completed (or failed). The first call in a turn is 1; each subsequent retry increments by one.

Retry strategies may rely on attemptCount === 1 to mark the start of a new retry sequence (e.g. to clear per-turn state carried over from a previous turn). The agent loop guarantees this marker on every fresh turn.


optional retry?: boolean;

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

Optional flag that can be set by hook callbacks to request a retry of the model call. When set to true, the agent will retry the model invocation.

toJSON(): Pick<AfterModelCallEvent, "type" | "stopData" | "attemptCount"> & {
error?: {
message?: string;
};
};

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

Serializes for wire transport, excluding the agent reference, invocationState, and mutable retry flag. Converts Error to an extensible object for safe wire serialization. Called automatically by JSON.stringify().

Pick<AfterModelCallEvent, "type" | "stopData" | "attemptCount"> & { error?: { message?: string; }; }