fix(adapters/langgraph): forward ManagerWorkers delegation task as SystemMessage#24
Merged
Merged
Conversation
…stemMessage The manager's delegated task was forwarded to each worker subgraph as a HumanMessage. Because the worker inherits the parent node's astream_events callbacks, that input message streams out to consumers and renders in the chat UI as a spurious end-user turn — the sub-agent's prompt shown as if the user typed it. Forward the task as a SystemMessage instead: it is the manager's internal instruction to the worker, not an end-user message. The worker is still driven by the task, worker state stays isolated (the top-level snapshot is unchanged), and the OpenAI-compatible models the runtime uses accept a system-only message list. Add a regression test asserting the worker receives its task as a SystemMessage with no HumanMessage in its input.
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.
Problem
When a
ManagerWorkersmanager delegates to a worker, the task was forwarded to the worker subgraph as aHumanMessage. The worker inherits the parent node'sastream_eventscallbacks, so that input message streams out to consumers and renders in the chat UI as a spurious end-user turn — the sub-agent's prompt appears as if the user typed it.The runtime and oi-apps-core faithfully propagate the message role; the
humanclassification originates here, in_wrap_worker_for_subgraph._worker_input.Fix
Forward the delegated task as a
SystemMessageinstead of aHumanMessage— it is the manager's internal instruction to the worker, not an end-user message.ToolMessagereturns to the parent, so the top-level message snapshot is unchanged.Test
Adds
test_worker_receives_its_task_as_a_system_message, which captures the worker model's input and asserts the delegated task arrives as aSystemMessagewith noHumanMessageleaking in.Offline ManagerWorkers / Swarm / Flow-node + serialization suites pass.