refactor(adapters/langgraph): align ManagerWorkers code and tests with codebase style - #32
Merged
spichen merged 1 commit intoAug 2, 2026
Conversation
…h codebase style Trim reviewer-directed comments to codebase density; drop the lru_cache on the delegation-tool factory, the _WorkerSubgraphNode class (now closures) and the dict-or-object tool-call shim. Rewrite the tests to repo conventions: module-level pyagentspec imports, a shared _agent() helper, pytestmark instead of an empty autouse fixture, no section dividers, and behavior-level coverage instead of micro-tests of private helpers. Also fix a real bug the flow-step test exposed: the ManagerWorkers parent graph runs over MessagesState, so a structured_response can never reach the node executor and any declared output raised ValueError. A ManagerWorkers flow step now answers its single string output with the manager's final message, and rejects other output shapes with NotImplementedError.
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.
Cleanup pass over oracle#211, plus one bug fix its own test exposed.
Bug fix: ManagerWorkers as a flow step could not produce its declared output
test_managerworkers_runs_as_a_flow_step_with_data_edge_inputsfails on the PR head: the ManagerWorkers parent graph runs overMessagesState, so the manager subgraph'sstructured_responsenever propagates outward, andextract_outputs_from_invoke_resultfinds nothing — any manager with declared outputs raisedValueError: Expected node ... to have a value for property .... (The fallback the test relies on lives in the unmergedfeat/agent-single-string-outputbranch.)AgentNodeExecutor._format_agent_resultnow answers a ManagerWorkers node's single string output with the manager's final message content, and raisesNotImplementedErrorfor other output shapes.Test cleanup (797 → 421 lines)
pyagentspecimports and a shared_agent()helper instead of ~10 lines ofAgent(...)boilerplate repeated per test; langchain/langgraph imports stay in-function, matchingtest_swarm.py/test_agentnode.py.pytestmark = pytest.mark.usefixtures(...)instead of an empty-bodied autouse fixture._messages_of,_surface_to_parent_command, tool name/description, echo-worker wrapper) — all covered by the end-to-end delegation tests — and merged duplicates (test_normalize_identifierduplicatedtest_safe_node_name; the roster and routing tests are consolidated).astream_events-unwrapped test asserts oncompiled.__dict__instead of patched-function__name__s.Source cleanup
@lru_cacheon the delegation-tool factory, replaced the__slots__class_WorkerSubgraphNodewith closures, removed the_tc_getdict-or-object shim (langchain tool calls are always dicts), and inlined_surface_to_parent_commandinto the delegation tool.gotoinvariant, one-Send-per-delegation, ambient-config namespacing).blackformatting fix for one over-long line in_langgraphconverter.py.Net: −452 lines against the PR head. Verified offline: 17/17 ManagerWorkers tests pass, plus the langgraph flows suite, swarm, tracing/serialization/validation core suites.