Skip to content

AfterModelCallEvent

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

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:520

ParameterType
data{ agent: LocalAgent; model: Model; invocationState: InvocationState; attemptCount: number; stopData?: ModelStopResponse; error?: Error; } & HookableEventData

AfterModelCallEvent

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: "afterModelCallEvent";

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


readonly agent: LocalAgent;

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


readonly model: Model;

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


readonly stopData?: ModelStopResponse;

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


readonly error?: Error;

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


readonly invocationState: InvocationState;

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


readonly attemptCount: number;

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

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.


retry?: boolean;

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

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:552

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; }; }