Skip to content

ExecuteToolContext

Defined in: src/middleware/stages.ts:105

Context passed to tool-stage middleware. Contains everything needed to understand and potentially modify the tool call.

readonly agent: LocalAgent;

Defined in: src/middleware/stages.ts:107

The agent instance (escape hatch for advanced use cases).


readonly tool: Tool;

Defined in: src/middleware/stages.ts:109

The resolved tool implementation, or undefined if not found.


readonly toolUse: ToolUseData;

Defined in: src/middleware/stages.ts:111

The tool use request (name, toolUseId, input).


readonly invocationState: InvocationState;

Defined in: src/middleware/stages.ts:113

Per-invocation state shared across hooks and tools.

interrupt<T>(params): MiddlewareInterruptResult<T>;

Defined in: src/middleware/stages.ts:51

Request a human-in-the-loop interrupt.

On first execution (no prior response), throws InterruptError to halt the agent. On resume (after the user provides a response), returns the response wrapped in MiddlewareInterruptResult.

Type ParameterDefault type
TJSONValue
ParameterTypeDescription
paramsInterruptParamsInterrupt parameters (name, optional reason, optional preemptive response)

MiddlewareInterruptResult<T>

The user’s response wrapped in { response: T }

InterruptError when no response has been provided yet

MiddlewareInterruptible.interrupt