Skip to content

fix(auto-reply): keep followup queue drains alive after the triggering request ends - #148025

Merged
Patrick-Erichsen merged 3 commits into
openclaw:mainfrom
xialonglee:fix/gap-followup-drain-detached-scope
Oct 1, 2026
Merged

Patrick-Erichsen merged 3 commits into
openclaw:mainfrom
xialonglee:fix/gap-followup-drain-detached-scope

Conversation

@xialonglee

@xialonglee xialonglee commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Relates to gap finding: gap-followup-drain-detached-scope (bug-dig, evidence level A)

What Problem This Solves

Fixes: queued follow-up messages are silently dropped when a follow-up queue drain runs after its triggering request has already settled, in gateway setups where debounce or retries defer the drain past the end of the enqueueing turn.

User Impact

User impact: queued follow-up turns now complete instead of vanishing when the drain outlives the request that enqueued them; operators no longer see repeating "followup queue drain failed" error logs for a queue that can never make progress.

Why This Change Was Made

scheduleFollowupDrain launched its drain through runWithGatewayIndependentRootWorkContinuation, which gives the detached chain its own admission root but leaves it inheriting the triggering request's AsyncWorkScope. The queue drain outlives its enqueue request by design (debounce and retries), so once the request settles and its scope closes, tracked agent work inside a drained turn rejects with "Async work scope is closed". That error is neither a deferred-run signal nor a restart-drain signal, so the drain loop logs it and reschedules against the same closed scope forever — the queued follow-up is never delivered. Switching the call site to runWithGatewayDetachedWorkContinuation (the primitive added in #144801 and already used for post-ack webhook work, session auto-reset, and session announcements) gives the drain its own fresh async work scope, so drained turns keep tracking work after the triggering request's scope has closed. This is the remaining un-fixed call site of that family on current main.

Follow-up (not in scope): other runWithGatewayIndependentRootWorkContinuation call sites (e.g. the conditional branch in src/hooks/bundled/session-memory/handler.ts) may share this pattern; each needs its own defect evidence before switching, matching how #144801/#146350/#147150 landed one proven site at a time.

Evidence

Regression test src/auto-reply/reply/queue.drain-scope.test.ts models the embedded-agent-runner entry (ambient scope tracker bridge) for a drained queued turn and fails deterministically on unpatched code at the original defect.

Real Gateway behavior — production follow-up drain after an actual request-scope closure (a2a webhook ingress, discriminating before/after)

The bundled a2a channel ingress dispatches each inbound webhook inside runDetachedWebhookWork (src/plugin-sdk/webhook-request-guards.ts), which owns a fresh detached AsyncWorkScope per request. A SendMessage with returnImmediately acks first; that scope closes once the enqueue settles. With messages.queue.mode: "followup", a second inbound while turn 1 holds the wait tool is enqueued, and the debounced drain only runs after turn 1 settles — i.e. strictly after the triggering request's scope has closed. The production Gateway, real auto-reply queue/drain, embedded-agent run, and HTTP reply delivery to the a2a peer URL are all exercised; only the LLM is a deterministic mock fixture. Harness: extensions/qa-lab qa-gateway child + bundled a2a channel + local proof sink + mock-openai server (proof-only, not committed); run on the rebased branch (OpenClaw 2026.9.4, 28f598e93c8).

AFTER (this branch), node scripts/run-vitest.mjs extensions/qa-lab/src/proof-148025-followup-drain-after-request-close.e2e.test.ts passes:

 ✓ delivers the queued follow-up reply after the triggering a2a request scope closed 71109ms
 Test Files  1 passed (1)
      Tests  1 passed (1)
[proof] t+31.0s first a2a task accepted: c9fb4a79-fb00-4dec-a85e-755bbc761575
[proof] t+34.1s first turn running with wait tool in flight (session agent:qa:a2a:default:direct:proof-peer:proof-followup-drain)
[proof] t+34.1s second a2a request acked (task 2d9b7ca7-8bfc-4ae9-94a1-4ec9a0dba1e1); its detached request scope closes after the enqueue settles
[proof] t+65.1s queued follow-up reply delivered over HTTP: delivered t+65.0s (request acked t+34.0s)
[proof] t+65.2s session settled after delivery: status=done user=2
[proof] scope/drain error lines: 0

