Skip to content

fix(test): keep subagent wake receipt checks from timing out - #204748

Merged
vyctorbrzezowski merged 1 commit into
openclaw:mainfrom
vyctorbrzezowski:fix/subagent-wake-receipt-clock-204649
Nov 24, 2026
Merged

vyctorbrzezowski merged 1 commit into
openclaw:mainfrom
vyctorbrzezowski:fix/subagent-wake-receipt-clock-204649

Conversation

@vyctorbrzezowski

Copy link
Copy Markdown
Member

Closes #204649

What Problem This Solves

Six tests for resuming a parent after its subagents finish can each time out after 120 seconds. The tests hold one delivery open and freeze the clock before its grace period can expire, so they never reach the receipt they meant to check.

User Impact

No runtime change. Developers get a result from these tests instead of waiting for a timeout.

Why This Change Was Made

The fixture moves its fake wall clock to the end of the existing five-minute delivery grace period. It does not run pending timers, raise the test timeout, or change the rejected-delivery case.

Evidence

The same six tests timed out on the original CI base and its PR integration; the rejected-wake control passed on both. With this change, the six cases and that control passed together. The original receipt assertions, production code and timeout are unchanged. Focused formatting and lint passed. Local autoreview of 2e64daf69e73 through P2 found no actionable issues.

@clawsweeper

clawsweeper Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Nov 24, 2026
@vyctorbrzezowski
vyctorbrzezowski marked this pull request as ready for review November 24, 2026 16:10
@vyctorbrzezowski
vyctorbrzezowski enabled auto-merge (squash) November 24, 2026 16:16
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 24, 2026
@vyctorbrzezowski
vyctorbrzezowski merged commit 99195cb into openclaw:main Nov 24, 2026
190 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 25, 2026
tideclaw-bot pushed a commit that referenced this pull request Nov 29, 2026
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…led replies (#204089)

When a child (subagent) result could not be handed to its parent turn, `recordRequiredCompletionNotice` wrote the notice as customType `run-failed-before-reply`. The Control UI renders that type as a failed reply: a red "Couldn't finish this reply" badge with "Report a bug". This happened even when no reply was running and the child ended days earlier.

Seen in production. Child deliveries suspended by the old store-path veto (removed in #200760) stayed suspended. They expired after the 7-day retention, and the expiry sweep put red failed-reply badges under unrelated later turns. One notice was for a child that had been **killed** on purpose and had no captured result. The badge showed a raw session key, a run id, the word `killed`, and the text "…then retry or resend your request", but there was no request to retry.

All changes are in the notice owner, `recordRequiredCompletionNotice`, and its copy:

- **Killed or cancelled child with no captured result → no notice.** The function filters each batch member: `endedReason === "subagent-killed"`, not a steer restart, and no captured result text. Live siblings in the same batch still get their notice. A killed child that holds a captured result still shows it. There are no per-caller checks.
- **Child-delivery notices use `customType: "subagent-completion"`**, the child-result row kind the function already writes for `kind === "result"`. No UI reader treats this type as a run error, so the red badge and "Report a bug" go away. No new customType. Old stored rows render as before.
- **Model context: unchanged.** The design planned `excludeFromContext: true` for all notices. That rested on `packages/agent-core/.../session.ts` excluding every `run-failed-before-reply` row. That is one reader only. The SQLite model-context projection and `cli-runner/session-history.ts` read only `excludeFromContext`. So an unconsumed failure notice did reach the parent model, as `docs/tools/subagents/announce.md` documents ("available to the requester model if it never consumed the original result"). The existing conditional stays as it was: the notice enters model context only while a batch member's result is unconsumed (local review finding, round 3).
- **Copy:** "<child label> finished on <date> UTC, but its result couldn't be added to this conversation automatically. Details are below." The heading makes no "saved result is below" claim, because a private `completionTarget=parent` handoff or an uncaptured child has only identity and status. Each child section starts with its session key and run id, then the label and status. The heading label is bounded to 200 characters, so a long label cannot push the ids out of the 512-character header or the 32,000-character limit (local review findings, rounds 1-3).
- **Yielded requester** (a requester that ended its turn waiting on the child): stays a run error, because no reply was made. Its copy (`child_completion_delivery_failed`) now reads "This reply was waiting for a child agent whose result couldn't be added to this conversation automatically. Check the child session for its outcome." It no longer says "retry or resend your request".

Accepted edge cases (no code for them):

- A yielded batch now writes a run-error row and a separate child row.
- A retry across the upgrade can duplicate one legacy row, because dedupe is scoped per customType.

- Child-delivery failure, expiry and idle-expiry notices show as neutral rows, not as failed replies.
- An intentional kill writes no notice.
- No schema, stored-row, protocol or dependency change.

- New unit test `subagent-registry.store-replaced.test.ts` › "records a child-result notice for live children and none for a killed child":
  - Base `f595f0237a35`: **red**. It writes the incident row, `run-failed-before-reply`, "…retry or resend your request", `Child agent:main:subagent:killed … killed`.
  - Head: green.
- Updated the existing tests that pinned `run-failed-before-reply` for child-delivery notices. The gateway and e2e assertions that check for *no* failed reply stay as they are.
- `ocx test` on touched tests and every test that imports a changed source or test-support file (29 files). oxfmt and oxlint pass. `pnpm check:changed` passes except the dead export scan, which flags `scripts/lib/docker-e2e-watchdog.mjs: parseTimeoutMs`. That file is not in this diff.
- Not ours:
  - `subagent-registry-worker.test.ts` › "releases serialized payloads…" (GC retention) fails on base `f595f0237a35` too.
  - `subagent-registry-lifecycle.test.ts` failed on different tests in two loaded runs. It passed alone on head and on base.
- Real-product E2E: isolated scratch Gateway from source, real agent turns on Claude through the Control UI. The agent spawned two children; state was edited so one child was killed with no result and both deliveries were suspended for more than 7 days. Then the real sweeper ran `discardExpiredSubagentDelivery`.
  - Before (base): both children show the red "Couldn't finish this reply" + "Report a bug", the killed one included.
  - After (head): the ok child shows a neutral System row with its result and no badge. The killed child writes no row.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit d66eeff)

Release adaptation: port the child notice assertion into the stable split wake fixture without changing cohort tests. #204748 is a focused fixture clock companion; #204178 and #204260 are later history redesigns, and other audit matches address separate features or fixtures.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: subagent-registry.requester-wake.e2e 'settles requester receipts' cases time out at 120 s

1 participant