How to process interrupts inside a subagent #2777
Replies: 4 comments
-
|
good questions! |
Beta Was this translation helpful? Give feedback.
-
|
same issue |
Beta Was this translation helpful? Give feedback.
-
|
Hi, I'm facing a similar issue on deepagents==0.5.3. Setup: create_deep_agent with AsyncPostgresSaver on the main agent SubAgent triggers interrupt correctly Expected: Root cause (looking at the code): Has this been resolved? If not, what's the current recommended workaround for HITL on side-effecting SubAgent tools? |
Beta Was this translation helpful? Give feedback.
-
|
i am also facing same issue |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a question about handling interrupts inside a SubAgent and preventing duplicate execution of tools.
A SubAgent is wrapped as a tool, and then grouped together with other tools inside a ToolNode. During a single LLM response, if both a SubAgent call and a normal tool call appear, they will run in parallel.
The problem is:
If the SubAgent encounters an interrupt, when the system resumes the execution it seems to re-run the entire ToolNode, which causes all tools (including the normal ones) to run again. How can this be avoided?
For normal tools, I can work around this by moving the interrupt earlier into the
after_modelstage, but for SubAgents I don’t have a way to intercept or shift the interrupt timing. This means I can’t prevent re-execution if the SubAgent is interrupted.Similarly, if the LLM returns multiple SubAgent calls at once, an interrupt in any one of them will cause all SubAgents to be executed again on resume. How can I prevent one SubAgent’s interrupt from causing all other SubAgents to be re-run?
I previously built a deepagents-like framework using LangGraph. Similar to deepagents, I have a main Agent that includes
FileOperate,TodoWrite, andTasktools. Inside theTasktool, I also include several tools (except Task itself).To avoid duplicate executions during interrupt recovery, I had to separate SubAgent tools from normal tools:
after_modelto prevent re-execution.This workaround does prevent duplicated execution, but the whole solution feels very hacky and unnatural. It doesn’t seem like the intended way to deal with SubAgent interrupts, and managing multiple ToolNodes manually is error-prone and hard to maintain.
Is there a more idiomatic or recommended way to handle SubAgent interrupts without separating tools or manually mapping ToolNodes?
Beta Was this translation helpful? Give feedback.
All reactions