feat(adapters/langgraph): support ManagerWorkers and Swarm orchestration - #19
Closed
spichen wants to merge 1 commit into
Closed
feat(adapters/langgraph): support ManagerWorkers and Swarm orchestration#19spichen wants to merge 1 commit into
spichen wants to merge 1 commit into
Conversation
spichen
force-pushed
the
feat/swarm-adapter
branch
3 times, most recently
from
June 30, 2026 13:32
12d06f6 to
7875c24
Compare
Compile a ManagerWorkers spec into a hierarchical LangGraph (manager react-agent + worker subgraphs wired via synthesized delegate_to_<worker> tools), run a ManagerWorkers as a flow step, and let a ManagerWorkers participate as a Swarm member (handoff re-emitted at the MW parent boundary so Command(graph=PARENT) jumps reach the Swarm). Includes the supporting middleware plumbing: forward LangChain agent middleware from the AgentSpecLoader/converter through create_agent and every nested conversion path (agents, flow nodes, MW, swarm). Delegation protocol is hidden from astream_events, worker events stream under the worker node, every delegation in a turn is answered, and delegate tool-calls are stripped from state snapshots.
spichen
force-pushed
the
feat/swarm-adapter
branch
from
June 30, 2026 14:15
7875c24 to
a6f62a2
Compare
Owner
Author
|
Superseded by a three-PR stack — same change, split for reviewability:
The tip of #31 is byte-identical to this branch's head ( Why split this way: The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds LangGraph-adapter support for multi-agent orchestration on top of the existing
ManagerWorkers/Swarmspec types:delegate_to_<worker>tools. The manager's tool call is intercepted by the parent graph's conditional edge, which fans out oneSendper delegation so a single turn can delegate to several workers at once; each worker runs in an isolated message context and replies with aToolMessagematched to itstool_call_id. Recursive ManagerWorkers compose for free.AgentNodewhose agent is aManagerWorkersruns as a hierarchical graph overMessagesState; node inputs are rendered into the group-manager prompt.ManagerWorkersnow infers its inputs/outputs from its group manager so data-flow edges resolve.Command(graph=PARENT)from inside a ManagerWorkers only reaches the ManagerWorkers graph, so handoff is re-emitted at the MW parent boundary via a__handoff__node, keeping the Swarm transcript a valid tool-call/result sequence.AgentSpecLoader/converter throughcreate_agentand every nested conversion path (agents, flow nodes, MW, swarm).astream_events(tool calls, their lifecycle events, and the worker's reply ToolMessage) without touching graph state, so the manager's react loop is unaffected and the workers' real token events still stream.Structure
The MW/Swarm compilation subsystem (constants, delegation/handoff tool builders, routing, worker-subgraph wrapping, and the astream_events scrubber) lives in its own
_managerworkers.pymodule rather than bloating_langgraphconverter.py; the two_*_convert_to_langgraphmethods stay on the converter alongside their siblings.Testing
SKIP_LLM_TESTS=1): helpers, routing precedence, the handoff node, delegation event scrubbing, and the middleware-forwarding contract.black/isort/pyflakesclean on the changed adapter modules.