Skip to content

AfterToolCallEvent

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

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

new AfterToolCallEvent(data): AfterToolCallEvent;

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

ParameterType
data{ agent: LocalAgent; toolUse: { name: string; toolUseId: string; input: JSONValue; }; tool: Tool; result: ToolResultBlock; invocationState: InvocationState; error?: Error; }
data.agentLocalAgent
data.toolUse{ name: string; toolUseId: string; input: JSONValue; }
data.toolUse.namestring
data.toolUse.toolUseIdstring
data.toolUse.inputJSONValue
data.toolTool
data.resultToolResultBlock
data.invocationStateInvocationState
data.error?Error

AfterToolCallEvent

HookableEvent.constructor

readonly type: "afterToolCallEvent";

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


readonly agent: LocalAgent;

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


readonly toolUse: {
name: string;
toolUseId: string;
input: JSONValue;
};

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

name: string;
toolUseId: string;
input: JSONValue;

readonly tool: Tool;

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


result: ToolResultBlock;

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

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


readonly optional error?: Error;

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


readonly invocationState: InvocationState;

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


optional retry?: boolean;

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

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:309

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; }; }