Repository navigation
fix(agents): sub-agent turns can ship narration as the final reply before work finishes - #301
Merged
Merged
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Heads up: you’re close to your included review allowance. Set a flex budget so reviews don’t pause.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
LGTM! Approved. Detailed review:
Evidence Map
- Surface:
src/agents/embedded-agent-runner/run.ts,incomplete-turn.ts, unit & integration tests. - Entry point:
runEmbeddedAgentInternalloop prior to finalize. - Owner boundary: Embedded agent runner incomplete-turn safety.
- Callers & Callees: Calls
resolveImplicitYieldContinuationInstruction, checkinghasLivePendingAcceptedSessionSpawnagainst the subagent registry. - Sibling surfaces: Perfectly aligns with the existing
resolveSettledToolContinuationInstructionpattern. - Tests: 13 unit tests + 3 integration tests covering positive, completed-child, explicit-yield, and edge cases. Verified all 138 tests pass locally.
Clean implementation and all cubic review comments have been properly addressed.
inassjunus
approved these changes
Oct 21, 2026
…b-agent spawn (ENG-21585) A turn that spawns a sub-agent (sessions_spawn is fire-and-forget) and then ends with plain narration instead of calling sessions_yield shipped that narration as the final reply while the sub-agent's real result was still in flight. doc-conversion hit this: the agent dispatched OCR sub-agents, wrote "Reading title block and notes tiles.", and that status line was delivered as the answer instead of the transcribed content. Add resolveImplicitYieldContinuationInstruction (incomplete-turn.ts): when an attempt is about to finalize with visible narration, a live sub-agent accepted this turn, and no explicit yield, force one bounded continuation instructing the model to call sessions_yield for real. This reuses the existing settled-tool-continuation pattern and produces a genuine tool call (not synthesized metadata), so plugin hooks and the eval harness's own yield detection see it the same way an explicit yield would. hasLivePendingAcceptedSessionSpawn (run.ts) scopes the check to this turn's own accepted spawns via the subagent registry, so an unrelated already-settled descendant never forces a continuation. Tests: 8 new unit tests covering every branch of the resolver, plus 2 new integration tests through the real runEmbeddedAgent loop (TDD'd red/green). 132/132 passing in the touched files; pnpm tsgo clean. Linear: ENG-21585 Co-Authored-By: Claude Opus 5 <[email protected]>
- Fix a real CI type error: test file imported a nonexistent AssistantMessage export from runtime/index.js; use EmbeddedRunAttemptResult["currentAttemptAssistant"] instead, matching this file's established pattern. - Gate the forced continuation on sessions_yield actually being in the turn's visible tool set (attempt.visibleToolNames) — some tool profiles expose sessions_spawn without sessions_yield, and forcing an unfollowable instruction wastes the one-shot retry. - Correct the registry-miss semantics: a missing row means the run already ended and was cleaned up (registerSubagentRun always runs before sessions_spawn returns "accepted", so there's no register-vs-read race to defend against), not that registration is still landing. Flip the check accordingly and add integration coverage for both the live-and-pending and gone-and-done cases. - Fix a broken compile-time type assertion in the test file (the old ternary silently widened to `never` on a mismatch instead of erroring); use an AssertTrue<T extends true> constraint instead. - Add missing unit coverage for the lastToolError, clientToolCalls, didSendDeterministicApprovalPrompt, and committed-media-delivery suppression guards. - Drop Linear ticket references from code comments and a test title per repo convention; trim comments to the shape this file's siblings use. All touched-file tests green (13 unit + 125 integration), pnpm tsgo and pnpm check:test-types both clean. Co-Authored-By: Claude Opus 5 <[email protected]>
convyusboy
force-pushed
the
worktree-polished-mixing-popcorn
branch
from
October 21, 2026 12:46
554e22d to
e26342d
Compare
convyusboy
added a commit
that referenced
this pull request
Oct 26, 2026
* chore(release): bump version 2026.6.35-boon.1 -> 2026.6.35-boon.2 Cuts the fork release covering the 9 PRs merged to boon since v2026.6.35-boon.1: #298 (ENG-21265) stuck-generation cut-off retry + sub-agent spawn backstop, #299 workspaceDir threading through outbound channel media adapters, #304 (ENG-19208) real inbound media path in the system prompt, #301 (ENG-21585) forced sessions_yield on narrated sub-agent turns, #305 message-tool source reply observed outside message_tool_only, #306 (ENG-19103) reasoning-stream callbacks honor message_tool_only, #303 sub-agent/completion-turn usage attribution, #302 clears 7 high-severity pnpm-audit-prod advisories, #300 (ENG-21588) boon-estimation trajectory label detail. Bump root package.json/npm-shrinkwrap.json, all bundled plugin manifests, and the version + openclaw peer floor in every extension npm-shrinkwrap.json. Add the 2026.6.35-boon.2 CHANGELOG.md section. No additional dependency or source changes beyond what already shipped in #299 and #302. Co-Authored-By: Claude Sonnet 5 <[email protected]> * docs(changelog): fold PR #309's advisory fixes into the 2026.6.35-boon.2 entry --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
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.
Closes: https://linear.app/getboon/issue/ENG-21585
What Problem This Solves
Fixes an issue where a turn that delegates work to a sub-agent (e.g. OCR/doc-conversion fan-out) could reply to the user with a mid-turn status line instead of the real answer, while the sub-agent's actual result was still in flight. This surfaced on the
doc-conversioneval scenario (run 39192943221): the agent dispatched two OCR sub-agents (notes_keynotes,title_block), then ended its turn with "Reading title block and notes tiles." instead of callingsessions_yield— and that narration was delivered as the final reply.Why This Change Was Made
sessions_spawnis documented as fire-and-forget: it returns{status: "accepted"}immediately and the child runs out-of-band. The contract for "my answer depends on this child" is that the model callssessions_yieldto pause the turn, but nothing in the runtime enforced that — a model that forgot to yield had its narration promoted straight to the final answer.This adds a runtime backstop:
resolveImplicitYieldContinuationInstruction(run/incomplete-turn.ts) detects a turn about to finalize with visible narration, a sub-agent accepted this turn that is still live (checked via the subagent registry, scoped to just this turn's spawns so an unrelated already-settled descendant never triggers it), and no explicit yield — and forces one bounded continuation instructing the model to callsessions_yieldfor real. It reuses the existing settled-tool-continuation pattern (same shape asresolveSettledToolContinuationInstruction) rather than synthesizing fake tool-call evidence, so the forced yield is a genuine tool call that pluginafter_tool_callhooks and the eval harness's own yield detection see identically to an explicit one. Capped at one continuation attempt, same as the sibling patterns in this file.Not harness-restricted (unlike the settled-tool continuation):
sessions_spawn/sessions_yieldare ordinary catalog tools any harness can call, and the race this guards against is a model-behavior gap, not a harness-specific one.User Impact
A turn that spawns a sub-agent and forgets to yield now gets resumed to actually wait for and deliver the sub-agent's real result, instead of shipping a stub status line as the answer.
Evidence
resolveImplicitYieldContinuationInstruction(src/agents/embedded-agent-runner/run/incomplete-turn.test.ts), TDD'd red → green.runEmbeddedAgentloop (src/agents/embedded-agent-runner/run.incomplete-turn.test.ts): one reproducing the doc-conversion shape (narration over a live spawn → forced yield continuation), one confirming an explicitsessions_yieldis left alone.node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.incomplete-turn.test.ts src/agents/embedded-agent-runner/run/incomplete-turn.test.ts— 132/132 passing.pnpm tsgo(core) — clean.Follow-up (not in this PR)
The scenario's own header comment ("HOURLY smoke set... pages the on-call responders") and the ticket's "hourly P0" framing are stale: both the hourly and the 6/12h scheduled cadences for
agent-regression.ymlwere cut on 2026-10-14 (now weekly-full + manual dispatch only). Flagging on the Linear ticket separately; not touched here to keep this PR scoped to the runtime fix.🤖 Generated with Claude Code
Summary by cubic
Fixes a race where a turn that spawns a sub-agent (for example, OCR/doc-conversion fan-out) and forgets to call
sessions_yieldshipped its mid-turn narration as the final answer while the sub-agent's real result was still in flight. The runtime now forces one boundedsessions_yieldcontinuation whenever a turn finalizes with visible narration and a sub-agent spawned this turn is still live, so the sub-agent's actual result is delivered instead of the status line. Closes ENG-21585.sessions_yieldis in the turn's visible tool set, so the model has a way to comply.sessions_yieldtool call, so pluginafter_tool_callhooks and eval harness yield detection see it identically to an explicit call.sessions_yieldis left untouched.Written for commit e26342d. Summary will update on new commits.