Skip to content

test(agents): give the sibling-drain completion wait a tolerance on slow runners - #139176

Merged
steipete merged 1 commit into
openclaw:mainfrom
ylcn91:fix/subagent-spawn-authority-waitfor
Sep 5, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
ylcn91:fix/subagent-spawn-authority-waitfor

Conversation

@ylcn91

@ylcn91 ylcn91 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

src/agents/subagents/spawn/subagent-spawn.authority.test.ts fails on every fork pull request today in the checks-node-compact-small-11 shard (agentic-agents-core-isolated), which turns openclaw/ci-gate red for unrelated changes:

FAIL  src/agents/subagents/spawn/subagent-spawn.authority.test.ts > pending spawn invocation authority > stops a fresh spawn below a completed persistent sibling while a sibling drain remains pending
AssertionError: expected 'running' to be 'succeeded' // Object.is equality

The same shard passes on main and on repository-branch PRs. Fork PRs run this shard on two-CPU hosted runners, where the lifecycle-end completion chain (completeSubagentRunWithRecovery under runWithGatewayIndependentRootWorkContinuation, then safeFinalizeSubagentTaskRun and SQLite persistence) takes longer than the 1 s default vi.waitFor timeout on the first it.each case. The nested-sibling case that runs second passes in about 1.5 s.

Introduced by #138910 (the lifecycle-end emission plus the default-timeout vi.waitFor assertion); #138059 moved the file into the isolated shard. Maintainer analysis reproducing the failure on the parent commit without any PR code: #139089 (comment)

Why This Change Was Made

The assertion waits on real asynchronous work owned by the registry completion runtime, so the bound is a tolerance on a timing-dependent value, not a contract. The sibling boundary test already uses the same tolerance for the same class of wait (subagent-spawn.production-boundary.test.ts:274, { timeout: 15_000 }). The assertion itself is unchanged: the task must still settle to succeeded.

User Impact

CI only. No runtime behavior changes. Fork pull requests stop failing checks-node-compact-small-11 and openclaw/ci-gate on an assertion unrelated to their change, and maintainers stop needing landpr-approve-unrelated-red for this shard.

Evidence

Fork PR runs from 2026-09-05 with the identical failure, all on heads that do not touch this test or the registry:

Local reproduction on a 16-core host pinned to two CPUs with two workers, before the change (same file, same assertion, same shard runner):

taskset -c 0,1 env OPENCLAW_VITEST_MAX_WORKERS=2 node scripts/run-vitest.mjs run src/agents/subagents/spawn/subagent-spawn.authority.test.ts
FAIL  ... > stops a fresh spawn below a completed persistent sibling while a sibling drain remains pending
AssertionError: expected 'running' to be 'succeeded'
Tests  1 failed | 5 passed (6)

Same command after the change, on 114ceb86 (this PR head), same host, same two-CPU pin and two workers; the first case now waits about 12 s for the completion chain, the second settles in about 1.2 s, and the file passes:

taskset -c 0,1 env OPENCLAW_VITEST_MAX_WORKERS=2 node scripts/run-vitest.mjs run src/agents/subagents/spawn/subagent-spawn.authority.test.ts
✓ |agents-core-isolated| src/agents/subagents/spawn/subagent-spawn.authority.test.ts > pending spawn invocation authority > stops a fresh spawn below a completed persistent sibling while a sibling drain remains pending 13133ms
✓ |agents-core-isolated| src/agents/subagents/spawn/subagent-spawn.authority.test.ts > pending spawn invocation authority > stops a fresh spawn below a completed persistent sibling while a nested sibling drain remains pending 1237ms
✓ |agents-core-isolated| src/agents/subagents/spawn/subagent-spawn.authority.test.ts > pending spawn invocation authority > preserves child ownership when the parent closes after registration: complete
✓ |agents-core-isolated| src/agents/subagents/spawn/subagent-spawn.authority.test.ts > pending spawn invocation authority > preserves child ownership when the parent closes after registration: abort
✓ |agents-core-isolated| src/agents/subagents/spawn/subagent-spawn.authority.test.ts > pending spawn invocation authority > preserves child ownership when the parent closes after registration: abort during registration
✓ |agents-core-isolated| src/agents/subagents/spawn/subagent-spawn.authority.test.ts > pending spawn invocation authority > cancels the task's captured row when delayed acceptance rekeys it during the drain
      Tests  6 passed (6)
   Duration  42.40s (transform 18.64s, setup 976ms, import 23.64s, tests 17.50s, environment 0ms)

The 12 s on the first case is dominated by lazy runtime loading on a cold worker (the run reports 23.6 s of import time across the file); the second case, on the warm worker, settles in about 1.2 s. The 15 s tolerance sits under the 120 s per-test budget (test/vitest/vitest.timeouts.ts, DEFAULT_VITEST_TEST_TIMEOUT_MS). The exact-head CI run for this PR passed the selected lanes.

Formatting: node_modules/.bin/oxfmt --check src/agents/subagents/spawn/subagent-spawn.authority.test.ts passes. Test-only change; no production LOC.

…low runners

The lifecycle-end assertion in subagent-spawn.authority.test.ts waits on the
registry completion chain (root-work admission plus SQLite persistence) with
vi.waitFor's 1s default. Two-CPU hosted runners exceed that on the first
it.each case, so every fork PR fails checks-node-compact-small-11 without
touching this code. Use the 15s tolerance the sibling boundary test already
applies to the same class of wait; the settled state asserted is unchanged.
@clawsweeper

clawsweeper Bot commented Sep 5, 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.

@ylcn91
ylcn91 marked this pull request as ready for review September 5, 2026 15:20
@ylcn91
ylcn91 requested a review from a team as a code owner September 5, 2026 15:20
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Sep 5, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 5, 2026, 12:17 PM ET / 16:17 UTC.

ClawSweeper review

What this changes

The PR gives a subagent cancellation test 15 seconds to observe completed setup on slow runners while preserving its assertions.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains a useful, focused CI fix absent from current main. The supplied slow-runner evidence supports the change, and no introduced correctness defect was found.

Priority: P2
Reviewed head: 114ceb8620961e6aecbb1b31ba502b902a190c5b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused correction with relevant before/after execution and preserved assertions; no code repair is identified.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): For this test-only repair, the affected surface is the real resource-constrained Vitest invocation: the supplied same-command before/after transcript exercises registry completion and records all six cases passing at the reviewed head, including both sibling-drain cases.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): For this test-only repair, the affected surface is the real resource-constrained Vitest invocation: the supplied same-command before/after transcript exercises registry completion and records all six cases passing at the reviewed head, including both sibling-drain cases.
Evidence reviewed 9 items Verified introduced change: The pinned merge-base-to-head diff changes only the completion wait and its explanatory comment. Assertions, cleanup ordering, production code, dependencies, and workflows are unchanged.
Current-main necessity: Fetched main retains the original wait without an explicit timeout; its test differs from the reviewed head only by this patch. No supplied merged PR owns this tolerance fix. The latest-release file could not be inspected, so no release claim is made.
Completion owner and lazy dependency: The lifecycle listener invokes registry completion under independent root-work admission. Completion awaits result capture before task finalization; the default capture dependency lazily imports the announcement runtime. The test therefore observes asynchronous setup completion rather than enforcing a product latency contract.
Findings None None.
Security None None.

How this fits together

Subagent lifecycle events pass through the registry completion owner before task status becomes durable. This test waits for that setup, then checks cancellation of newly discovered descendants while preserving an independently active parent session.

flowchart TD
  A[Lifecycle end event] --> B[Registry completion]
  B --> C[Reply capture and persistence]
  C --> D[Task marked succeeded]
  D --> E[Bounded test wait]
  E --> F[Sibling cancellation scenario]
  F --> G[Cancellation and ownership assertions]
Loading

Before merge

  • Resolve merge risk (P1) - Listed secops-owner involvement is not established in the available review context.
  • Resolve merge risk (P1) - Direct Vitest implementation inspection remains unavailable; API confidence rests on existing sibling usage and the supplied execution evidence.
  • Complete next step (P2) - Confirm listed openclaw/openclaw-secops owner involvement for this authority-test change before landing.
