Skip to content

fix(subagents): make completion handoff review-first - #82724

Merged
steipete merged 2 commits into
openclaw:mainfrom
100menotu001:codex/subagent-review-handoff
May 16, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
100menotu001:codex/subagent-review-handoff

Conversation

@100menotu001

@100menotu001 100menotu001 commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem: completed subagent announce handoffs tell the requester agent the result is "ready for user delivery", which frames the handoff as a final-response rewrite instead of a parent review point.
  • Why it matters: when the child result identifies remaining work, the requester agent should verify the result and continue or record follow-up work before reporting done.
  • What changed: successful subagent announce instructions now say the handoff is ready for parent review, require review/verification before deciding the original task is done, and explicitly tell the requester to continue or record follow-up when more action is required.
  • What did NOT change (scope boundary): no delivery routing, registry state, child execution, task registry, ACP lifecycle, config, or channel behavior changed.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: completed subagent announce handoffs now instruct the requester/parent to review and verify child results before deciding whether the original task is done, and to continue or record follow-up work when additional action remains.
  • Real environment tested: local OpenClaw source checkout from current openclaw/openclaw@main on macOS, branch codex/subagent-review-handoff, running the actual runSubagentAnnounceFlow formatter coverage used by the runtime announce path.
  • Exact steps or command run after this patch:
    • git show upstream/main:src/agents/subagent-announce.ts | rg -n "ready for user delivery|ready for parent review"
    • rg -n "ready for user delivery|ready for parent review|Review/verify|additional action" src/agents/subagent-announce.ts src/agents/subagent-announce.format.e2e.test.ts CHANGELOG.md | sed -n '1,80p'
    • pnpm exec vitest run --config test/vitest/vitest.e2e.config.ts src/agents/subagent-announce.format.e2e.test.ts
    • pnpm exec oxfmt --check --threads=1 src/agents/subagent-announce.ts src/agents/subagent-announce.format.e2e.test.ts CHANGELOG.md
    • pnpm check:changed
    • git diff --check
    • Synthetic redacted requester handoff capture using runSubagentAnnounceFlow with a temp config/session store and captured agent handoff params.
  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output):
$ git show upstream/main:src/agents/subagent-announce.ts | rg -n "ready for user delivery|ready for parent review"
91:    return `A completed ${params.announceType} is ready for user delivery. Convert the result above into your normal assistant voice and send that user-facing update now. Keep this internal context private (don't mention system/log/stats/session details or announce type).`;
93:  return `A completed ${params.announceType} is ready for user delivery. Convert the result above into your normal assistant voice and send that user-facing update now. Keep this internal context private (don't mention system/log/stats/session details or announce type), and do not copy the internal event text verbatim. Reply ONLY: ${SILENT_REPLY_TOKEN} if this exact result was already delivered to the user in this same turn.`;

$ rg -n "ready for user delivery|ready for parent review|Review/verify|additional action" src/agents/subagent-announce.ts src/agents/subagent-announce.format.e2e.test.ts CHANGELOG.md | sed -n '1,80p'
src/agents/subagent-announce.ts:91:    return `A completed ${params.announceType} is ready for parent review. Review/verify the result above before deciding whether the original task is done. If additional action is required, continue the task or record a follow-up; otherwise send a truthful user-facing update. Keep this internal context private (don't mention system/log/stats/session details or announce type).`;
src/agents/subagent-announce.ts:93:  return `A completed ${params.announceType} is ready for parent review. Review/verify the result above before deciding whether the original task is done. If additional action is required, continue the task or record a follow-up; otherwise send a truthful user-facing update. Keep this internal context private (don't mention system/log/stats/session details or announce type), and do not copy the internal event text verbatim. Reply ONLY: ${SILENT_REPLY_TOKEN} if this exact result was already delivered to the user in this same turn.`;
src/agents/subagent-announce.format.e2e.test.ts:514:    expect(msg).toContain("A completed subagent task is ready for parent review.");
src/agents/subagent-announce.format.e2e.test.ts:516:      "Review/verify the result above before deciding whether the original task is done.",
src/agents/subagent-announce.format.e2e.test.ts:519:      "If additional action is required, continue the task or record a follow-up; otherwise send a truthful user-facing update.",
src/agents/subagent-announce.format.e2e.test.ts:705:    expect(msg).toContain("A completed subagent task is ready for parent review.");
src/agents/subagent-announce.format.e2e.test.ts:707:      "If additional action is required, continue the task or record a follow-up; otherwise send a truthful user-facing update.",
CHANGELOG.md:24:- Agents/subagents: mark completed subagent handoffs as ready for parent review so requester agents verify results and continue required follow-up work before reporting done.

$ pnpm exec vitest run --config test/vitest/vitest.e2e.config.ts src/agents/subagent-announce.format.e2e.test.ts
Test Files  1 passed (1)
Tests  79 passed (79)

$ pnpm exec oxfmt --check --threads=1 src/agents/subagent-announce.ts src/agents/subagent-announce.format.e2e.test.ts CHANGELOG.md
All matched files use the correct format.

$ pnpm check:changed
Import cycle check: 0 runtime value cycle(s).
[check:changed] completed successfully

$ git diff --check
(no output)

$ OPENCLAW_CONFIG_PATH=<temp>/openclaw.json OPENCLAW_STATE_DIR=<temp> OPENCLAW_PROOF_STORE=<temp>/sessions.json pnpm exec tsx --eval '<capture runSubagentAnnounceFlow handoff>'
captured_method=agent
captured_session=agent:main:main
captured_deliver=false
captured_message_excerpt:
child found a stale override and recommends a follow-up fix
A completed subagent task is ready for parent review. Review/verify the result above before deciding whether the original task is done. If additional action is required, continue the task or record a follow-up; otherwise send a truthful user-facing update. Keep this internal context private (don't mention system/log/stats/session details or announce type), and do not copy the internal event text verbatim. Reply ONLY: NO_REPLY if this exact result was already delivered to the user in this same turn.
  • Observed result after fix: the subagent announce prompt generated by the runtime formatter now says the completion is ready for parent review, asks the requester agent to verify before deciding the original task is done, and tells it to continue or record follow-up when more action remains. A synthetic redacted runtime handoff capture also showed runSubagentAnnounceFlow delivering those instructions through the requester agent handoff params.
  • What was not tested: no live provider-backed Telegram/Discord/Slack turn was run for this PR; the change is limited to runtime prompt wording and covered through the existing subagent announce formatter e2e path.
  • Before evidence (optional but encouraged): upstream/main output above shows both non-subagent requester handoff branches used ready for user delivery wording before this patch.

Root Cause (if applicable)

  • Root cause: the non-subagent requester handoff text treated a completed child run as a user-delivery event, not as parent-owned evidence that may require review, verification, or more work.
  • Missing detection / guardrail: formatter coverage asserted the old delivery wording but did not require review-first closeout language.
  • Contributing context (if known): subagent completion announces are internal handoff data; requester agents own synthesis and final task state.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/agents/subagent-announce.format.e2e.test.ts
  • Scenario the test should lock in: generated subagent announce prompts for requester sessions contain parent-review wording, verification guidance, and continue/follow-up guidance instead of delivery-only wording.
  • Why this is the smallest reliable guardrail: it exercises the runtime announce formatter path without requiring external channels or providers for a prompt-text-only change.
  • Existing test that already covers this (if any): existing formatter e2e cases covered the same prompt branches but expected the old wording.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

Subagent completion handoffs now guide the requester/parent agent to verify child results and continue required follow-up work before reporting done. No config or channel behavior changes.

Diagram (if applicable)

Before:
subagent completes -> requester sees "ready for user delivery" -> likely final-answer rewrite

After:
subagent completes -> requester sees "ready for parent review" -> verify -> continue/follow-up or truthful final update

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local OpenClaw source checkout
  • Model/provider: N/A; prompt formatter change only
  • Integration/channel (if any): subagent announce formatter/runtime path
  • Relevant config (redacted): N/A

Steps

  1. Inspect upstream/main subagent announce instruction text.
  2. Apply this patch.
  3. Inspect the patched instruction text and run the formatter e2e test shard.
  4. Run formatting, changed-file gate, and whitespace checks.

Expected

  • Subagent announce requester prompts say ready for parent review and instruct review/verification before done.
  • Prompt text tells the requester to continue or record follow-up if additional action is required.
  • Formatter e2e tests pass.

Actual

  • Expected behavior observed.
  • Focused e2e, formatting, docs formatting, synthetic handoff capture, check:changed, and git diff --check passed.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: both non-subagent requester handoff branches now use parent-review wording; existing formatter e2e branch assertions were updated and passed; a synthetic redacted handoff run captured the actual requester agent handoff message containing the parent-review/follow-up instruction.
  • Edge cases checked: duplicate-delivery SILENT_REPLY_TOKEN guidance remains intact on the default branch; requester-is-subagent internal orchestration wording remains unchanged.
  • What you did not verify: live model-backed channel turn; no runtime routing or delivery code was changed.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: a requester agent may spend more effort reviewing a child result before replying.
    • Mitigation: the new wording only applies when a child completion is handed back to the requester and keeps the final-update path explicit when no more action is needed.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 16, 2026
@clawsweeper

clawsweeper Bot commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR changes subagent completion handoff wording, formatter e2e assertions, docs, and changelog so requester agents treat child completion results as parent-review material before final user delivery.

Reproducibility: yes. Current main source at 25090f64b3889e20e927d541a895d14e287486ea emits ready for user delivery in the two non-subagent requester branches, and current formatter e2e coverage asserts that wording.

Real behavior proof
Sufficient (terminal): The PR body includes after-fix terminal proof from the formatter e2e path and a synthetic runtime handoff capture showing the changed requester instruction.

Next step before merge
Human selection is needed between this focused PR and the broader delegated-completion PR; there is no narrow automated repair for ClawSweeper to make.

Security
Cleared: The diff only changes prompt text, formatter assertions, docs, and changelog content; no security or supply-chain concern was found.

Review details

Best possible solution:

Land one coherent review-first handoff change, choosing this focused subagent-only patch or the broader delegated-completion patch based on the desired scope.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main source at 25090f64b3889e20e927d541a895d14e287486ea emits ready for user delivery in the two non-subagent requester branches, and current formatter e2e coverage asserts that wording.

Is this the best way to solve the issue?

Yes for the subagent-only bug. Changing the central handoff instruction with matching formatter coverage and docs is the narrow maintainable fix; the only open question is whether the broader delegated-completion PR should be the merge vehicle.

What I checked:

Likely related people:

  • steipete: Recent history includes manual subagent completion delivery and deterministic announce work on the same prompt/handoff surface, and Peter also committed the current PR's changelog credit update. (role: recent area contributor; confidence: high; commits: e2dd827ca4ba, 289f215b3160, bdc817d72e24; files: src/agents/subagent-announce.ts, src/agents/subagent-announce-delivery.ts, CHANGELOG.md)
  • tyler6204: History and the linked issue trace the delivery-first buildAnnounceReplyInstruction lineage to the nested subagent orchestration controls work, with several follow-up changes in this area. (role: introduced adjacent behavior; confidence: medium; commits: b8f66c260db8, fe57bea088c7, 81b93b9ce04b; files: src/agents/subagent-announce.ts, src/agents/subagent-announce-delivery.ts, docs/tools/subagents.md)
  • onutc: Thread-bound subagent work touched the same subagent routing/docs area after the original wording was introduced, making Onur a useful adjacent routing reviewer if scope expands. (role: adjacent feature contributor; confidence: medium; commits: 8178ea472db1, a7d56e3554d0; files: src/agents/subagent-announce.ts, src/agents/subagent-announce.format.e2e.test.ts, docs/tools/subagents.md)

Remaining risk / open question:

Codex review notes: model gpt-5.5, reasoning high; reviewed against 25090f64b388.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 16, 2026
@clawsweeper clawsweeper Bot added the P2 Normal backlog priority with limited blast radius. label May 16, 2026
@100menotu001
100menotu001 force-pushed the codex/subagent-review-handoff branch from ad7e099 to 02faea4 Compare May 16, 2026 20:16
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label May 16, 2026
@100menotu001
100menotu001 force-pushed the codex/subagent-review-handoff branch from 02faea4 to 703fe7c Compare May 16, 2026 20:19
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 16, 2026
@100menotu001
100menotu001 force-pushed the codex/subagent-review-handoff branch from 703fe7c to 9a5112d Compare May 16, 2026 20:27
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 16, 2026
@100menotu001
100menotu001 force-pushed the codex/subagent-review-handoff branch from 9a5112d to e2ad6c7 Compare May 16, 2026 20:33
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 16, 2026
@steipete
steipete force-pushed the codex/subagent-review-handoff branch from e2ad6c7 to b594434 Compare May 16, 2026 21:35
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 16, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 16, 2026
@steipete
steipete force-pushed the codex/subagent-review-handoff branch from b594434 to bdc817d Compare May 16, 2026 21:42
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 16, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 16, 2026
@steipete
steipete merged commit fff8e79 into openclaw:main May 16, 2026
119 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Landed in fff8e79. Thanks @100menotu001.

Proof:

  • Codex review: no actionable correctness issues on the branch diff.
  • Focused e2e: node scripts/run-vitest.mjs --config test/vitest/vitest.e2e.config.ts src/agents/subagent-announce.format.e2e.test.ts -> 79 passed.
  • Format: pnpm exec oxfmt --check --threads=1 src/agents/subagent-announce.ts src/agents/subagent-announce.format.e2e.test.ts docs/tools/subagents.md CHANGELOG.md -> passed.
  • Whitespace: git diff --check -> passed.
  • GitHub checks: latest head bdc817d completed 119/119 with 0 failures before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subagent completion handoffs should return to parent review before user delivery

2 participants