Repository navigation
[ENG-20103] fix(sessions): agent forgets a sub-agent's result after the completion run answers through the message tool - #225
Conversation
…ry mirror A sub-agent completion run that answers through the message tool ends with a leaf control that points at the merging manager's own leaf. When that manager is behind a peer run on the same transcript, the row moves the active branch back to the pre-run yield marker and every later prompt loses the completion exchange; the agent then tells the user the sub-agent is still running. Skip the navigation write when a merged transcript row or opaque link has a parent this manager never saw. Such a row proves the manager's leaf is stale, so the file keeps its natural leaf. Merges whose rows descend from the lane's own leaf still write the restoring control, so delivery mirrors stay out of the prompt as before. ENG-20103
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
/cr |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
cubic analysis
All reported issues were addressed across 2 files
Linked issue analysis
Linked issue: ENG-20103: Boon Agent: agent forgets a sub-agent's completed result on the next turn after answering through the message tool
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | After a message-tool sub-agent completion, the next compiled context contains the completion prompt and agent reply. | The PR reports a live verification where the next prompt compiled the completion prompt and result; the regression test also verifies the peer turn remains in rebuilt context. |
| ✅ | Asking what the sub-agent reported returns the reported result rather than saying it is still running. | The PR reports a live follow-up prompt receiving the exact reported text and time. |
| ✅ | Delivery mirror rows written after a visible reply remain out of model context. | The change preserves the restoring leaf for healthy merges and the regression setup models a delivery mirror whose visible peer reply remains active while the mirror is not made part of the context. |
| Ordinary turns and completion runs ending with sessions_yield behave as before. | The PR explicitly states these paths are unchanged and reports broad related test suites passing, but the provided diff does not add focused coverage for both ordinary turns and sessions_yield completion runs. | |
| ✅ | A regression test reproduces the lost-context transcript shape and fails on the current fork. | A targeted test constructs the yield marker, peer completion turn, and delivery mirror, and the PR provides the pre-fix assertion failure and passing result after the fix. |
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
augusteo
left a comment
There was a problem hiding this comment.
Review — APPROVE (augusteo / Samwise sweep)
ENG-20103 — fix(sessions): sub-agent result forgotten after completion run answers through the message tool
Correctness ✅
- The drift detection is ordered correctly:
isKnownMergeParentId(sourceEntry.parentId)is evaluated against the entry's original parent before the entry is reparented tosideBranchParentIdand inserted intobyId, so a mirror whose parent is a peer-run row flags drift exactly as intended, while batch-internal chains (later rows parented to earlier rows in the same merge) resolve as known because earlier entries land inbyIdas the loop proceeds. - Global metadata (
custom,label,session_info) is correctly excluded from the drift check — those resolve outside the active branch, matching the PR description. - The guard at the persist gate skips only the
leafnavigation write; the in-memory merge,opaqueParentsByIdbookkeeping, andpromptReleasedSideBranchParentIdadvancement all still run, so subsequent merges chain correctly off the merged rows. - Extending
sawUnknownMergeParentto the unresolved-leaf-control path (!leafState) is the right conservative call — if a merged navigation control can't be resolved, writing our own restoring control on top would be guessing. - Healthy-merge behavior preserved: a mirror parented to the lane's own assistant row still satisfies
isKnownMergeParentId, so the restoring leaf write and the existing "side delivery stays out of the prompt" behavior (covered by the pre-existing test just above) are unchanged.
Tests ✅
- The new test reproduces the exact production scenario end-to-end: yield marker → peer run appends a full turn → mirror merged with
persistLeaf: true→ asserts noleafrow is written, the reopened session's leaf is not the stale yield marker, the peer turn is visible inbuildSessionContext(), and the follow-up user turn descends frompeer-mirror. Strong coverage.
Security ✅
- No user-input handling, no new persistence surface beyond skipping a write. Nothing to flag.
Notes (non-blocking)
- Most CI check-runs were still
queuedat review time (the completed ones are green) — worth confirming the suite goes green before merge. - Acknowledged non-goal: transcripts already carrying a stale
leafrow aren't repaired by this; stops new ones only. Fine as scoped.
Clean, minimal, well-reasoned fix. Approving on 6224b909.
augusteo
left a comment
There was a problem hiding this comment.
Review: ENG-20103 — completion-run leaf reset (#225)
Verdict: Approve. Covers head 6224b909 specifically (cubic's pass reviewed 0a214cf2; the delta since is +13 lines of extra test assertions only).
What I verified in code (not just the diff)
- The merge-batch shape the fix relies on is the designed one.
classifyPromptReleasedSessionLines(attempt.session-lock.ts) only accepts transcript-only assistant rows (delivery-mirror/gateway-injected) as mergeable message lines when not validating owned writes; a peer run's regular user/assistant rows are intentionally not mergeable through this path. So "the mirror is the only row this manager merges, with a parent it has never seen" is the real production shape, and the test models it faithfully. - The guard can only suppress a navigation write, never corrupt data. Merged entries are pushed/indexed regardless; only the restoring
leafcontrol is skipped. A missed detection degrades to the old behavior, not a new failure mode. - Healthy merges stay pinned. The existing
applies merged leaf controls across separate callbacks/ side-delivery tests assert the restoring control is still written when the mirror's parent is the lane's own reply, and the mirror stays out of context. 96/96 session-manager tests pass locally (see below). - Skipping the leaf write cannot leak the mirror into model context. The natural leaf becomes the mirror row (it has no
appendMode:"side"— confirmed the writer at transcript-append.ts:698 only marks side when the file is already in side mode), but the prompt path drops transcript-only assistant rows vianormalizeAssistantReplayContent(attempt.ts:4780) keyed on theopenclaw/delivery-mirrormarker, independent of branch position. - Intra-batch chains don't false-positive:
byIdis updated as the loop progresses, so a batch containing its own ancestors resolves. Global metadata rows (custom/label/session_info) are correctly excluded — they resolve outside the active branch. The newsawUnknownMergeParent = trueon unresolvable peer leaf controls is consistent: an unresolvable navigation target means the peer navigated somewhere this manager can't see. - RED-GREEN verified locally: the new test fails against base
session-manager.tswith exactly the PR's reported assertion (aleafrow targeting the yield marker is written), and passes with the fix.
Local verification
session-manager.test.ts(+ matched sibling): 96 passedattempt.session-lock.test.ts,transcript.test.ts,transcript-tree.test.ts,session-file-repair.test.ts,session-transcript-runtime.test.ts,replay-history.test.ts(+ matched siblings): 399 passed / 8 files- Reviewed at
6224b909; worktree installpnpm install --frozen-lockfile, vitest run on the touched suites. - CI status is not independently verifiable from this token (check-runs 403) — taking the reported green as stated. Review posts as
augusteo.
One open question (non-blocking)
The expectedPublishedEntries path sets allowAnyMessage: true (attempt.session-lock.ts:790), so same-process owned writes can merge regular peer rows. If a peer completion run shares the gateway process and its turn rows + mirror ever arrive in one validated batch, every parent resolves intra-batch and the restoring leaf would still be written targeting the stale leaf. Was that path ruled out for the Boon Web topology (e.g. the peer turn always arrives via requiresReload/full reload instead)? If reachable, it may be worth a follow-up — not a blocker for this fix, which addresses the observed incident shape.
Nits (non-blocking)
- None. The stated non-goals (no repair of already-damaged transcripts, stale-lane full-rewrite path unchanged) are accurately scoped.
Routine release chore for the next train. Root package.json to 2026.6.11-boon.44, plugin package.json files synced via scripts/sync-plugin-versions.ts, changed npm-shrinkwrap.json files regenerated via scripts/generate-npm-shrinkwrap.mjs --changed, and a CHANGELOG.md section for boon.44. Ships #225 (ENG-20103), #224, #228 (ENG-20090) and #227. No separately published plugin source changed since boon.43 (#227 moves diagnostics-otel into the gateway bundle), so a gateway roll delivers the whole release.
…226) Routine release chore for the next train. Root package.json to 2026.6.11-boon.44, plugin package.json files synced via scripts/sync-plugin-versions.ts, changed npm-shrinkwrap.json files regenerated via scripts/generate-npm-shrinkwrap.mjs --changed, and a CHANGELOG.md section for boon.44. Ships #225 (ENG-20103), #224, #228 (ENG-20090) and #227. No separately published plugin source changed since boon.43 (#227 moves diagnostics-otel into the gateway bundle), so a gateway roll delivers the whole release.
Related: ENG-20103 (https://linear.app/getboon/issue/ENG-20103)
What Problem This Solves
Fixes an issue where a user who delegates work to a sub-agent in Boon Web chat would, on the next prompt, be told the sub-agent "is still running" or "never sent a completion signal" even though the agent had already posted the result to the thread.
The trigger is a sub-agent completion run that answers through the
messagetool. Right after that run ends, the session transcript receives aleafcontrol row whose target is thesessions_yieldmarker written before the run. Every later prompt is then compiled from that stale branch, so the completion prompt, the model's answer and the delivery mirror are invisible to the model. Observed onv2026.6.11-boon.40in a paid Boon Web environment: four completion runs out of four that used themessagetool were side-branched; the two that ended withsessions_yieldwere kept.Why This Change Was Made
SessionManager.mergePromptReleasedSessionEntriespersists aleafcontrol that always points at the merging manager's own in-memory leaf. When the lane that merges a delivery mirror is behind a peer run that already appended a whole turn to the same file, that row moves the file's active branch back to the stale leaf and hides the peer run's turn.The merge now tracks whether any merged transcript row, or opaque link, has a parent this manager has never seen. Such a row proves the manager's leaf is no longer the file's active leaf, so the navigation write is skipped and the file keeps its natural leaf. Healthy merges are unchanged: a mirror whose parent is the lane's own assistant row still gets the restoring control, so delivery mirrors stay out of the prompt as before. Global metadata rows (
custom,label,session_info) are excluded from the check because they resolve outside the active branch.Non-goals: no repair of transcripts already carrying a stale
leafrow; the fix stops new ones. The stale-lane full-rewrite path (getPersistedFileEntries) is not changed; no rewrite appears in the incident transcript.User Impact
After a sub-agent reports back in Boon Web, the agent remembers that exchange on later turns. No change for ordinary turns, for completion runs that end with
sessions_yield, or for how delivery mirrors are kept out of the model context.Evidence
Unit test
keeps a peer run's turn active when merging a later delivery mirrorinsession-manager.test.tsreproduces the production row shape (yield marker, peer user and assistant rows appended by another run, then the peer's delivery mirror merged withpersistLeaf: true).Without the fix:
With the fix:
src/agents/sessions/session-manager.test.tssrc/agents/embedded-agent-runner/run/attempt.session-lock.test.tstranscript.test.ts,transcript-tree.test.ts,session-file-repair.test.ts,session-transcript-runtime.test.ts,replay-history.test.tspnpm tsgo, oxlint andformat:checkon touched files,pnpm check:test-typesBefore / After
Before (
v2026.6.11-boon.40, paid Boon Web, two sub-agents; the first one reported at 5:42 PM):After (this branch, fresh thread, same prompt shape):
Live check on this branch with a local paid gateway and
anychat-boon-webv0.0.43-alpha, fresh thread, same prompt shape as the incident (spawn withsessions_spawn, yield, sub-agent sleeps 30 s, completion run answers through themessagetool):leafrow targets the run's own assistant row (mirror hidden, as designed). No end-of-runleafrow targets the pre-run yield marker.v2026.6.11-boon.40the same shape produced the stale row two seconds after eachmessage-tool completion run and the next prompt's compiled context did not contain the completion rows.Not verified: a same-build A/B without the fix (the control is the boon.40 incident transcript), and repair of transcripts already damaged.