[PR #6643] fix(prebuilt): add handle_tool_errors parameter to create_react_agent #5187

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

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/6643

State: closed
Merged: No


Summary

Add handle_tool_errors parameter to create_react_agent with a default of True to maintain backward compatibility. This fixes the issue where tool errors were not being handled by default after version 1.0.1, causing agents to crash instead of returning error messages to the LLM.

The parameter is passed to the internally created ToolNode when tools are provided as a list. If a ToolNode is passed directly, its error handling configuration is preserved.

Changes:

  • Added handle_tool_errors parameter to create_react_agent (defaults to True)
  • Parameter is passed to the internally created ToolNode
  • Added tests for both default behavior and explicit handle_tool_errors=False

This is a generic approach that addresses the underlying issue without hard-coding model-specific response handling.

Fixes #6486

Test plan

  • Added unit test test_handle_tool_errors_default_true that verifies errors are handled by default
  • Added unit test test_handle_tool_errors_false_propagates that verifies errors propagate when disabled
  • Tests pass for both v1 and v2 versions of the react agent
  • Ran make format and make lint successfully
**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/6643 **State:** closed **Merged:** No --- ## Summary Add `handle_tool_errors` parameter to `create_react_agent` with a default of `True` to maintain backward compatibility. This fixes the issue where tool errors were not being handled by default after version 1.0.1, causing agents to crash instead of returning error messages to the LLM. The parameter is passed to the internally created ToolNode when tools are provided as a list. If a ToolNode is passed directly, its error handling configuration is preserved. **Changes:** - Added `handle_tool_errors` parameter to `create_react_agent` (defaults to `True`) - Parameter is passed to the internally created `ToolNode` - Added tests for both default behavior and explicit `handle_tool_errors=False` This is a generic approach that addresses the underlying issue without hard-coding model-specific response handling. Fixes #6486 ## Test plan - [x] Added unit test `test_handle_tool_errors_default_true` that verifies errors are handled by default - [x] Added unit test `test_handle_tool_errors_false_propagates` that verifies errors propagate when disabled - [x] Tests pass for both v1 and v2 versions of the react agent - [x] Ran `make format` and `make lint` successfully
yindo added the pull-request label 2026-02-20 17:51:21 -05:00
yindo closed this issue 2026-02-20 17:51:21 -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#5187