Skip to content

AfterToolCallEvent

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

Event triggered after a tool execution completes. Fired after tool execution finishes, whether successful or failed. Uses reverse callback ordering for proper cleanup semantics.

Hook callbacks can mutate result to rewrite the tool result before it propagates to the model (e.g. to redact or truncate output).

new AfterToolCallEvent(data): AfterToolCallEvent;

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

ParameterType
data{ agent: LocalAgent; toolUse: ToolUseData; tool: Tool; result: ToolResultBlock; invocationState: InvocationState; error?: Error; } & HookableEventData

AfterToolCallEvent

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

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


readonly agent: LocalAgent;

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


readonly toolUse: ToolUseData;

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


readonly tool: Tool;

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


result: ToolResultBlock;

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

The tool result. Can be replaced by hook callbacks to transform the result before it enters the conversation history.


readonly error?: Error;

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


readonly invocationState: InvocationState;

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


retry?: boolean;

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

Optional flag that can be set by hook callbacks to request a retry of the tool call. When set to true, the agent will re-execute the tool.

toJSON(): Pick<AfterToolCallEvent, "toolUse" | "type" | "result"> & {
error?: {
message?: string;
};
};

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

Serializes for wire transport, excluding the agent reference, tool instance, invocationState, and mutable retry flag. Converts Error to an extensible object for safe wire serialization. Called automatically by JSON.stringify().

Pick<AfterToolCallEvent, "toolUse" | "type" | "result"> & { error?: { message?: string; }; }