Gateway log (excerpt): the queued follow-up is enqueued while turn 1 runs; its dispatch completes in 78ms (request ends); the drain creates the queued turn only after turn 1's 30s wait settles, and the reply GATEWAY_REPEATED_REQUEST_QUEUED_OK is POSTed to the peer URL 31s after the enqueue request ended:

2026-09-15T10:59:45.592+08:00 [diagnostic] message queued: ... messageId=proof-msg-2 ... queueDepth=2 sessionState=processing
2026-09-15T10:59:45.687+08:00 [diagnostic] message dispatch completed: ... messageId=proof-msg-2 ... duration=78ms
... (turn 1 finishes its 30s wait; drain runs the queued turn) ...
[proof] t+65.0s sink receipt: GATEWAY_REPEATED_REQUEST_QUEUED_OK delivered to peer URL over HTTP

Cleanup and root release: the drained turn settles (run_completed, session done, user=2), zero Async work scope is closed / drain-failure lines appear in the debug log, and the harness's gateway stop() returns with zero errors, so every admitted root released cleanly.

BEFORE (only src/auto-reply/reply/queue/drain.ts reverted to the upstream/main call site, same tree, same harness), the identical run fails and the defect fires in the production Gateway:

[proof] t+32.4s second a2a request acked (task 985b7d91-c57d-47f3-a5ac-562cbedeae7b); its detached request scope closes after the enqueue settles
Error: timed out after 300000ms (last=1 sink receipts so far)
 Test Files  1 failed (1)
2026-09-15T11:22:56.355+08:00 [diagnostic] message received: ... messageId=proof-msg-2 ...
2026-09-15T11:22:56.471+08:00 [diagnostic] message processed: ... messageId=proof-msg-2 ... duration=112ms
2026-09-15T11:23:26.626+08:00 [diagnostic] session turn created: runId=ebae7a1f-... (drain starts the queued turn 30s later, after turn 1 settles and the triggering scope has closed)
2026-09-15T11:23:26.660+08:00 Embedded agent failed before reply: Async work scope is closed

The sink receives only turn 1's reply; the queued follow-up is never delivered — the exact defect this patch repairs, reproduced through the real request-scope closure. Re-applying the one-line call-site switch restores delivery (the AFTER run above).

Regression suites (rebased branch, upstream/main = 9153127)

  • queue.drain-scope.test.ts plus all queue test files and src/process/gateway-work-admission.test.ts: 8 files, 191 tests passed; admission suite 40 tests passed (node scripts/run-vitest.mjs <files>).
  • The CI failure on the previous head (checks-node-compact-small-12, docker-build-helper.test.ts > covers plugin CLI sources in the Docker plugin sweep) came from the stale base; on the rebased branch that test passes locally (353 passed; the only 3 local failures are environment-specific service-install probes that pass in CI).
  • Typecheck: tsconfig.core.json core lane and tsconfig.core.test.messaging.json test shard both exit 0.
  • Lint/format: run-oxlint.mjs (oxlint.core.json) zero findings; oxfmt --check clean on the changed files.

Not run: full 88-shard CI locally (PR CI covers it); the earlier qa-channel trace did not create a per-request scope, so it is superseded by the a2a proof above.

Maintainer follow-up: current CI test cost

Public CI job checks-node-changed-4 measured the focused regression at PR head 8ce7cb9e9606 (GitHub test merge 79b8eb1e5a905b08a91ca6769acac18179b271e5):

  • queue.drain-scope.test.ts: 1 test passed; test case 4 ms.
  • Vitest duration: 36.51 s; focused child wrapper: 38.20 s; exit 0.
  • Actual CI command: time -p node --import tsx scripts/ci-run-node-test-shard.mts; the focused child used Bun, vitest.unit-fast.config.ts, and inner parallelism 1 on the documented two-CPU runner.

Use these public CI measurements for the review's test-cost follow-up. The separate local pnpm test src/auto-reply/reply/queue.drain-scope.test.ts --maxWorkers=1 wall-time measurement is skipped: CI records the cost of the execution path and runner actually used to gate this head. The earlier Gateway trace above retains its original revision and attribution.

The final Doctor fixture checkpoint changes one test line so its fake Gateway PID differs from the test process and parent; production code and assertions are unchanged.

@clawsweeper

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

@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 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 6:23 AM ET / 10:23 UTC (Revision 9).

ClawSweeper review

What this changes

