AfterToolCallEvent
Defined in: src/hooks/events.ts:298
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).
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AfterToolCallEvent(data): AfterToolCallEvent;Defined in: src/hooks/events.ts:319
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | { agent: LocalAgent; toolUse: ToolUseData; tool: Tool; result: ToolResultBlock; invocationState: InvocationState; error?: Error; } |
data.agent | LocalAgent |
data.toolUse | ToolUseData |
data.tool | Tool |
data.result | ToolResultBlock |
data.invocationState | InvocationState |
data.error? | Error |
Returns
Section titled “Returns”AfterToolCallEvent
Overrides
Section titled “Overrides”Properties
Section titled “Properties”readonly type: "afterToolCallEvent";Defined in: src/hooks/events.ts:299
readonly agent: LocalAgent;Defined in: src/hooks/events.ts:300
toolUse
Section titled “toolUse”readonly toolUse: ToolUseData;Defined in: src/hooks/events.ts:301
readonly tool: Tool;Defined in: src/hooks/events.ts:302
result
Section titled “result”result: ToolResultBlock;Defined in: src/hooks/events.ts:308
The tool result. Can be replaced by hook callbacks to transform the result before it enters the conversation history.
error?
Section titled “error?”readonly optional error?: Error;Defined in: src/hooks/events.ts:310
invocationState
Section titled “invocationState”readonly invocationState: InvocationState;Defined in: src/hooks/events.ts:311
retry?
Section titled “retry?”optional retry?: boolean;Defined in: src/hooks/events.ts:317
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.
Methods
Section titled “Methods”toJSON()
Section titled “toJSON()”toJSON(): Pick<AfterToolCallEvent, "toolUse" | "type" | "result"> & { error?: { message?: string; };};Defined in: src/hooks/events.ts:347
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().
Returns
Section titled “Returns”Pick<AfterToolCallEvent, "toolUse" | "type" | "result"> & {
error?: {
message?: string;
};
}