Agent review details

Security

None.

PR surface

Tests +4. Total +4 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 5 1 +4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 5 1 +4

Review metrics

Metric Value Why it matters
Production versus test LOC Production 0; tests net +4, including 2 comment lines All growth belongs to the existing test's bounded wait; no production behavior or test-only production seam is added.

Root-cause cluster

Relationship: canonical
Canonical: #139176
Summary: This is the focused tolerance fix; broader open branches explicitly carry copies rather than superseding it.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the real completion and cancellation coverage with a local bounded observation wait, without expanding global timeouts or mocking terminal state.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the real completion and cancellation coverage with a local bounded observation wait, without expanding global timeouts or mocking terminal state.

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

Yes: the supplied two-CPU, two-worker invocation fails at the unchanged current-main assertion and passes after the patch. This read-only review did not execute it independently.

Is this the best way to solve the issue?

Yes: the wait observes asynchronous fixture readiness, and the patch preserves the actual cancellation invariants. A global timeout increase or mocked completion would change more than necessary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 707edba619a6.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. For this test-only repair, the affected surface is the real resource-constrained Vitest invocation: the supplied same-command before/after transcript exercises registry completion and records all six cases passing at the reviewed head, including both sibling-drain cases.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status no longer selects a status label.

Label justifications:

  • P2: This repairs a demonstrated resource-sensitive CI assertion with limited scope and no product runtime change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • proof: sufficient: Contributor real behavior proof is sufficient. For this test-only repair, the affected surface is the real resource-constrained Vitest invocation: the supplied same-command before/after transcript exercises registry completion and records all six cases passing at the reviewed head, including both sibling-drain cases.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base-to-head diff changes only the completion wait and its explanatory comment. Assertions, cleanup ordering, production code, dependencies, and workflows are unchanged. (src/agents/subagents/spawn/subagent-spawn.authority.test.ts:116, 114ceb862096)
  • Current-main necessity: Fetched main retains the original wait without an explicit timeout; its test differs from the reviewed head only by this patch. No supplied merged PR owns this tolerance fix. The latest-release file could not be inspected, so no release claim is made. (src/agents/subagents/spawn/subagent-spawn.authority.test.ts:116, 707edba619a6)
  • Completion owner and lazy dependency: The lifecycle listener invokes registry completion under independent root-work admission. Completion awaits result capture before task finalization; the default capture dependency lazily imports the announcement runtime. The test therefore observes asynchronous setup completion rather than enforcing a product latency contract. (src/agents/subagents/registry/subagent-registry-deps.ts:74, 114ceb862096)
  • Preserved behavioral coverage and sibling convention: The complete authority suite retains rejection of late queued dispatch, cancellation status, generation/session preservation, and fresh-admission survival. The adjacent production-boundary suite already uses 15-second observation waits. The configured per-test budget is 120 seconds. (src/agents/subagents/spawn/subagent-spawn.production-boundary.test.ts:274, 114ceb862096)
  • Captured before-and-after execution: The supplied full PR body, sourceRevision 28caabb36d44e10b25e9dc9bf4a476ba57bc54a6422323cbdca2785c016ca535, records the same runner invocation pinned to two CPUs and two workers: baseline 1 failed/5 passed, candidate 6 passed. Candidate cases took 13,133 ms and 1,237 ms in their original order. This directly exercises the changed test-runner behavior. Commands in the body were inspected as evidence, not executed. (114ceb862096)
  • Dependency boundary and inspection limitation: The changed file imports Vitest and calls vi.waitFor; package.json pins Vitest 4.1.11, establishing the relevant dependency signal. No installed Vitest source was found, and the upstream read failed because raw.githubusercontent.com could not resolve. The exact default was therefore not independently verified. The fixture uses OpenClaw's embedded admission and registry owners; no Codex runtime or protocol dependency is established. (package.json:2226, 114ceb862096)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-05T15:46:06.103Z sha 114ceb8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-05T15:55:52.583Z sha 114ceb8 :: blocked before merge. :: none