The PR gives queued follow-up replies an independent work lifetime, adds deterministic scope-closure coverage, and prevents a Doctor test’s fake Gateway PID from matching its mocked process ancestry.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: current main and the latest release retain the faulty continuation. No actionable patch defects remain, and the recorded CI cost addresses the previous review’s measurement follow-up.

Priority: P2
Reviewed head: 8ce7cb9e9606bf77815b98162879f1a8bbcb3082

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct repair with strong production-boundary proof and deterministic regression coverage.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): Recorded Gateway/A2A logs exercise the production follow-up drain after actual request-scope closure and show delayed HTTP reply delivery, session settlement, and clean shutdown after the same continuation repair. The model is a deterministic fixture; later changes add deterministic test ordering and a synthetic PID adjustment. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): Recorded Gateway/A2A logs exercise the production follow-up drain after actual request-scope closure and show delayed HTTP reply delivery, session settlement, and clean shutdown after the same continuation repair. The model is a deterministic fixture; later changes add deterministic test ordering and a synthetic PID adjustment. No stored-data contract changes.
Evidence reviewed 8 items Verified introduced patch: The pinned merge-base-to-head diff changes the drain’s existing continuation call, adds a scope-closure regression, and adjusts one synthetic Doctor PID. Diff whitespace checks passed; no tests or contributor code were executed.
Current main still needs the repair: Fetched main still starts the follow-up drain through the independent-root continuation, which preserves the ambient async-work scope. The shared scope owner rejects tracking after closure, matching the reported delayed-turn failure.
Latest-release check: The v2026.9.7 source also uses the independent-root continuation at the follow-up drain; the requested caller repair is not present in that release.
Findings None None.
Security None None.

How this fits together

OpenClaw’s follow-up queue holds incoming messages while an agent is busy, then starts later agent turns and delivers their replies. Gateway work admission tracks those delayed turns through completion and shutdown.

flowchart TD
  A[Incoming message] --> B[Follow-up queue]
  B --> C[Debounce and reply-lane wait]
  C --> D[Independent drain lifetime]
  D --> E[Agent turn]
  E --> F[Reply delivery]
  E --> G[Tracked cleanup and root release]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +2, Tests +85. Total +87 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 3 +2
Tests 2 86 1 +85
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 91 4 +87

Review metrics

Metric Value Why it matters
Focused regression cost Reported: 4 ms case; 36.51 s Vitest; 38.20 s wrapper The current-head CI measurement makes the regression’s execution and startup cost visible and addresses the prior timing follow-up.

Technical review

Best possible solution:

Use the existing detached continuation for queue-owned work while preserving source cancellation, current authority checks, and Gateway shutdown accounting.

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

Yes: current source establishes the closed-scope tracking failure, and the contributor records discriminating Gateway before/after delivery traces. This read-only review did not execute a current-main reproduction.

Is this the best way to solve the issue?

Yes: reusing the established detached-work owner repairs the caller’s lifetime without adding a parallel mechanism or changing queue configuration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9ced5fc07dae.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded lifecycle repair for queued replies that outlive their triggering request.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): Recorded Gateway/A2A logs exercise the production follow-up drain after actual request-scope closure and show delayed HTTP reply delivery, session settlement, and clean shutdown after the same continuation repair. The model is a deterministic fixture; later changes add deterministic test ordering and a synthetic PID adjustment. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded Gateway/A2A logs exercise the production follow-up drain after actual request-scope closure and show delayed HTTP reply delivery, session settlement, and clean shutdown after the same continuation repair. The model is a deterministic fixture; later changes add deterministic test ordering and a synthetic PID adjustment. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • steipete: 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 (8 earlier review cycles)
  • reviewed 2026-09-14T07:03:44.990Z sha 1ede44dca66c2361565de0cbad3b929a305bde62 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-14T09:47:00.730Z sha 21c02ba7077ac4ed0ce11bbcaf86109a9543c2da :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-15T03:40:14.332Z sha 28f598e93c88d4be4726d068ebe886c5e300eb5a :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T04:18:54.396Z sha 21eb1c912cbf6384ea16c070d75a2819c585f6b7 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-24T05:54:23.098Z sha 21eb1c912cbf6384ea16c070d75a2819c585f6b7 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-01T06:40:09.030Z sha d1247b0aada2619f88a5b79c36e22e32d6b9e3a1 :: needs changes before merge. :: [P3] Replace the regression's wall-clock sleep with a completion signal
  • reviewed 2026-10-01T07:17:40.117Z sha e53fa8c :: needs changes before merge. :: none
  • reviewed 2026-10-01T10:00:52.351Z sha 8ce7cb9 :: needs changes before merge. :: none

