Feature: interruptible tool handler functions #199

Open
opened 2026-02-15 17:17:12 -05:00 by yindo · 1 comment
Owner

Originally created by @benjamincburns on GitHub (Mar 13, 2025).

Per #975, there are way too many complex concepts to understand if you want to implement a human-in-the-loop process for approving tool calls, especially in the case when you want to allow parallel tool calls and execute all approved tool calls (as opposed to a denial of one call blocking execution of all parallel calls on the AIMessage).

It would be so much nicer if user code could simply call interrupt from within tool handler functions. Doing this today requires extra steps (e.g. fanning out individual tool calls to ToolNode), as otherwise you'll repeat the execution of all previously-approved tool calls on every resume.

A better approach (credit to @hinthornw for the idea) would be if within ToolNode we wrapped calls to tool handler functions with the task decorator from the functional API. This would allow individual tool handlers to interrupt and resume without re-executing other handlers that are running in parallel.

One caveat, however: task currently relies on the node:async_hooks module for AsyncLocalStorage, which isn't available in browser or react native environments. We'll need to address that prior to implementing this feature.

Originally created by @benjamincburns on GitHub (Mar 13, 2025). Per #975, there are way too many complex concepts to understand if you want to implement a human-in-the-loop process for approving tool calls, especially in the case when you want to allow parallel tool calls _and_ execute all approved tool calls (as opposed to a denial of one call blocking execution of all parallel calls on the `AIMessage`). It would be so much nicer if user code could simply call `interrupt` from within tool handler functions. Doing this today requires extra steps (e.g. fanning out individual tool calls to `ToolNode`), as otherwise you'll repeat the execution of all previously-approved tool calls on every resume. A better approach (credit to @hinthornw for the idea) would be if within `ToolNode` we wrapped calls to tool handler functions with the `task` decorator from the functional API. This would allow individual tool handlers to interrupt and resume without re-executing other handlers that are running in parallel. One caveat, however: `task` currently relies on the `node:async_hooks` module for `AsyncLocalStorage`, which isn't available in browser or react native environments. We'll need to address that prior to implementing this feature.
yindo added the enhancement label 2026-02-15 17:17:12 -05:00
Author
Owner

@benjamincburns commented on GitHub (May 8, 2025):

New python API coming that will change how to implement this - goal is good, though

@benjamincburns commented on GitHub (May 8, 2025): New python API coming that will change how to implement this - goal is good, though
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#199