Repository navigation
fix(core): tell agents they can message running subagents - #60045
Conversation
There was a problem hiding this comment.
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", () => |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Problem
When a background subagent is running and the user adds an instruction ("also target the release branch"), agents send it with
session_promptinstead of the subagent tool.session_promptdelivers the text, but the parent never gets the subagent's answer back.The subagent tool already handles this: passing a running child's
sessionIDsteers it mid-task and the parent still gets one completion notification. Nothing in the tool's text said so. ThesessionIDfield 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.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):
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
session_prompt.session_promptabout 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.tsinpackages/core: 12 passbun typecheckinpackages/core: cleanVisual
Added by the opencode bot (AI-generated).
Related: #38966