@xialonglee
xialonglee force-pushed the fix/gap-followup-drain-detached-scope branch from 1ede44d to 21c02ba Compare September 14, 2026 09:32
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 14, 2026
@fuller-stack-dev fuller-stack-dev self-assigned this Sep 14, 2026
obviyus added a commit that referenced this pull request Sep 15, 2026
…pe is closed" before the agent replies (#148548)

Related: #144801, #148025

## What Problem This Solves

Fixes LINE messages failing with “Something went wrong while processing your request” before the agent replies. SMS and Zalo use the same webhook pump.

## User Impact

Turns can answer, wait for an exec approval, and answer queued follow-ups after the first turn ends. No configuration or migration is required.

## Why This Change Was Made

The ingress drain starts dispatches that outlive the pump. Dispatch now leaves the pump's async-work scope while retaining its existing Gateway root until the task settles. Claim settlement and cancellation are unchanged. Cleanup after dispatch no longer holds the incidental webhook root; independently owned plugin cleanup keeps its own lifetime.

## Evidence

- A self-signed POST to `/line/webhook` on an isolated Gateway reproduced `Async work scope is closed` on main `a81fd6123fdc`, with a failed transcript turn and no inference request.
- The repaired dispatch completed the same flow with synthetic credentials and a local receiver: ordinary reply, approval prompt, denial, approval-turn answer, queued answer, and next answer. All six sends arrived. The dedicated `openclaw approvals pending` and `openclaw approvals resolve <id> deny` commands drove the real approval.
- 251 tests across 23 owner/channel files passed on merge `5384b5a718a2` with main `62a4d0c547bc`. Both new lifetime tests fail with the original production code. Type, lint, format, export, architecture and test-partition checks pass.
- The original Bash CI timeout did not reproduce in six focused head/base/merge/parent controls. Full CI remains pending on the repaired head.

This pass proves the Gateway and delivery boundary, not live LINE service delivery. The contributor also recorded real LINE push receipts at `138cd4fb4b1b`.

## Consumers

The shared monitor and plugin state API use the drain. LINE, SMS and Zalo supply detached webhook pumps; boot-started Discord is a scope-free sibling. Public plugin signatures stay unchanged.

## Dispatch and cleanup ownership

The owner's intended boundary is: “the completed pump must not be held open for unrelated follow-ups.” Dispatch leaves the pump's async-work scope and retains an existing live Gateway root until dispatch settles. The incidental webhook root then releases. Required plugin cleanup keeps its separate owner and existing shutdown bounds.

The decision to leave the pump scope is made once, by `runClaimed` in `src/channels/message/ingress-drain.ts`. Production changes are +10/−2 lines, net +8, across the dispatch owner and its private storage helper. Claim settlement, cancellation, restart admission, and completed-message deduplication remain unchanged.

## Evidence boundaries

The signed `/line/webhook` experiment used a real isolated Gateway, synthetic credentials, deterministic inference, and a local LINE request receiver. It captured an ordinary answer, approval prompt, denial notice, approval-turn answer, queued answer, and next answer. Recipient delivery through the real LINE service is not proved by this experiment.

The live green build was `6c7067918343`; production bytes are identical at `2b94019ae275`. The final commit changes only an optional test callback invocation. All 251 selected tests passed on merge `5384b5a718a2`, with parents `2b94019ae275` and main `62a4d0c547bc`. Restoring the original production code makes both new lifetime tests fail.

The live approval sequence includes #148228. The fresh merge also includes #148301; its reply-source receipt uses separate state that the dispatch scope exit preserves. The live sequence does not include #148301, and this validation does not claim a new streamed-tail recovery experiment.

The earlier Bash failure remains classified as a non-reproduced child startup/import timeout. Six focused head, base, merge, and relevant-parent controls passed. Different hosted runtime and shard conditions prevent treating those local passes as proof that the timeout cannot recur. Hosted CI remains a separate landing check.

Co-authored-by: Ayaan Zaidi <[email protected]>
@xialonglee
xialonglee force-pushed the fix/gap-followup-drain-detached-scope branch from 21c02ba to 28f598e Compare September 15, 2026 03:30
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 15, 2026
@xialonglee
xialonglee force-pushed the fix/gap-followup-drain-detached-scope branch from 28f598e to 21eb1c9 Compare September 15, 2026 04:13
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
…pe is closed" before the agent replies (openclaw#148548)