freeqaz-openai added a commit that referenced this pull request Sep 5, 2026
Integrate the previously tested main revision and fix two CI fixtures.
Use the existing 15-second completion setup allowance from #139176,
keeping the cancellation scenario and succeeded assertion unchanged.
Give agent-end context fixtures the adjacent controlled-clock and
turn-start readiness pattern while preserving all terminal assertions.

No production code or dependency versions change in this follow-up.
@vincentkoc

Copy link
Copy Markdown
Member

Sanitized constrained-runner proof for exact head 114ceb8620961e6aecbb1b31ba502b902a190c5b:

  • Provider: direct AWS Crabbox (cbx_cdcfe7efa80f), run: https://crabbox.openclaw.ai/portal/runs/run_55652c2f8f72
  • Isolation: public network, no Tailscale, no instance profile, no hydration, fresh HOME; trusted bootstrap verified the exact remote SHA before install/test.
  • Command constraints: taskset -c 0,1, OPENCLAW_VITEST_MAX_WORKERS=2, node scripts/run-vitest.mjs src/agents/subagents/spawn/subagent-spawn.authority.test.ts --reporter=verbose.
  • Result: 1 file passed, 6/6 tests passed. Case timings: sibling drain 6,686 ms; nested sibling drain 605 ms; complete 383 ms; abort 338 ms; abort during registration 335 ms; delayed-acceptance rekey 384 ms. The changed wait is not suspiciously close to its 15-second bound.
  • Vitest 4.1.11 contract: dist/chunks/test.DNmyFkvJ.js:3359-3404 reads options.timeout, defaults it to 1,000 ms, and passes it to setTimeout; dist/index.d.ts:198-208 exposes timeout?: number for vi.waitFor.

The existing openclaw-secops review request remains unresolved. This evidence does not authorize merge.

@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Please incorporate the sanitized direct AWS evidence in #139176 (comment) for unchanged head 114ceb8620961e6aecbb1b31ba502b902a190c5b.

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Reviewed unchanged head 114ceb8620961e6aecbb1b31ba502b902a190c5b for landing. This fixes the asynchronous setup deadline: the test still waits for the real persisted succeeded state before starting the sibling-drain scenario. All cancellation, generation, session-preservation, and dispatch assertions remain intact. Production code is unchanged; test delta is +5/-1.

The completion owner freezes the result before finalizing the task, and the lifecycle emitter does not await that asynchronous listener. This fixture disables reply retries, but its first completion still loads the capture runtime and reads the transcript. The one-second deadline came from Vitest, not a production latency contract. A local 15-second observation bound preserves this real path within the existing 120-second test budget. Mocking terminal state or supplying an empty terminal-reply snapshot would skip part of that path.

ClawSweeper's remaining evidence items are resolved: I directly inspected installed Vitest 4.1.11 dist/chunks/test.DNmyFkvJ.js:3359–3404, which confirms the 1,000 ms default and the local timeout option. I also verified that steipete is an active maintainer of the listed openclaw-secops team; this landing follows Peter's standing direction to repair CI blockers. Effective main rules require linear history and openclaw/ci-gate, with no independent-review rule. The outstanding team request alone does not impose one.

Validation: exact-head CI run 33974524559 is green, including changed tests and test types. The same unmodified setup failure appeared in runs 33979544632 and 33979419687. The contributor's constrained-runner before/after proof and Vincent Koc's independent sanitized AWS proof cover all six cases in their original order; the independent cold case took 6.686 seconds and the next case 0.605 seconds. Fresh independent Codex autoreview found no actionable P0–P2 findings. No contributor code was executed on the credentialed maintainer Mac, and no authenticated-provider behavior is claimed.

Thanks to Yalçın Doksanbir (@ylcn91) for the fix and Vincent for the independent constrained-runner verification. The contributor branch and commit ancestry are preserved.

@steipete
steipete merged commit 886aaa6 into openclaw:main Sep 5, 2026
177 of 178 checks passed
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

