AfterModelCallEvent
Defined in: src/hooks/events.ts:461
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:486
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | { agent: LocalAgent; model: Model; invocationState: InvocationState; attemptCount: number; stopData?: ModelStopResponse; error?: Error; } |
data.agent | LocalAgent |
data.model | Model |
data.invocationState | InvocationState |
data.attemptCount | number |
data.stopData? | ModelStopResponse |
data.error? | Error |
Returns
Section titled “Returns”AfterModelCallEvent
Overrides
Section titled “Overrides”Properties
Section titled “Properties”readonly type: "afterModelCallEvent";Defined in: src/hooks/events.ts:462
readonly agent: LocalAgent;Defined in: src/hooks/events.ts:463
readonly model: Model;Defined in: src/hooks/events.ts:464
stopData?
Section titled “stopData?”readonly optional stopData?: ModelStopResponse;Defined in: src/hooks/events.ts:465
error?
Section titled “error?”readonly optional error?: Error;Defined in: src/hooks/events.ts:466
invocationState
Section titled “invocationState”readonly invocationState: InvocationState;Defined in: src/hooks/events.ts:467
attemptCount
Section titled “attemptCount”readonly attemptCount: number;Defined in: src/hooks/events.ts:478
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?”optional retry?: boolean;Defined in: src/hooks/events.ts:484
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:516
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;
};
}