Predicate controlling whether a given tool call triggers an interrupt.
Receives a ToolCallRequest and returns true to interrupt or false
to auto-approve the tool call.
The request is constructed with tool set to undefined and runtime set to
the node-level Runtime, so it reflects the batch (afterModel) context
rather than a per-call tool execution.
WhenPredicate: z.infer<typeof WhenFunctionSchema>import { type WhenPredicate } from "langchain";
// Only interrupt delete_file calls targeting /etc
const when: WhenPredicate = (request) =>
String(request.toolCall.args.path ?? "").startsWith("/etc");