Skip to content

AfterToolsEvent

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

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.

new AfterToolsEvent(data): AfterToolsEvent;

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

ParameterType
data{ agent: LocalAgent; message: Message; invocationState: InvocationState; }
data.agentLocalAgent
data.messageMessage
data.invocationStateInvocationState

AfterToolsEvent

HookableEvent.constructor

readonly type: "afterToolsEvent";

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


readonly agent: LocalAgent;

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


readonly message: Message;

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


readonly invocationState: InvocationState;

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


endTurn: string | boolean = false;

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

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. Contrast with cancel fields on other events, where the string is a cancellation reason.

In both cases stopReason on the returned AgentResult is 'endTurn'.

toJSON(): Pick<AfterToolsEvent, "type" | "message">;

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

Serializes for wire transport, excluding the agent reference, invocationState, and mutable endTurn field. Called automatically by JSON.stringify().

Pick<AfterToolsEvent, "type" | "message">