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.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AfterModelCallEvent(data): AfterModelCallEvent;Defined in: src/hooks/events.ts:520
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | { agent: LocalAgent; model: Model; invocationState: InvocationState; attemptCount: number; stopData?: ModelStopResponse; error?: Error; } & HookableEventData |
Returns
Section titled “Returns”AfterModelCallEvent
Overrides
Section titled “Overrides”Properties
Section titled “Properties”invocationContext?
Section titled “invocationContext?”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.
Inherited from
Section titled “Inherited from”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
stopData?
Section titled “stopData?”readonly stopData?: ModelStopResponse;Defined in: src/hooks/events.ts:499
error?
Section titled “error?”readonly error?: Error;Defined in: src/hooks/events.ts:500
invocationState
Section titled “invocationState”readonly invocationState: InvocationState;Defined in: src/hooks/events.ts:501
attemptCount
Section titled “attemptCount”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?
Section titled “retry?”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.
Methods
Section titled “Methods”toJSON()
Section titled “toJSON()”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().
Returns
Section titled “Returns”Pick<AfterModelCallEvent, "type" | "stopData" | "attemptCount"> & {
error?: {
message?: string;
};
}