Skip to content

fix(adapters/langgraph): forward ManagerWorkers delegation task as SystemMessage#24

Merged
spichen merged 1 commit into
oi-forkfrom
fix/worker-delegation-system-message
Jul 5, 2026
Merged

fix(adapters/langgraph): forward ManagerWorkers delegation task as SystemMessage#24
spichen merged 1 commit into
oi-forkfrom
fix/worker-delegation-system-message

Conversation

@spichen

@spichen spichen commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Problem

When a ManagerWorkers manager delegates to a worker, the task was forwarded to the worker subgraph as a HumanMessage. The worker inherits the parent node's astream_events callbacks, 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 human classification originates here, in _wrap_worker_for_subgraph._worker_input.

Fix

Forward the delegated task as a SystemMessage instead of a HumanMessage — 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: only a ToolMessage returns to the parent, so the top-level message snapshot is unchanged.
  • Consumers using OpenAI-compatible models accept a system-only message list, so there is no empty-user-turn issue.

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 a SystemMessage with no HumanMessage leaking in.

Offline ManagerWorkers / Swarm / Flow-node + serialization suites pass.

…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.
@spichen spichen merged commit 3017632 into oi-fork Jul 5, 2026
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant