Skip to content

fix(core): tell agents they can message running subagents - #60045

Merged
rekram1-node merged 1 commit into
devfrom
subagent-steer-docs
Oct 28, 2026
Merged

rekram1-node merged 1 commit into
devfrom
subagent-steer-docs

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When a background subagent is running and the user adds an instruction ("also target the release branch"), agents send it with session_prompt instead of the subagent tool. session_prompt delivers the text, but the parent never gets the subagent's answer back.

The subagent tool already handles this: passing a running child's sessionID steers it mid-task and the parent still gets one completion notification. Nothing in the tool's text said so. The sessionID field only talked about continuing a "previous" conversation, and the background result only said what not to do.

Change

Two lines in packages/core/src/tool/plugin/subagent.ts. The tool description stays as is, so behavior for finished subagents doesn't change.

 background result
   "Work on non-overlapping tasks, or briefly tell the user what you launched and end your response.",
+  "To send it follow-ups or change its instructions while it runs, call subagent again with this sessionID.",

 sessionID
-  "Continue a specific previous subagent conversation by passing its sessionID. Calls without a sessionID start a new conversation.",
+  "Send a follow-up to an existing subagent, running or finished. Omit to start a new one.",

Also adds a test: three follow-ups to a running background child (with and without background: true) all return right away, and the parent gets exactly one completion notification.

Eval

I replayed fixed conversations against each model's API, 10 to 20 runs per cell. Failures when asked to redirect a running background subagent (two phrasings):

model before after
Opus 5.5 13/20 0/20
Gemini 4 Argon 7/20 0/20
Sonnet 5.5 5/20 0/20
Haiku 5.5 12/20 0/20
Sonnet 4.5 20/20 0/20
DeepSeek 20/20 0/20
MiniMax M2.5 20/20 0/40
MiniMax M2 20/20 2/40
Haiku 4.5 20/20 13/40

Checked for over-reuse too: when the user asks for something unrelated, every model still starts a fresh subagent, both while the old one runs and after it finishes. Related follow-ups to a finished explore agent are reused as often as before or more.

Out of scope

  • No change to session_prompt.
  • Haiku 4.5 still picks session_prompt about a third of the time. The wordings that fixed it fully either forbade other tools or made other models worse.

Verification

  • bun test test/tool-subagent.test.ts in packages/core: 12 pass
  • bun typecheck in packages/core: clean

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" stroke="currentColor" stroke-width="1.5" font-family="system-ui, sans-serif" font-size="10">
  <style>
    .msg { animation: send 2.4s ease-in-out infinite; }
    .reply { animation: back 2.4s ease-in-out infinite; }
    @keyframes send { 0%, 10% { transform: translateX(0); opacity: 0 } 20% { opacity: 1 } 45% { transform: translateX(104px); opacity: 1 } 55%, 100% { transform: translateX(104px); opacity: 0 } }
    @keyframes back { 0%, 55% { transform: translateX(0); opacity: 0 } 65% { opacity: 1 } 90% { transform: translateX(-104px); opacity: 1 } 100% { transform: translateX(-104px); opacity: 0 } }
    @media (prefers-reduced-motion: reduce) { .msg, .reply { animation: none; opacity: 1; } .msg { transform: translateX(52px); } .reply { transform: translateX(-52px); } }
  </style>
  <rect x="8" y="20" width="64" height="32" rx="6" opacity="0.8"/>
  <text x="40" y="40" text-anchor="middle" fill="currentColor" stroke="none">parent</text>
  <rect x="168" y="20" width="64" height="32" rx="6" opacity="0.8"/>
  <text x="200" y="40" text-anchor="middle" fill="currentColor" stroke="none">subagent</text>
  <circle cx="190" cy="14" r="3" fill="currentColor" stroke="none" opacity="0.5"/>
  <line x1="76" y1="30" x2="164" y2="30" opacity="0.25"/>
  <line x1="76" y1="44" x2="164" y2="44" opacity="0.25"/>
  <rect class="msg" x="60" y="26" width="16" height="8" rx="2" fill="currentColor" stroke="none" opacity="0.7"/>
  <rect class="reply" x="164" y="40" width="16" height="8" rx="2" fill="currentColor" stroke="none" opacity="0.4"/>
</svg>

Added by the opencode bot (AI-generated).

Related: #38966

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks sound. The new text matches what the tool already does: a follow-up with sessionID goes through the normal prompt path, which redirects a running child, and the call returns straight away with status running. I couldn't test the effect on model behavior because it needs real models; the simulated model can't show tool choice. tool-subagent.test.ts passes (12/12) and typecheck:tsc is clean. The typecheck script fails with "Script not found check" on dev as well, so that failure isn't from this PR.

Public API: unchanged. The tool's input fields are the same; only the wording the model sees changes.

The new test can be dropped (see the inline comment).

Related: #38966

),
)

it.live("follow-ups to a running background child return immediately and notify once", () =>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran this test on dev without the prompt change and it passes there too. It checks behavior that already exists and doesn't touch the new text, so for a two-line wording change it can be dropped to keep the diff minimal.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping it. It passes on dev on purpose: the new text tells models a follow-up to a running background subagent returns right away and still notifies once, so this pins that behavior. If it changes, the prompt would be lying.

@rekram1-node
rekram1-node merged commit 0e10290 into dev Oct 28, 2026
16 checks passed
@rekram1-node
rekram1-node deleted the subagent-steer-docs branch October 28, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant