Repository navigation
fix: preserve required child results during completion handoffs - #185667
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves explicit child-result requirements while allowing ordinary parent completion handoffs to finish quietly. Example: A subagent_settle input explicitly specifies replyExpectation: result-required and the CLI returns NO_REPLY.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR repairs a current-main reply-obligation regression with a focused change; no actionable introduced defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherChild findings enter the announcement flow, which dispatches a requester continuation through shared command reply policy and records its processing and delivery outcome. flowchart TD
A[Child findings] --> B[Announcement handoff]
B --> C[Reply policy owner]
C --> D[CLI or embedded execution]
D --> E[Completion classification]
E --> F[Registry settlement]
Technical reviewBest possible solution: Preserve explicit obligations and quiet completion defaults in the existing reply-policy owner while retaining human-reply promotion and delivery receipt checks. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically overrides explicit result-required completion inputs with optional, and the PR reports matching base failures through real CLI enforcement; no target code was executed during this review. Is this the best way to solve the issue? The patch repairs precedence at the shared owner and adjusts the handoff default at its producer, preserving the approved quiet-parent behavior without adding a competing policy implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 819a6c6eee75. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +14, Tests +12. Total +26 across 6 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 27, 2026, 4:35 AM ET / 08:35 UTC. |
|
Merged via squash.
|
Use visible unsent parent output to exercise direct completion fallback after #185388 and #185667 made ordinary parent silence optional. Preserve exact-once notices, child failure and side-effect facts, sanitization, private review, and restart assertions. Align the ACK fixture receipt and stale completion docs with the current contract.
…lds into one helper call Upstream (openclaw#185569, openclaw#185667) grew subagent-announce-direct-delivery.ts to exactly the 700-line cap, so the fork's `continuationTrigger` and `traceparent` lines on the direct agent request put it at 702. Fold, not extract (bootstrap#1727 comment 6449160126). The new continuation-owned sibling subagent-announce-direct-delivery.continuation.ts exports withDirectAnnounceContinuationFields. It returns upstream's source-reply spread, then `continuationTrigger` and `traceparent`, each only when present. The request keeps one call in place of upstream's 3-line spread, so a later upstream edit to that spread conflicts on that one line. Field order is unchanged. Deviation from the workorder, measured (TROUBLE posted): passing upstream's 92-character expression itself as the argument cannot fit. At indent 8 with its trailing comma it needs 101 columns, so the formatter breaks it over 3+ lines, and the import costs a fourth. Counted lines with oxfmt and max-lines: verbatim argument 704; wrapping upstream's object literal with every inner byte unchanged 701; taking `completionSourceReplyDeliveryMode` 699. The helper therefore takes the operand, and upstream's expression moves verbatim into its body. Behaviour: unchanged for every consumer. The request used to carry `continuationTrigger: undefined` when there was no trigger. The key is now absent, like the sibling producers (announce delivery, restart sentinel, continuation wake). The Gateway `agent` validator treats an optional undefined as absent, and readers only read the value. Counted lines (U8 -> 3c834c7 -> this): 700 -> 702 -> 699. No cap moved. RED (3c834c7, bare and --base 7fdf69f): check:line-cap-ratchet subagent-announce-direct-delivery.ts: 700 -> 702 counted lines (cap 700). GREEN: check:line-cap-ratchet bare and --base 7fdf69f OK (806 changed files); tsgo:core exit 0. subagent-announce-direct-delivery.continuation.test.ts 2/2: upstream's fields unchanged for every mode, continuation fields only when present, order kept. subagent-announce-direct-delivery, -direct-completion-media and -delivery.completion-contract (continuation trigger and trace on the direct path) 61/61; subagent-announce-delivery{,.origin,.discord-thread, .yielded-settle,.runtime}, continuation-drain.chain-cost and media-generate-background trace-context 157/157. Refs karmaterminal/openclaw-bootstrap#1727 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…claw#185667) Fix the reply-expectation precedence regression introduced by openclaw#185388: completion provenance could downgrade an explicit result-required child result to optional and silently accept NO_REPLY. Honor explicit caller expectations at the reply owner, and let ordinary completion handoffs ask that owner for their optional default. Explicit visible-reply obligations and channel receipts remain enforced. Quiet parent completions settle once without a blocked notice or another model turn. Proof: reproduced all 17 CLI failures on the base; final CLI and settle-dispatch suites passed 112/112, with explicit result-required policy cases and the one-undelivered NO_REPLY settle case. The isolated scripted-provider Gateway product test covers quiet and visible completions. Targeted typecheck, lint, format, size ratchet, and Codex P1 autoreview passed. No baseline or dependency changes. Related: openclaw#185388.
Use visible unsent parent output to exercise direct completion fallback after openclaw#185388 and openclaw#185667 made ordinary parent silence optional. Preserve exact-once notices, child failure and side-effect facts, sanitization, private review, and restart assertions. Align the ACK fixture receipt and stale completion docs with the current contract.
Upstream openclaw#185388 is 1aba44b ("fix(agents): settle silent subagent completions quietly", merged to main 2026-10-26), with the precedence fix from its follow-up openclaw#185667 b3b0f1b. On 2026.11.x a private completion turn (sessions_spawn completionTarget "parent") that ends with NO_REPLY or no text is treated as a missing answer: the direct-delivery producer passes replyExpectation "required" for every announce that expects a completion message, the runner retries with a visible-answer continuation, and on the released builds the retried turn can fail with "Session transcript keyed user is outside the current turn" and leave the registry row suspended. Ported behavior (private completions only): - subagent-announce-direct-delivery: a private announce no longer owes a reply; an explicit visible-reply obligation still does. - resolveCommandReplyExpectation (attempt-execution.helpers.ts on this branch, reply-completion.ts on main): a private completion input with subagent_announce/subagent_settle provenance and no producer expectation is optional. It runs after the explicit-expectation check, which is the openclaw#185667 precedence (an explicit "required" is never downgraded). - docs/tools/subagents/announce.md: private processing may finish silently. Adaptations: - Not carried: the public (user-target) half of openclaw#185388, i.e. optional public completions plus the direct-response classifier's quiet settle, and the removal of the blocked-delivery system notice and its queue receipt machinery. Those conflict in 15 files and change user-visible behavior of public completions; this branch keeps retry and text fallback there. The private classifier on this branch already settles successful silent consumption (resolvePrivateCompletionDeliveryResult). - The product test is upstream's server.subagent-silent-completion test reduced to the private target, with inline provider and spawn helpers (the upstream test-support files do not exist on this branch) and a settle waiter that also stops on failed/suspended rows. - INTER_SESSION_REPLY_POLICY_CASES: the private settle row now expects optional (upstream openclaw#185667's table has the same row as optional); added private announce, explicit-required private, and private sessions_send rows. Proof (M4, Node 26.12.1, OPENCLAW_VITEST_RUNTIME=node, on e79eb6135f36): - src/gateway/server.subagent-silent-completion.product.test.ts: 1 passed (one Gateway boot, private completions answering NO_REPLY, empty text and visible text; the test takes 18.3 s, the file 47.3 s with --maxWorkers=1). Red-before with the two source files reverted: 1 failed, 'private completion "NO_REPLY": expected 2 to be 1' (the runner retried the silent turn with a second model request). - src/agents/command/attempt-execution.cli.test.ts: 87 passed (39.5 s). Red-before: 2 failed | 85 passed, the openai and claude-cli inter-session reply policy rows ("expected 'required' to deeply equal 'optional'"). - src/agents/subagents/announce, src/agents/command and src/gateway/server.private-completion.test.ts: 63 files, 893 passed. The 7 announce live/e2e files are not in that run; of them subagent-announce.format.e2e.test.ts ran with test/subagent-requester-owner.e2e.test.ts: 2 files, 67 passed. The 6 live files need real providers and were not run. - src/agents/subagents/registry, src/agents/subagents/completion, the 17 src/agents/tools/sessions-s*.test.ts files, openclaw-tools.sessions-send-child-coordination.test.ts and agent-command-restart-recovery.test.ts: 115 files, 1855 passed, 1 skipped.
Upstream openclaw#185388 is 1aba44b. The private-completion half was carried in "carry upstream openclaw#185388" earlier in this stack; this commit carries the rest, with the reply-expectation precedence of openclaw#185667 b3b0f1b and the QA fixture follow-up of openclaw#185840 fc06d3c. User-visible changes: - Removed notice. When a successful child's completion delivery was blocked (the requester settle failed, or delivery was suspended on expiry or permanent failure), the completion kernel queued a system event into the requester session, text "Subagent completion delivery is blocked: <reason> (run <runId>)", with the requester's origin as its delivery context. That event started another model turn in the parent session, and its reply went to the parent's conversation, so the user saw whatever the parent said about the blocked delivery (on 11.2 that turn once sent the child's raw result to Telegram). Nothing is queued now and no extra turn runs. The failure stays on the child run's delivery state (status failed or suspended, lastError = the reason), which subagents list/wait report as deliveryStatus and the parent's runtime context shows as delivery=failed/suspended on its next turn. - Public completions. A user-facing completion turn that ends with NO_REPLY or no text used to be retried once with a visible-answer continuation; if it stayed silent, core sent the child's raw result (or, for a failed child, "A delegated task failed before it could report a result. Please retry the task.") to the chat as a direct-message fallback. It now settles as delivered on the first silent turn, with no retry and no fallback send; the child result stays in the child session and the Subagents panel. A visible parent reply that was not delivered still uses the fallback. Explicit visible-reply obligations (requireVisibleReply) keep their required expectation and retries. Source: - subagent-announce-direct-response.ts: successful silent completion and settle turns return delivered before the fallback paths; the settle-only optional branch it replaces is removed. Kept from this branch: a terminal reply snapshot marked visible is not treated as silence. - subagent-announce-direct-delivery.ts: completion and settle inputs owe no reply unless requireVisibleReply is set (openclaw#185667's resolveCompletionInputReplyExpectation, inlined here); other completion producers stay required. - resolveCommandReplyExpectation (attempt-execution.helpers.ts): the subagent_announce/subagent_settle provenance default is optional for all completion inputs, not only private ones; an explicit producer expectation still wins (the openclaw#185667 precedence). - Completion kernel and store: the blocked-notice producer, its queue intent receipts (queueIds/queueReceipts), the post-commit scheduling and subagent-completion-queue-receipt.ts are removed. - Docs: announce.md and slash-command.md describe quiet settlement and the missing notice. Adaptations: - Classifier: the branch has no "result-required" expectation and its fallback block differs; the quiet-settle return is placed after the delivery-failure check as upstream, using this branch's payload facts. - Tests, rewritten on this branch's fixtures where upstream's files differ: the queue-receipt test now proves a failed settle commits without any system event and replays without a second write; the yielded-settle, direct-delivery and delivery settle cases take upstream's new expectations (silent successful turns settle; cases that need a missing reply now use unsent visible text); requester-wake expects no system events; the reply-policy table and CLI announce cases expect optional completion processing and keep explicit required rows. The product test now runs the user target too (NO_REPLY, empty and visible). Branch-only tests that pinned the old classifier: settle-dispatch's optional cohorts now settle once even when a child result was owed (the same change openclaw#185667 made to its settle-dispatch case); progress-draft's silent retries now model the runner's incomplete turn under a required expectation, so the wake still retries; restart-recovery's receipt tests now assert that replay classifies the bounded receipt like the original turn, and an empty legacy receipt settles without a visible final; the requester-wake e2e case whose woken requester accepts no next child now settles on that empty successful turn instead of retrying it. Not on this branch, so not carried: upstream's mailbox test, the settle-replay recovery harness, and the restart-sentinel blocked-notice case. - openclaw#185840: the qa-lab mock leaves visible parent text unsent for the visible terminal case, so the direct-fallback scenario still exercises fallback; its unit test and the scenario's descriptions follow. Its terminal-ack fixture and empty-completion-recovery wording are not carried (this branch's fixtures and wording differ). Upgrade: blocked-notice system events already queued by 11.1/11.2 stay in the session delivery queue and drain once through the generic session delivery runtime; nothing new is written. Proof (M4, Node 26.12.1, OPENCLAW_VITEST_RUNTIME=node, each file alone with --maxWorkers=1 unless noted): - Changed tests green: server.subagent-silent-completion.product 1 passed (6 cases, 14.4 s test, 35.9 s file), attempt-execution.cli 87, subagent-announce-delivery 137, yielded-settle 20, direct-delivery 35, queue-receipt 1, requester-wake 37, subagent-registry-lifecycle 249, qa-lab mock-openai server 115, agent-command-restart-recovery 33, requester-settle-dispatch 20, subagent-progress-draft 11, delivery-completion.recovery.integration 18. - Red-before (this commit's source files at the parent, tests kept): the product test fails 'user completion "NO_REPLY": expected 2 to be 1' (a retried silent public completion); attempt-execution.cli 20 failed | 67; yielded-settle 2 | 18; queue-receipt 1 failed (a system event is queued); requester-wake 8 | 29; mock-openai server 1 | 114. The delivery and direct-delivery fixture changes pass both ways. - Wider suites (continue-on-failure): src/agents/subagents, src/agents/command, the private-completion, restart-sentinel and product gateway tests, the 17 sessions tool tests, subagents tool and scope tests, commands-subagents, session-utils.subagent, requester-pause-authority, sessions.abort-completion-publication, sessions-send-child-coordination, agent-command-restart-recovery and the qa-lab scenario-catalog, coverage, smoke-plan, terminal-ack and mock tests: 251 files, 3675 passed, 1 skipped, 0 failed. - E2E: subagent-completion-blocked, gateway-restored-requester-settle, gateway-subagent-restart, subagent-requester-owner, announce format and the three registry e2e files pass (139 of 141 before the requester-wake adaptation; that file then 32 passed). gateway-completion-replay fails "expected 2 to be 1" (a second requester tool effect after a silent-stop nudge) both here and at the parent efa05c6, so it is not from this change. - Gates on this commit: check-line-cap-ratchet and check-test-mock-exports against v2026.11.2 exit 0; run-oxlint on the touched .ts files 0 errors; oxfmt --check exit 0; tsgo:core, tsgo:extensions, tsgo:test:src and tsgo:test:extensions exit 0. No config change, so config:docs:check was not needed.
Related: #185388
What Problem This Solves
Required child results could be silently accepted after #185388 because completion provenance overrode the caller's explicit reply expectation.
User Impact
Explicit child-result obligations remain required. Ordinary parent completions can still finish silently once, without blocked-delivery notices or an extra model turn. Channel delivery receipts and explicit visible-reply obligations retain their existing contracts.
Why This Change Was Made
Restore explicit result-required precedence after #185388: the reply owner honors caller expectations before applying the optional completion default. The ordinary completion handoff delegates its default to that same owner instead of creating a required reply merely because child findings are available.
The CLI policy matrix uses independent expected values for explicit obligations and quiet defaults. The settle “one undelivered, NO_REPLY” case now expects settled delivery in one turn. Size gates pass without baseline changes: the nested tools fixture checks its optional default, while explicit result obligations are covered by the existing provider policy cases. Direct delivery stays within its 700-line cap.
No configuration, persisted state, dependencies, or restart-recovery branches change. Production: +19/-5 lines; tests: +49/-37 lines (net +26 overall). The duplicate test policy tree and obsolete retry assertions are removed; no new runtime owner or test-only seam is introduced.
Evidence
Final local Gateway replay on the loaded host timed out during startup (120000ms test budget, 476.99s wrapper total), before any completion assertion. Its earlier equivalent-policy product run passed; no timeout budget or test expectation was changed to conceal the setup failure. Local CLI/settle proof and exact-head CI are green.