Related: openclaw#144801, openclaw#148025

## What Problem This Solves

Fixes LINE messages failing with “Something went wrong while processing your request” before the agent replies. SMS and Zalo use the same webhook pump.

## User Impact

Turns can answer, wait for an exec approval, and answer queued follow-ups after the first turn ends. No configuration or migration is required.

## Why This Change Was Made

The ingress drain starts dispatches that outlive the pump. Dispatch now leaves the pump's async-work scope while retaining its existing Gateway root until the task settles. Claim settlement and cancellation are unchanged. Cleanup after dispatch no longer holds the incidental webhook root; independently owned plugin cleanup keeps its own lifetime.

## Evidence

- A self-signed POST to `/line/webhook` on an isolated Gateway reproduced `Async work scope is closed` on main `4e8dd8e1859f`, with a failed transcript turn and no inference request.
- The repaired dispatch completed the same flow with synthetic credentials and a local receiver: ordinary reply, approval prompt, denial, approval-turn answer, queued answer, and next answer. All six sends arrived. The dedicated `openclaw approvals pending` and `openclaw approvals resolve <id> deny` commands drove the real approval.
- 251 tests across 23 owner/channel files passed on merge `5384b5a718a2` with main `d229f4a2ba41`. Both new lifetime tests fail with the original production code. Type, lint, format, export, architecture and test-partition checks pass.
- The original Bash CI timeout did not reproduce in six focused head/base/merge/parent controls. Full CI remains pending on the repaired head.

This pass proves the Gateway and delivery boundary, not live LINE service delivery. The contributor also recorded real LINE push receipts at `138cd4fb4b1b`.

## Consumers

The shared monitor and plugin state API use the drain. LINE, SMS and Zalo supply detached webhook pumps; boot-started Discord is a scope-free sibling. Public plugin signatures stay unchanged.

## Dispatch and cleanup ownership

The owner's intended boundary is: “the completed pump must not be held open for unrelated follow-ups.” Dispatch leaves the pump's async-work scope and retains an existing live Gateway root until dispatch settles. The incidental webhook root then releases. Required plugin cleanup keeps its separate owner and existing shutdown bounds.

The decision to leave the pump scope is made once, by `runClaimed` in `src/channels/message/ingress-drain.ts`. Production changes are +10/−2 lines, net +8, across the dispatch owner and its private storage helper. Claim settlement, cancellation, restart admission, and completed-message deduplication remain unchanged.

## Evidence boundaries

The signed `/line/webhook` experiment used a real isolated Gateway, synthetic credentials, deterministic inference, and a local LINE request receiver. It captured an ordinary answer, approval prompt, denial notice, approval-turn answer, queued answer, and next answer. Recipient delivery through the real LINE service is not proved by this experiment.

The live green build was `6c7067918343`; production bytes are identical at `2b94019ae275`. The final commit changes only an optional test callback invocation. All 251 selected tests passed on merge `5384b5a718a2`, with parents `2b94019ae275` and main `d229f4a2ba41`. Restoring the original production code makes both new lifetime tests fail.

The live approval sequence includes openclaw#148228. The fresh merge also includes openclaw#148301; its reply-source receipt uses separate state that the dispatch scope exit preserves. The live sequence does not include openclaw#148301, and this validation does not claim a new streamed-tail recovery experiment.

The earlier Bash failure remains classified as a non-reproduced child startup/import timeout. Six focused head, base, merge, and relevant-parent controls passed. Different hosted runtime and shard conditions prevent treating those local passes as proof that the timeout cannot recur. Hosted CI remains a separate landing check.

Co-authored-by: Ayaan Zaidi <[email protected]>
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 15, 2026
obviyus added a commit that referenced this pull request Sep 20, 2026
Closes #152105

## What Problem This Solves

Fixes: A2A tasks return a model-fallback notice instead of the agent's answer when a failed primary model is followed by a successful fallback.

## User Impact

A2A clients receive the actual answer in the completed task artifact. Authentication, task retention, cancellation behavior, and the A2A protocol are unchanged.

## Why This Change Was Made

A delivery marked `final` can still be a supplemental notice preceding the answer. A2A now uses the existing terminal-reply classifier through the reply-payload SDK instead of treating every final-lane payload as task completion. The SDK contract documents that classification is separate from content, sendability, and authority checks.

