Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(langgraph): Re-throw NodeInterrupt errors from ToolNode for HITL. #718

Merged
merged 3 commits into from
Dec 9, 2024

Conversation

jaredhanson
Copy link
Contributor

This changes ToolNode to always re-throw NodeInterrupt errors, rather than feeding errors back into the agent.

As documented here, the intent of NodeInterrupt is to act as a breakpoint for when a human needs to be brought into the loop. This works as intended when thrown from a step function. However, when wrapped in a ToolNode, the default behavior traps NodeInterrupt and feeds it back to the agent. This is unexpected, since if a human is necessary the agent can't recover on its own.

Furthermore, setting handleToolErrors to false is a way to workaround this, but that then requires the developer to feed all other non-NodeInterrupt errors back manually (which is also unexpected).

The best default behavior seems to be feeding all errors except NodeInterrupt back, and re-throwing NodeInterrupt so the application can handle it appropriately.

I discussed this with @jacoblee93 on an internal Slack channel.

Twitter: @jaredhanson

@jacoblee93 jacoblee93 changed the title Re-throw NodeInterrupt errors from ToolNode for HITL. fix(langgraph): Re-throw NodeInterrupt errors from ToolNode for HITL. Dec 9, 2024
@jacoblee93
Copy link
Collaborator

Thank you!

@jacoblee93 jacoblee93 merged commit 3996017 into langchain-ai:main Dec 9, 2024
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants