Skip to content

BeforeToolCallEvent

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

Event triggered just before a tool is executed. Fired after tool lookup but before execution begins. Hook callbacks can set cancel to prevent the tool from executing.

new BeforeToolCallEvent(data): BeforeToolCallEvent;

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

ParameterType
data{ agent: LocalAgent; toolUse: { name: string; toolUseId: string; input: JSONValue; }; tool: Tool; }
data.agentLocalAgent
data.toolUse{ name: string; toolUseId: string; input: JSONValue; }
data.toolUse.namestring
data.toolUse.toolUseIdstring
data.toolUse.inputJSONValue
data.toolTool

BeforeToolCallEvent

HookableEvent.constructor

readonly type: "beforeToolCallEvent";

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


readonly agent: LocalAgent;

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


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

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

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

readonly tool: Tool;

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


cancel: string | boolean = false;

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

Set by hook callbacks to cancel this tool call. When set to true, a default cancel message is used. When set to a string, that string is used as the tool result error message.