## Evidence

- Actual CLI-started Gateway, registered A2A JSON-RPC endpoints, and a local OpenAI-compatible HTTP provider: a primary HTTP 503 followed by a successful fallback returned only the fallback notice before the change and the exact answer afterward. Public chat history independently retained the answer in both cases.
- Ordinary replies, terminal HTTP 401 diagnostics, cross-peer task isolation, both unsupported cancellation aliases, and slash-command rejection were exercised. Built runtime provenance and a separate public SDK consumer verified the shared classifier.
- 207 focused tests passed; the A2A regression fails on the original production code. Build, scoped type-aware lint, documentation syntax, line-limit ratchets, SDK export registration, and the approved SDK surface check passed.
- Known separate failure: the second queued followup stalls with `Async work scope is closed` on both baseline and candidate, consistent with the separately owned #148025 work. This PR does not claim an all-green queued-delivery flow or repair that lifecycle.

The provider was a controlled local fixture; no paid-provider, native-client, or broader notice-only/TTS/abort proof is claimed.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
Closes openclaw#152105

## What Problem This Solves

Fixes: A2A tasks return a model-fallback notice instead of the agent's answer when a failed primary model is followed by a successful fallback.

## User Impact

A2A clients receive the actual answer in the completed task artifact. Authentication, task retention, cancellation behavior, and the A2A protocol are unchanged.

## Why This Change Was Made

A delivery marked `final` can still be a supplemental notice preceding the answer. A2A now uses the existing terminal-reply classifier through the reply-payload SDK instead of treating every final-lane payload as task completion. The SDK contract documents that classification is separate from content, sendability, and authority checks.

## Evidence

- Actual CLI-started Gateway, registered A2A JSON-RPC endpoints, and a local OpenAI-compatible HTTP provider: a primary HTTP 503 followed by a successful fallback returned only the fallback notice before the change and the exact answer afterward. Public chat history independently retained the answer in both cases.
- Ordinary replies, terminal HTTP 401 diagnostics, cross-peer task isolation, both unsupported cancellation aliases, and slash-command rejection were exercised. Built runtime provenance and a separate public SDK consumer verified the shared classifier.
- 207 focused tests passed; the A2A regression fails on the original production code. Build, scoped type-aware lint, documentation syntax, line-limit ratchets, SDK export registration, and the approved SDK surface check passed.
- Known separate failure: the second queued followup stalls with `Async work scope is closed` on both baseline and candidate, consistent with the separately owned openclaw#148025 work. This PR does not claim an all-green queued-delivery flow or repair that lifecycle.

The provider was a controlled local fixture; no paid-provider, native-client, or broader notice-only/TTS/abort proof is claimed.

Co-authored-by: Ayaan Zaidi <[email protected]>
@Patrick-Erichsen
Patrick-Erichsen force-pushed the fix/gap-followup-drain-detached-scope branch from 21eb1c9 to d1247b0 Compare October 1, 2026 06:31
@clawsweeper clawsweeper Bot removed the rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. label Oct 1, 2026
@clawsweeper clawsweeper Bot added the rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. label Oct 1, 2026
@Patrick-Erichsen
Patrick-Erichsen force-pushed the fix/gap-followup-drain-detached-scope branch from 520666d to e53fa8c Compare October 1, 2026 07:10
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Oct 1, 2026
@Patrick-Erichsen
Patrick-Erichsen merged commit 3400fd9 into openclaw:main Oct 1, 2026
128 checks passed
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Merged via squash.

steipete added a commit that referenced this pull request Oct 1, 2026
…ardown

#162540 deleted the raw-key clearSessionQueues helper while #148025 landed a test that still imported it for teardown. Use the shared clearFollowupQueueForTest helper; the test enqueues no lane commands.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
…g request ends (openclaw#148025)

* fix(auto-reply): keep followup queue drains alive after the triggering request ends

* test(auto-reply): make followup scope ordering deterministic

* test(doctor): keep fake gateway PID outside the test ancestry

---------

Co-authored-by: Patrick Erichsen <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
…ardown

openclaw#162540 deleted the raw-key clearSessionQueues helper while openclaw#148025 landed a test that still imported it for teardown. Use the shared clearFollowupQueueForTest helper; the test enqueues no lane commands.
@xialonglee
xialonglee deleted the fix/gap-followup-drain-detached-scope branch October 8, 2026 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants