feat(langgraph): supports calling (multiple) handoffs and non-handoff tools at the same time #6232
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This PR extends ToolNode to support executing non-handoff tools in parallel while treating handoff tool calls (handoff_prefix, default "transfer_to") with special handling. Specifically:
Non-handoff tool calls are executed concurrently (threadpool or asyncio).
Multiple handoff calls are detected: only the first one is processed; subsequent ones are ignored with an error message.
Handoff calls can incorporate previous tool outputs into their state.messages.
Added error handling via a custom tool_error_handler, with explicit handling of AtaConnectionKickedOffError.
In chat_agent_executor, introduced a v3 mode to forward all tool_calls together, distinguishing handoffs more cleanly.
This improves agent flexibility in scenarios where multiple tool invocations and handoff operations need to be coordinated in the same step.
Issue:
N/A (new feature; not tied to a specific issue, but can help agent developers who need multi-tool and handoff orchestration).
Dependencies:
No new external dependencies introduced.
Reuses existing LangGraph execution utilities (get_executor_for_config, _run_one, _arun_one).
Tests & Docs: