[PR #1667] [MERGED] langgraph: expand handle_tool_errors in ToolNode #2219

Closed
opened 2026-02-20 17:46:34 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraph/pull/1667
Author: @isahers1
Created: 9/9/2024
Status: Merged
Merged: 10/23/2024
Merged by: @vbarda

Base: mainHead: isaac/toolnodestuff


📝 Commits (10+)

📊 Changes

2 files changed (+484 additions, -84 deletions)

View changed files

📝 libs/langgraph/langgraph/prebuilt/tool_node.py (+127 -9)
📝 libs/langgraph/tests/test_prebuilt.py (+357 -75)

📄 Description

This change expands error-handling functionality of the ToolNode by introducing more options for handle_tool_errors. Default behavior of the ToolNode is unchanged -- all errors are handled and wrapped in a ToolMessage to be sent back to LLM.

With this change, users have flexibility to only handle the exceptions that they need to pass back to the LLM:

  • they can specify exceptions to handle by passing a tuple of exceptions in handle_tool_errors
  • specify handle_tool_errors=True/str/callable
    • when handle_tool_errors is a callable, the signature will be inspected and exceptions from the signature will be handled

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/langgraph/pull/1667 **Author:** [@isahers1](https://github.com/isahers1) **Created:** 9/9/2024 **Status:** ✅ Merged **Merged:** 10/23/2024 **Merged by:** [@vbarda](https://github.com/vbarda) **Base:** `main` ← **Head:** `isaac/toolnodestuff` --- ### 📝 Commits (10+) - [`a51f4fe`](https://github.com/langchain-ai/langgraph/commit/a51f4fe9ee22fc9c2aff091c9e0ce52042f1fd64) wip - [`a61ee65`](https://github.com/langchain-ai/langgraph/commit/a61ee658039e4a406bef32e312eeed3f94aa9ad1) adding tests - [`a833516`](https://github.com/langchain-ai/langgraph/commit/a833516b67b47b56bcefe65f99c61956b2cac8f3) changes - [`002503c`](https://github.com/langchain-ai/langgraph/commit/002503ca0ac18d6c796b70a85f1aa4a64b2a16f5) Merge branch 'main' into isaac/toolnodestuff - [`2def3eb`](https://github.com/langchain-ai/langgraph/commit/2def3ebf9d672bd4ffa92ab9253b4af4a73ce4d4) simplify - [`f22a302`](https://github.com/langchain-ai/langgraph/commit/f22a3024cd9970155ff90bc8d83ffdd079a42bff) add 'all' + better docstring - [`2b83809`](https://github.com/langchain-ai/langgraph/commit/2b83809a301b6a4303ac6afaac2a26d91aefcb76) update - [`d03c10c`](https://github.com/langchain-ai/langgraph/commit/d03c10c63ec44b092e1c8b7e1a387fe73bbc9e8c) lint - [`1e32adc`](https://github.com/langchain-ai/langgraph/commit/1e32adcafc58ffb8ab3392e8e2f365d30e946866) handle pydantic v1 - [`89e3d00`](https://github.com/langchain-ai/langgraph/commit/89e3d0053f4e229039a9e6bdb63b7303c9ba2bab) more typing ### 📊 Changes **2 files changed** (+484 additions, -84 deletions) <details> <summary>View changed files</summary> 📝 `libs/langgraph/langgraph/prebuilt/tool_node.py` (+127 -9) 📝 `libs/langgraph/tests/test_prebuilt.py` (+357 -75) </details> ### 📄 Description This change expands error-handling functionality of the `ToolNode` by introducing more options for `handle_tool_errors`. Default behavior of the `ToolNode` is unchanged -- all errors are handled and wrapped in a `ToolMessage` to be sent back to LLM. With this change, users have flexibility to only handle the exceptions that they need to pass back to the LLM: * they can specify exceptions to handle by passing a tuple of exceptions in `handle_tool_errors` * specify `handle_tool_errors=True/str/callable` * when `handle_tool_errors` is a callable, the signature will be inspected and exceptions from the signature will be handled --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-20 17:46:34 -05:00
yindo closed this issue 2026-02-20 17:46:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#2219