Skip to content

[ENG-21269] fix(gateway): parent agent forgets finished sub-agent results after yielding - #314

Merged
orswn merged 2 commits into
boonfrom
okka/eng-21269/persist-completion-handoffs
Oct 30, 2026
Merged

orswn merged 2 commits into
boonfrom
okka/eng-21269/persist-completion-handoffs

Conversation

@orswn

@orswn orswn commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Related: ENG-21269, ENG-20773

What Problem This Solves

Fixes an issue where a parent agent that splits work across sub-agents forgets finished results and never sends its final answer.

  • The parent spawns several sub-agents, then calls sessions_yield and goes idle.
  • Each finished child wakes the parent once with its result.
  • On the next wake, the parent no longer sees the earlier results. It replies "waiting on ..." for children that have already finished.
  • After the last child, nothing wakes the parent again. The user sees no answer until they ask again.

Seen on customer Slack threads and in the PDF coverage agent regression scenario, which times out at 900 s while its children finish in about 5 minutes.

Why This Change Was Made

The gateway agent method suppressed transcript persistence for the turn that delivers a sub-agent completion to its parent. The model saw the child result in that turn only, and the result was never saved.

That suppression came from upstream "fix: hide subagent announce handoff prompts" (openclaw#79618), whose goal was to keep these internal prompts out of chat history. The chat display projection already hides user rows with inter_session / subagent_announce provenance, so the transcript row can be saved without showing it. Upstream removed the same suppression in openclaw#181673.

  • The completion turn now saves one user row with inter_session / subagent_announce provenance. The row holds the child result.
  • Callers that pass suppressPromptPersistence explicitly (gateway boot, sub-agent orphan resume) keep their behavior.
  • Not ported from upstream fix(gateway): the turn after a subagent completion misses the prompt cache openclaw/openclaw#181673: the durable pre-admission of the row with display: false. That code lives in a gateway module this fork does not have yet. Display is already hidden by provenance here.

Trade-off, not fixed here: when a completion delivery stays pending (for example a session with no deliverable channel and target), the agent steering queue re-sends it on each wake. A sessions_yield abort returns the leased items to the queue, so the next wake replays them again. That replay is now saved in each wake row too, so results can repeat in the transcript, up to 24,000 characters per wake. In the runtime check below, Slack thread wakes were marked delivered and carried no replay. A TODO marks the release on the yield abort; fixing it changes the steering lease rules.

User Impact

  • A parent agent keeps every finished sub-agent result across wakes and sends its final answer when the last child finishes.
  • Later turns in the same thread can still use those results.
  • Chat history in web chat, the Control UI, and the sessions_history tool does not show the internal completion rows.

Evidence

  • New gateway test: no request flag means the completion prompt is persisted, explicit suppressPromptPersistence: true means it is suppressed. It failed on the base commit (expected true to be false) and passes on this branch.
  • node scripts/run-vitest.mjs over the gateway agent, chat history, server methods, sub-agent announce delivery, agent command, and input provenance tests: 864 tests pass.
  • tsgo (core, core tests), oxlint, oxfmt --check, and git diff --check pass.
  • Runtime check: a real gateway built from the base commit and from this branch, with a scripted local mock model. The parent session has a Slack channel thread route, the same delivery branch as the customer threads. No Slack connection was made. The parent spawns 3 sub-agents that finish 2 s, 8 s, and 14 s later, yields, and is woken once per child. A final user turn asks the parent to list every result.
Check Base commit This branch
Results visible on wake 1, 2, 3 1/3, 1/3, 1/3 (own child only) 1/3, 2/3, 3/3
Parent sends its final answer no, yields "Seen 1/3" after all children ended yes, with all 3 results
Later user turn sees the results none all 3
Saved subagent_announce user rows in the parent transcript 0 3, one result each
Those rows in chat.history n/a 0 of 14 messages
Child delivery state delivered delivered

OpenClaw Control UI view of the same two parent sessions. Left: base build. Right: this branch. The completion handoff rows stay hidden in both.

Base build vs this branch in the Control UI

The last right-hand tile starts with a steering queue block for the third child. The local test had no Slack adapter, so that child's final reply could not be delivered and was queued for replay. The block holds only RESULT-CHARLIE-9902. The other two results reach the recall turn from the saved transcript.


Summary by cubic

Fixes a bug where a parent agent that spawns sub-agents and calls sessions_yield forgets finished children's results, then never sends its final answer.

The gateway agent method suppressed transcript persistence for the turn that delivers a sub-agent completion to its parent, so each child result was visible to the model only in that single turn. That suppression came from upstream commit openclaw#79618, which hid subagent announce handoff prompts from chat history; the chat display projection already hides these rows by provenance, so the row can now be saved without appearing in chat.

The completion turn now persists one user row with inter_session / subagent_announce provenance carrying the child result, so the parent keeps every finished result across wakes. Callers that pass suppressPromptPersistence explicitly keep their behavior. The rows remain hidden from web chat, the Control UI, and sessions_history.

Known trade-off, not fixed here: when a completion delivery stays pending (a session with no deliverable channel), a sessions_yield abort returns leased steering items to the queue, so the next wake replays and repersists them. A TODO in attempt.ts marks that release for a follow-up fix.

Written for commit c5d5733. Summary will update on new commits.

View guided diff Turn on auto-fix

…ielding

A parent agent that spawns sub-agents and calls sessions_yield is idle
while the children run. When a child finishes, the gateway agent method
runs a parent turn with the child result. That turn did not save its
prompt to the parent transcript. The model saw the result once, in that
turn only. On the next wake the result was gone, so the parent waited
for children that had already finished and never sent its final answer.

The suppression came from upstream "fix: hide subagent announce
handoff prompts" (openclaw#79618). Its goal was to hide the handoff prompt in
chat history. The chat display projection already hides user rows with
subagent_announce provenance, so dropping the transcript row is not
needed for that goal. Upstream removed the same suppression in
openclaw#181673.

Remove the automatic suppression for sub-agent completion handoffs. The
completion turn now saves a user row with inter_session /
subagent_announce provenance that carries the child result. Callers that
pass suppressPromptPersistence explicitly keep their behavior.
@orswn
orswn requested a review from a team October 29, 2026 14:03
The deferred-gap TODO in the embedded runner attempt needs an
eslint/no-warning-comments suppression. The production suppression
allowlist test lists each such file explicitly, so add the attempt
file next to the other deferred-gap entries.

@boon-hermes-bot boon-hermes-bot 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.

Review Summary

Verdict: Approved (Ready to merge)

Analysis & Implementation

  • Root Cause: In src/gateway/server-methods/agent.ts, shouldSuppressAgentPromptPersistence was suppressing prompt persistence for any subagent_announce completion handoff. As a result, child completion turns were never written to the parent session transcript, causing the parent to lose previous results across wakes after yielding.
  • Fix: Removed shouldSuppressAgentPromptPersistence so completion turn prompts are persisted in the transcript by default, matching upstream openclaw#181673. Explicit caller suppression (request.suppressPromptPersistence === true) remains respected.
  • UI & Chat Projection: User-facing WebChat and Control UI projections remain clean: chat-display-projection.ts already drops subagent_announce provenance records from visible history.
  • Deferred Gap Documented: Documented the steering queue replay behavior upon sessions_yield abort with a TODO comment in run/attempt.ts and updated the production lint suppression allowlist in test/scripts/lint-suppressions.test.ts.

Verification

  • Test Suite:
    • src/gateway/server-methods/agent.test.ts: 344 passed (including the new parameterized test covering both default and explicit suppression).
    • test/scripts/lint-suppressions.test.ts: 3 passed.
    • src/agents/subagent-announce-delivery.test.ts: 112 passed.
  • CI Status: All GitHub check runs completed successfully (clean green across lint, types, shrinkwrap, guards, and test shards).
  • Commit Signatures: Both commits (55c1a7f, c5d5733) are signed and verified by GitHub.

LGTM!

@orswn
orswn merged commit 6acf15e into boon Oct 30, 2026
147 checks passed
@orswn
orswn deleted the okka/eng-21269/persist-completion-handoffs branch October 30, 2026 07:53
orswn added a commit that referenced this pull request Nov 2, 2026
Cut the fork release for the 6 PRs merged to boon since
v2026.6.35-boon.2:

- #313 (ENG-21904, ENG-21905): no fallback after the run deadline, no
  late replies from timed-out sub-agents, and no false error notice
  after a recovered context precheck.
- #314 (ENG-21269): a parent that yielded keeps finished sub-agent
  results on later wakes.
- #315 (ENG-21129): skip the failure notice on channels that report
  their own turn outcome, and say the work continues while the failed
  turn's sub-agents still run.
- #311: qs override 6.16.1 (CVE-2026-82417).
- #317: follow-redirects override 1.16.2 (GHSA-mrwp-f3q8-3g9p).
- #312: Docker base digests to Node 24.22.1.

Bump the root package.json and npm-shrinkwrap.json, all 136 bundled
plugin manifests (scripts/sync-plugin-versions.ts), and the version and
openclaw peer floor in every extension npm-shrinkwrap.json. Add the
2026.6.35-boon.3 CHANGELOG.md section. No source or dependency change
beyond what already merged in the PRs above.
orswn added a commit that referenced this pull request Nov 2, 2026
Cut the fork release for the 6 PRs merged to boon since
v2026.6.35-boon.2:

- #313 (ENG-21904, ENG-21905): no fallback after the run deadline, no
  late replies from timed-out sub-agents, and no false error notice
  after a recovered context precheck.
- #314 (ENG-21269): a parent that yielded keeps finished sub-agent
  results on later wakes.
- #315 (ENG-21129): skip the failure notice on channels that report
  their own turn outcome, and say the work continues while the failed
  turn's sub-agents still run.
- #311: qs override 6.16.1 (CVE-2026-82417).
- #317: follow-redirects override 1.16.2 (GHSA-mrwp-f3q8-3g9p).
- #312: Docker base digests to Node 24.22.1.

Bump the root package.json and npm-shrinkwrap.json, all 136 bundled
plugin manifests (scripts/sync-plugin-versions.ts), and the version and
openclaw peer floor in every extension npm-shrinkwrap.json. Add the
2026.6.35-boon.3 CHANGELOG.md section. No source or dependency change
beyond what already merged in the PRs above.
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.

2 participants