[PR #2957] feat: Add state-modifying retry policies #2998

Open
opened 2026-02-20 17:47:55 -05:00 by yindo · 0 comments
Owner

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

State: open
Merged: No


Add state-modifying retry policies

Description

This PR adds support for state-modifying retry policies by allowing a dictionary mapping of exceptions to state-modifying functions in the RetryPolicy class. This enhancement enables users to modify the workflow state before retry attempts based on specific exceptions.

I think this feature can be very usefull as I am not the only one who needs it. See this discussion

Changes

  • Extended RetryPolicy's retry_on parameter to accept dict[Type[Exception], Callable[[Any, Exception], None]]
  • Updated type hints and documentation
  • Added tutorial section explaining the new functionality

Tests

I have not added a test for this feature as I did not find a a fitting file name for this case and did not want to make my own test file.
If needed I can add a test for this new feature, I would appreciate guidance on the preferred location for adding tests.

All existing tests pass.

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/2957 **State:** open **Merged:** No --- # Add state-modifying retry policies ## Description This PR adds support for state-modifying retry policies by allowing a dictionary mapping of exceptions to state-modifying functions in the RetryPolicy class. This enhancement enables users to modify the workflow state before retry attempts based on specific exceptions. I think this feature can be very usefull as I am not the only one who needs it. See [this discussion](https://github.com/langchain-ai/langgraph/discussions/1175#discussioncomment-10518271) ## Changes - Extended `RetryPolicy`'s `retry_on` parameter to accept `dict[Type[Exception], Callable[[Any, Exception], None]]` - Updated type hints and documentation - Added tutorial section explaining the new functionality ## Tests I have not added a test for this feature as I did not find a a fitting file name for this case and did not want to make my own test file. If needed I can add a test for this new feature, I would appreciate guidance on the preferred location for adding tests. All existing tests pass.
yindo added the pull-request label 2026-02-20 17:47:55 -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#2998