[PR #4934] Fix timeout parent command #4153

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

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

State: closed
Merged: No


Fix Timeout Handling for Parent Commands

Problem

Setting step_timeout on a supervisor agent was causing ParentCommand errors during agent handoffs. This occurred because the timeout mechanism was interrupting the handoff process before it could complete properly.

Solution

Implemented a specialized timeout handler that properly manages parent commands during timeouts. The new handler allows parent commands to propagate even when a timeout occurs, ensuring smooth agent handoffs while maintaining timeout functionality for other cases.

Changes

  1. Added new timeout.py module:

    • Introduced with_timeout function for specialized timeout handling
    • Properly handles parent commands during timeouts
    • Maintains normal timeout behavior for non-handoff cases
  2. Modified runner integration:

    • Updated runner to use the new timeout handler
    • Ensures proper propagation of parent commands
    • Maintains existing timeout functionality for regular tasks
  3. Added comprehensive test suite:

    • Basic timeout functionality
    • Parent command propagation during timeouts
    • Agent handoff scenarios
    • Sequential and concurrent execution cases
    • Task cancellation verification

Testing

All tests can be run using:

cd libs/langgraph && uv run pytest tests/test_timeout.py -v

Additional Notes

  • No changes to external APIs or interfaces
  • Maintains backward compatibility
  • No new dependencies added
**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/4934 **State:** closed **Merged:** No --- # Fix Timeout Handling for Parent Commands ## Problem Setting `step_timeout` on a supervisor agent was causing `ParentCommand` errors during agent handoffs. This occurred because the timeout mechanism was interrupting the handoff process before it could complete properly. ## Solution Implemented a specialized timeout handler that properly manages parent commands during timeouts. The new handler allows parent commands to propagate even when a timeout occurs, ensuring smooth agent handoffs while maintaining timeout functionality for other cases. ## Changes 1. Added new `timeout.py` module: - Introduced `with_timeout` function for specialized timeout handling - Properly handles parent commands during timeouts - Maintains normal timeout behavior for non-handoff cases 2. Modified runner integration: - Updated runner to use the new timeout handler - Ensures proper propagation of parent commands - Maintains existing timeout functionality for regular tasks 3. Added comprehensive test suite: - Basic timeout functionality - Parent command propagation during timeouts - Agent handoff scenarios - Sequential and concurrent execution cases - Task cancellation verification ## Testing All tests can be run using: ```bash cd libs/langgraph && uv run pytest tests/test_timeout.py -v ``` ## Additional Notes - No changes to external APIs or interfaces - Maintains backward compatibility - No new dependencies added
yindo added the pull-request label 2026-02-20 17:49:45 -05:00
yindo closed this issue 2026-02-20 17:49:45 -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#4153