[PR #6877] fix(langgraph): allow implicit END in conditional path_map routing #5371

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

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

State: open
Merged: No


Description

Fixes a runtime crash when a conditional router returns END ("__end__") but the provided path_map does not explicitly include an END mapping.

Previously, BranchSpec._finish indexed self.ends[result] directly, which raised KeyError('__end__').

This change:

  • treats END as a built-in terminal destination even when omitted from path_map
  • preserves existing Send behavior
  • raises a clearer ValueError for truly unknown branch targets
  • adds sync and async regression tests for implicit END handling
  • adds a small repro script at libs/langgraph/reproduce_issue.py

Issue

Closes #6770

Dependencies

None

Twitter handle

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/6877 **State:** open **Merged:** No --- ## Description Fixes a runtime crash when a conditional router returns `END` (`"__end__"`) but the provided `path_map` does not explicitly include an END mapping. Previously, `BranchSpec._finish` indexed `self.ends[result]` directly, which raised `KeyError('__end__')`. This change: - treats `END` as a built-in terminal destination even when omitted from `path_map` - preserves existing `Send` behavior - raises a clearer `ValueError` for truly unknown branch targets - adds sync and async regression tests for implicit END handling - adds a small repro script at `libs/langgraph/reproduce_issue.py` ## Issue Closes #6770 ## Dependencies None ## Twitter handle
yindo added the pull-request label 2026-02-20 17:51:37 -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#5371