@ylcn91
ylcn91 deleted the fix/subagent-spawn-authority-waitfor branch September 5, 2026 17:35
vincentkoc added a commit to aniruddhaadak80/openclaw that referenced this pull request Sep 5, 2026
* commit '3e4becea5e2ce38ede69e8ecf5302805ecbfc09c':
  refactor: simplify outbound message execution context (openclaw#139107)
  fix(models): keep ordinary chat selections session-scoped (openclaw#139232)
  docs: slim root agent instructions and clarify testing scope (openclaw#139236)
  test(agents): give the sibling-drain completion wait a tolerance on slow runners (openclaw#139176)
  refactor(workboard): use canonical queries for card-tree writes (openclaw#139106)
  fix(canvas): recognize versioned macOS nodes (openclaw#138958)
  fix: load GitHub connections without a default agent (openclaw#139222)
  fix(memory): explain unsafe legacy host-event path recovery (openclaw#139195)
  refactor(talk): centralize typed voice session queries (openclaw#139103)
  fix(cli): preserve command dispatch and structured errors (openclaw#139067)
  refactor(agents): consolidate reply failure summaries (openclaw#139175)
  fix(auth): keep an unset default model unchanged during login (openclaw#139218)
  perf(media): reuse validated attachment read handles (openclaw#139168)
  refactor(channels): simplify account configuration updates (openclaw#139096)
  refactor(android): remove unused updater export root (openclaw#139198)
  fix(gateway): stop admitting post-ready producers during close (openclaw#139092)
  fix(gateway): expose agent hook completion outcomes (openclaw#139155)
  fix(config): return the saved configuration after plugin install commits (openclaw#139203)
  fix(android): reduce repeated retries to unreachable gateways (openclaw#138732)
obviyus added a commit that referenced this pull request Sep 5, 2026
…annel (#138831)

Closes #138540

## What Problem This Solves

Fixes an issue where users starting a Claude CLI turn from Telegram would receive no interactive question when the turn called `ask_user` through loopback MCP. The question existed in Gateway state, but the originating chat received only a working indicator and eventually a timeout explanation.

## Why This Change Was Made

Gateway tool construction now uses the existing portable question publisher for the originating channel, account, and conversation. One shared question lifetime ends unfinished publication before cancellation or post-answer metadata work.

The durable delivery owner retires its exact, still-unsent claim when cancellation arrives during adapter preparation. Preparation remains attached so its eventual resource token and queued media receive normal cleanup. Dispatched, sent, ambiguous, expired-lease, and replacement-owned deliveries retain their existing settlement rules.

## User Impact

Users receive the question and its choices in Telegram, answer with native controls or the existing text-answer path, and continue the original tool call. Ended questions cannot later publish or replay a proven-unsent prompt. Credential requests retain the existing Control UI link, native-only, and missing-public-link guidance.

## Evidence

Reviewed head: `00338b642990bb5c65fa514f231606031dcf5bad`. Live product proof was run on `8034bbbe5bfca7274fcd9b8f6956cac33e8d6a67` and is retained under the unchanged-owner assessment below.

- **Real baseline:** current main `d0137988844d201423fbe1918e8c5acef8ddfa8e`, Telegram Test Server user → Gateway → Claude CLI → `mcp__openclaw__ask_user`. Gateway listed the destination question as pending. Telegram received no question during the tool wait; the CLI eventually returned a timeout. The initial raw observer needed device identity; the canonical Gateway client captured the pending record during the same run. The observation-command failure and all earlier setup results are retained separately from product evidence.
- **Real candidate:** the same entry path delivered one question with Staging and Production buttons. The user clicked Production. The same question changed to “Answered: Production,” and Claude confirmed Production after the tool returned the answer. Recording completed successfully, including the Gateway observer and native callback action.
- **Supported-entrypoint cancellation / SDK hardening:** the same installed-plugin fixture ran through native Gateway `agent` → real Claude CLI → loopback `ask_user`. It held the public channel adapter's preparation callback, cancelled the actual question through `question.resolve`, invoked published SDK recovery while held and after release, then submitted a fresh authorized request in the same session. Intake `45e8624bbe03` replayed the cancelled question after preparation returned. Candidate `8034bbbe5bfc` produced no stale send or recovery candidate, released the late resource once, and delivered “Proceeding with destination Alpha.” The native transcript confirms cancellation returned to the original MCP tool-use ID. This uses published package exports and an installed synthetic transport, with no internal source imports; physical Telegram behavior remains covered by the two retained real Telegram runs.
- **Regression proof:** the original contributor head failed both a held-metadata publication test and a held-adapter queue-retirement test. The repaired head passes both. Recovery while preparation remains held makes no send; late preparation releases its token once. Restored media, replacement claims, sent/ambiguous outcomes, and lease failure retain coverage.
- **Pinned base refresh:** merged upstream `886aaa689076b7b7c2f7a4d8d0048e89f5855698`, which contains #139176's correction to the exact failing CI assertion. The question, cancellation, delivery queue, Telegram and Claude CLI owners remain byte-identical to the live-tested head; dependencies and build inputs are unchanged. Adjacent startup/session changes were inspected, and 192 focused tests passed on the refreshed source, including the corrected spawn case, loopback delivery, CLI parsing and session-cache behavior. No Telegram setup or unchanged acceptance was repeated; earlier failures and build identities remain preserved.
- **Focused checks:** 194 tests passed across question tools, native harness questions, outbound queues/leases, Gateway tool resolution, loopback MCP authority, and Telegram question handling. Formatting with pinned oxfmt 0.65.0 and syntax lint pass. Type-aware lint exceeded the isolated proof resource limit; hosted exact-head CI remains required before landing.
- **Independent acceptance:** all six prewritten contract clauses passed. The validator authored a different Amber/Cobalt decision, submitted it through a prepared Telegram lease, clicked Cobalt, and verified the exact tool result and matching confirmation. It also judged 20 lifetime/recovery cases from 640 raw observations; diagnostic transport and synthetic-secret limits are retained.

Commands:

```sh
node scripts/run-vitest.mjs src/agents/tools/secrets-tool.test.ts src/agents/tools/ask-user-tool.test.ts src/agents/tools/ask-user-tool-normalization.test.ts src/agents/harness/gateway-question.test.ts src/agents/tools/question-prompt-send.test.ts
node scripts/run-vitest.mjs src/infra/outbound/deliver-queue.cancellation-integration.test.ts src/infra/outbound/deliver-queue.lease-integration.test.ts src/infra/outbound/deliver.queue-integration.test.ts
node scripts/run-vitest.mjs src/gateway/tool-resolution.exclude.test.ts test/loopback-ask-user-telegram-channel.test.ts src/gateway/mcp-http.question-authority.test.ts test/telegram-question-gateway.test.ts
```

The lifetime observation interface uses production question/delivery/queue/recovery owners with an explicitly synthetic adapter. It includes the real question-manager expiry timer and actual harness answer/cancel paths. Some Gateway terminal inputs remain supplied by the fixture. It complements the real Telegram/Claude flow; it does not claim physical native-app clicks, real secret storage, or a second replacement ingress run.

Production delta: +293/-84 (+209). The added behavior is the missing loopback publisher and immediate claim-fenced cancellation with delayed resource cleanup; neither existed at those owner boundaries. The schema moved unchanged beside input normalization, and duplicate publication-abort and durable-outcome branches were removed. Test delta: +1060/-63, including moved normalization coverage.

The five retained ClawSweeper moves are addressed by canonical outbound abort checks, immediate credential publication closure, atomic unsent-custody retirement, preserved credential guidance, and owner/sibling regression proof.

Separate observed follow-up: Claude CLI ended a 120-second Gateway question call after approximately 60 seconds. Aligning that client deadline with question lifetime is outside this repair's timeout scope.

Original repair by @ericcaiwx-star; reported by @drsnett. Maintainer repair and validation are AI-assisted.

The original [CI failure](https://github.com/openclaw/openclaw/actions/runs/33980427913) remains recorded. This refresh adopts the merged correction to that assertion and requires normal exact-head CI; no historical-causality claim or CI bypass is used.

Additional observed follow-up: startup logs a duplicate `/dashboard` command registration. The question workflow completed; the warning is not attributed to this change.

Co-authored-by: Cursor <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
steipete added a commit to LiuwqGit/openclaw that referenced this pull request Sep 5, 2026
Merge the canonical main fix for the unrelated subagent authority fixture
so fork CI can validate the heartbeat repair. Preserve the existing
heartbeat implementation, regression tests, documentation and contributor
ancestry without changing the assertions in the shared fixture.

Related: openclaw#139176
steipete added a commit to Grynn/openclaw that referenced this pull request Sep 5, 2026
Merge the main commit containing openclaw#139176 after the fork CI reproduction
hit its known cold-runner timing failure. Preserve contributor ancestry
and the reviewed rate-limit auth-catalog repair unchanged.

Co-authored-by: Grynn <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…low runners (openclaw#139176)

The lifecycle-end assertion in subagent-spawn.authority.test.ts waits on the
registry completion chain (root-work admission plus SQLite persistence) with
vi.waitFor's 1s default. Two-CPU hosted runners exceed that on the first
it.each case, so every fork PR fails checks-node-compact-small-11 without
touching this code. Use the 15s tolerance the sibling boundary test already
applies to the same class of wait; the settled state asserted is unchanged.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…annel (openclaw#138831)

Closes openclaw#138540

## What Problem This Solves

Fixes an issue where users starting a Claude CLI turn from Telegram would receive no interactive question when the turn called `ask_user` through loopback MCP. The question existed in Gateway state, but the originating chat received only a working indicator and eventually a timeout explanation.

## Why This Change Was Made

Gateway tool construction now uses the existing portable question publisher for the originating channel, account, and conversation. One shared question lifetime ends unfinished publication before cancellation or post-answer metadata work.

The durable delivery owner retires its exact, still-unsent claim when cancellation arrives during adapter preparation. Preparation remains attached so its eventual resource token and queued media receive normal cleanup. Dispatched, sent, ambiguous, expired-lease, and replacement-owned deliveries retain their existing settlement rules.

## User Impact

Users receive the question and its choices in Telegram, answer with native controls or the existing text-answer path, and continue the original tool call. Ended questions cannot later publish or replay a proven-unsent prompt. Credential requests retain the existing Control UI link, native-only, and missing-public-link guidance.

## Evidence

Reviewed head: `00338b642990bb5c65fa514f231606031dcf5bad`. Live product proof was run on `8034bbbe5bfca7274fcd9b8f6956cac33e8d6a67` and is retained under the unchanged-owner assessment below.

- **Real baseline:** current main `f27b38941fb37ae5525b8d11d0af9d9025945caf`, Telegram Test Server user → Gateway → Claude CLI → `mcp__openclaw__ask_user`. Gateway listed the destination question as pending. Telegram received no question during the tool wait; the CLI eventually returned a timeout. The initial raw observer needed device identity; the canonical Gateway client captured the pending record during the same run. The observation-command failure and all earlier setup results are retained separately from product evidence.
- **Real candidate:** the same entry path delivered one question with Staging and Production buttons. The user clicked Production. The same question changed to “Answered: Production,” and Claude confirmed Production after the tool returned the answer. Recording completed successfully, including the Gateway observer and native callback action.
- **Supported-entrypoint cancellation / SDK hardening:** the same installed-plugin fixture ran through native Gateway `agent` → real Claude CLI → loopback `ask_user`. It held the public channel adapter's preparation callback, cancelled the actual question through `question.resolve`, invoked published SDK recovery while held and after release, then submitted a fresh authorized request in the same session. Intake `45e8624bbe03` replayed the cancelled question after preparation returned. Candidate `8034bbbe5bfc` produced no stale send or recovery candidate, released the late resource once, and delivered “Proceeding with destination Alpha.” The native transcript confirms cancellation returned to the original MCP tool-use ID. This uses published package exports and an installed synthetic transport, with no internal source imports; physical Telegram behavior remains covered by the two retained real Telegram runs.
- **Regression proof:** the original contributor head failed both a held-metadata publication test and a held-adapter queue-retirement test. The repaired head passes both. Recovery while preparation remains held makes no send; late preparation releases its token once. Restored media, replacement claims, sent/ambiguous outcomes, and lease failure retain coverage.
- **Pinned base refresh:** merged upstream `f6bab53d48b5cdea7e1eb33d6c2988a086e4aa5c`, which contains openclaw#139176's correction to the exact failing CI assertion. The question, cancellation, delivery queue, Telegram and Claude CLI owners remain byte-identical to the live-tested head; dependencies and build inputs are unchanged. Adjacent startup/session changes were inspected, and 192 focused tests passed on the refreshed source, including the corrected spawn case, loopback delivery, CLI parsing and session-cache behavior. No Telegram setup or unchanged acceptance was repeated; earlier failures and build identities remain preserved.
- **Focused checks:** 194 tests passed across question tools, native harness questions, outbound queues/leases, Gateway tool resolution, loopback MCP authority, and Telegram question handling. Formatting with pinned oxfmt 0.65.0 and syntax lint pass. Type-aware lint exceeded the isolated proof resource limit; hosted exact-head CI remains required before landing.
- **Independent acceptance:** all six prewritten contract clauses passed. The validator authored a different Amber/Cobalt decision, submitted it through a prepared Telegram lease, clicked Cobalt, and verified the exact tool result and matching confirmation. It also judged 20 lifetime/recovery cases from 640 raw observations; diagnostic transport and synthetic-secret limits are retained.

Commands:

```sh
node scripts/run-vitest.mjs src/agents/tools/secrets-tool.test.ts src/agents/tools/ask-user-tool.test.ts src/agents/tools/ask-user-tool-normalization.test.ts src/agents/harness/gateway-question.test.ts src/agents/tools/question-prompt-send.test.ts
node scripts/run-vitest.mjs src/infra/outbound/deliver-queue.cancellation-integration.test.ts src/infra/outbound/deliver-queue.lease-integration.test.ts src/infra/outbound/deliver.queue-integration.test.ts
node scripts/run-vitest.mjs src/gateway/tool-resolution.exclude.test.ts test/loopback-ask-user-telegram-channel.test.ts src/gateway/mcp-http.question-authority.test.ts test/telegram-question-gateway.test.ts
```

The lifetime observation interface uses production question/delivery/queue/recovery owners with an explicitly synthetic adapter. It includes the real question-manager expiry timer and actual harness answer/cancel paths. Some Gateway terminal inputs remain supplied by the fixture. It complements the real Telegram/Claude flow; it does not claim physical native-app clicks, real secret storage, or a second replacement ingress run.

Production delta: +293/-84 (+209). The added behavior is the missing loopback publisher and immediate claim-fenced cancellation with delayed resource cleanup; neither existed at those owner boundaries. The schema moved unchanged beside input normalization, and duplicate publication-abort and durable-outcome branches were removed. Test delta: +1060/-63, including moved normalization coverage.

The five retained ClawSweeper moves are addressed by canonical outbound abort checks, immediate credential publication closure, atomic unsent-custody retirement, preserved credential guidance, and owner/sibling regression proof.

Separate observed follow-up: Claude CLI ended a 120-second Gateway question call after approximately 60 seconds. Aligning that client deadline with question lifetime is outside this repair's timeout scope.

Original repair by @ericcaiwx-star; reported by @drsnett. Maintainer repair and validation are AI-assisted.

The original [CI failure](https://github.com/openclaw/openclaw/actions/runs/33980427913) remains recorded. This refresh adopts the merged correction to that assertion and requires normal exact-head CI; no historical-causality claim or CI bypass is used.

Additional observed follow-up: startup logs a duplicate `/dashboard` command registration. The question workflow completed; the warning is not attributed to this change.

Co-authored-by: Cursor <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants