BeforeToolsEvent
Defined in: src/hooks/events.ts:688
Event triggered before executing tools. Fired when the model returns tool use blocks that need to be executed. Hook callbacks can set cancel to prevent all tools from executing.
Extends
Section titled “Extends”Implements
Section titled “Implements”Interruptible
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BeforeToolsEvent(data): BeforeToolsEvent;Defined in: src/hooks/events.ts:701
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | { agent: LocalAgent; message: Message; invocationState: InvocationState; } |
data.agent | LocalAgent |
data.message | Message |
data.invocationState | InvocationState |
Returns
Section titled “Returns”BeforeToolsEvent
Overrides
Section titled “Overrides”Properties
Section titled “Properties”readonly type: "beforeToolsEvent";Defined in: src/hooks/events.ts:689
readonly agent: LocalAgent;Defined in: src/hooks/events.ts:690
message
Section titled “message”readonly message: Message;Defined in: src/hooks/events.ts:691
invocationState
Section titled “invocationState”readonly invocationState: InvocationState;Defined in: src/hooks/events.ts:692
cancel
Section titled “cancel”cancel: string | boolean = false;Defined in: src/hooks/events.ts:699
Set by hook callbacks to cancel all tool calls.
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.
Methods
Section titled “Methods”interrupt()
Section titled “interrupt()”interrupt<T>(params): T;Defined in: src/hooks/events.ts:716
Raises an interrupt for human-in-the-loop workflows. If a response is available (from a previous resume), returns it immediately. Otherwise, throws an InterruptError to halt agent execution.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T | JSONValue |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
params | InterruptParams | Interrupt parameters including name and optional reason |
Returns
Section titled “Returns”T
The user’s response when resuming from an interrupt
Implementation of
Section titled “Implementation of”Interruptible.interrupttoJSON()
Section titled “toJSON()”toJSON(): Pick<BeforeToolsEvent, "type" | "message">;Defined in: src/hooks/events.ts:724
Serializes for wire transport, excluding the agent reference, invocationState, and mutable cancel flag. Called automatically by JSON.stringify().
Returns
Section titled “Returns”Pick<BeforeToolsEvent, "type" | "message">