AfterToolsEvent
Defined in: src/hooks/events.ts:823
Event triggered after all tools complete execution. Fired after tool results are collected and ready to be added to conversation. Uses reverse callback ordering for proper cleanup semantics.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AfterToolsEvent(data): AfterToolsEvent;Defined in: src/hooks/events.ts:844
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | { agent: LocalAgent; message: Message; invocationState: InvocationState; } & HookableEventData |
Returns
Section titled “Returns”AfterToolsEvent
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: "afterToolsEvent";Defined in: src/hooks/events.ts:824
readonly agent: LocalAgent;Defined in: src/hooks/events.ts:825
message
Section titled “message”readonly message: Message;Defined in: src/hooks/events.ts:826
invocationState
Section titled “invocationState”readonly invocationState: InvocationState;Defined in: src/hooks/events.ts:827
endTurn
Section titled “endTurn”endTurn: string | boolean | ContentBlock[] = false;Defined in: src/hooks/events.ts:842
When set to true, the agent loop halts after this tool batch completes
without calling the model again and a default message
("Turn ended early by hook after tool execution") is appended as the
final assistant message. When set to a string, that string is used instead
of the default — the string becomes literal assistant content (a
TextBlock), not a reason or label. When set to a ContentBlock[], those
blocks become the final assistant message content directly (shallow-copied).
Contrast with cancel fields on other events,
where the string is a cancellation reason.
In all cases stopReason on the returned AgentResult is 'endTurn'.
Methods
Section titled “Methods”toJSON()
Section titled “toJSON()”toJSON(): Pick<AfterToolsEvent, "type" | "message">;Defined in: src/hooks/events.ts:860
Serializes for wire transport, excluding the agent reference, invocationState, and mutable endTurn field. Called automatically by JSON.stringify().
Returns
Section titled “Returns”Pick<AfterToolsEvent, "type" | "message">