Skip to content

fix(queue): queued operations inherit the previous request context - #164105

Merged
obviyus merged 2 commits into
openclaw:mainfrom
harshitgupta31415:harshitgupta31415/queued-tasks-inherit-the-previous-request-context
Oct 3, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
harshitgupta31415:harshitgupta31415/queued-tasks-inherit-the-previous-request-context

Conversation

@harshitgupta31415

@harshitgupta31415 harshitgupta31415 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #164091. Waiting serial tasks inherit the previous request's async context, so a voice transcript operation can carry another request's diagnostic trace. Reported and initially fixed by @harshitgupta31415; their commit is retained.

User Impact

Queued operations retain the submitting request's diagnostic context; untraced submissions stay untraced. FIFO order, capacity limits, backpressure, failure recovery, and flush barriers are unchanged.

Implementation

Capture each accepted operation with Node's supported AsyncLocalStorage.bind. Load the builtin only in Node through process.getBuiltinModule, because the same voice transcript policy is used in the Control UI browser. Browsers retain the existing queue behavior without a Node module dependency. No configuration, schema, dependency, or public API changes.

No overlap with Pash/Sarah changes.

Evidence

Linux ARM64 / Node 24.16.0, isolated Docker:

Candidate head: b59faa74e3ad049f9e85b5da1cff2e13dfb91a08.

  • Baseline 46fc2e34f2f2f980f1b496f959df28d1925b7ddb: a built production createVoiceTranscriptOperationRegistry().run() flow using production diagnostic trace contexts observed [first, first, first, first, first, first] across the three operations, before/after awaits. Expected [first, first, second, second, null, null].
  • Candidate: the same built flow observed the expected trace sequence. FIFO was [first, second, untraced] on both versions.
  • The retained queue regression fails on baseline (1 failed, 8 passed; Vitest duration 805 ms, runner 1.58 s). Candidate queue tests: 9 passed, including failure recovery, count/weight bounds, non-sealing backpressure, and flush-prefix controls. Voice registry tests: 2 passed.
  • Isolated Chromium exercised the production browser voice-transcript queue policy: FIFO [first, second], idle after settlement, and no Node process global. This protects the browser consumer while restoring server-side context propagation.
  • Sibling store-writer queue: 17 passed in a serialized run (17.80 s runner time, including a cold compiled-worker build). An earlier supplemental attempt failed during setup because it overlapped asset generation; no product assertion failed.
  • Requested single-worker cost: pnpm test src/shared/bounded-serial-queue.test.ts --maxWorkers=1: 9 passed, 1.631 s wall, 470 ms Vitest duration, 1.17 s runner duration. Exact-head CI also passed all 9 queue cases: 2.19 s runner duration, 863 ms Vitest duration; the containing multi-file job took 151 s.
  • Production UI bundle built successfully in 7.52 s without externalizing node:async_hooks. The built Node CLI resolves its isolated config path correctly.

The exact-head live Gateway smoke passed: one real gpt-5-mini Responses API request through a passive proxy, reasoning low, max_output_tokens: 4096, HTTP 200, and LIVE_GATE_OK_164091 returned in Gateway chat history. Credentials were file-mounted read-only for that run and removed afterward.

The queue-specific production-consumer proof is not a live microphone/provider voice session. Exact-head CI is green, including openclaw/ci-gate, with no failed or cancelled jobs. Exact-head ClawSweeper review is tracked on this PR.

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@harshitgupta31415
harshitgupta31415 marked this pull request as ready for review October 3, 2026 06:53
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 4:24 AM ET / 08:24 UTC (Revision 2).

ClawSweeper review

What this changes

The shared serial queue preserves each submitting request’s async context in Node, retains browser operation, and adds regression coverage.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary and has no actionable review findings. The updated evidence resolves the previous timing request and supports the browser-compatible revision.

Priority: P2
Reviewed head: b59faa74e3ad049f9e85b5da1cff2e13dfb91a08

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful regression coverage and relevant production-path proof; the previous follow-up is resolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured body records before/after trace results through the built production voice registry on isolated Linux ARM64 with Node 24.16.0, directly exercising the changed queue owner. Candidate traces and FIFO match expectations; Chromium proof covers the browser-shared policy. The unrelated Gateway smoke is supplemental. 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 (live_output): The captured body records before/after trace results through the built production voice registry on isolated Linux ARM64 with Node 24.16.0, directly exercising the changed queue owner. Candidate traces and FIFO match expectations; Chromium proof covers the browser-shared policy. The unrelated Gateway smoke is supplemental. No stored-data contract changes.
Evidence reviewed 10 items Pinned introduced change: The merge-base-to-head diff changes only context capture and its regression. FIFO, capacity, sealing, failure handling, and flush logic remain intact; diff whitespace checking passed.
Current main still needs the repair: Fetched main stores run without binding and starts subsequent work from the preceding task’s finally microtask. The latest release contains the same mechanism.
Latest release remains affected: The v2026.9.8 source also stores unbound callbacks; no implemented-on-main or released-fix closure is warranted.
Findings None None.
Security None None.

How this fits together

The shared queue serializes voice transcript operations, Talk controls, and terminal uploads. It accepts callbacks, enforces waiting limits, and executes accepted work in order.

flowchart TD
  A[Voice operations and uploads] --> B[Queue admission]
  B --> C{Within waiting limits}
  C -->|No| D[Reject submission]
  C -->|Yes| E[Capture Node request context]
  E --> F[Execute callbacks in order]
  F --> G[Completion and flush barriers]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +8, Tests +40. Total +48 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 9 1 +8
Tests 1 40 0 +40
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 49 1 +48

Review metrics

Metric Value Why it matters
Queue regression cost 1.631 s single-worker wall; 2.19 s CI runner The updated evidence satisfies the prior timing request and remains within the repository’s focused-test budget.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #164091
Summary: This PR is the implementation candidate for the linked caller-context defect; the issue remains open until merge.

Members:

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

Technical review

Best possible solution:

Keep caller-context capture at the shared queue’s admission boundary while preserving browser execution and existing queue semantics.

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

Yes: hold the first operation, submit a differently scoped operation and an untraced operation, then release the first. Current-main source establishes the faulty inheritance; supplied runtime proof demonstrates it without reviewer execution.

Is this the best way to solve the issue?

Yes: binding accepted callbacks at admission repairs the shared owner and follows the sibling writer queue’s context-preservation pattern.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 01f838a2b421.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The established defect misattributes queued request diagnostics without a demonstrated outage or authorization bypass.
  • 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 (live_output): The captured body records before/after trace results through the built production voice registry on isolated Linux ARM64 with Node 24.16.0, directly exercising the changed queue owner. Candidate traces and FIFO match expectations; Chromium proof covers the browser-shared policy. The unrelated Gateway smoke is supplemental. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body records before/after trace results through the built production voice registry on isolated Linux ARM64 with Node 24.16.0, directly exercising the changed queue owner. Candidate traces and FIFO match expectations; Chromium proof covers the browser-shared policy. The unrelated Gateway smoke is supplemental. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head diff changes only context capture and its regression. FIFO, capacity, sealing, failure handling, and flush logic remain intact; diff whitespace checking passed. (src/shared/bounded-serial-queue.ts:89, b59faa74e3ad)
  • Current main still needs the repair: Fetched main stores run without binding and starts subsequent work from the preceding task’s finally microtask. The latest release contains the same mechanism. (src/shared/bounded-serial-queue.ts:81, 01f838a2b421)
  • Latest release remains affected: The v2026.9.8 source also stores unbound callbacks; no implemented-on-main or released-fix closure is warranted. (src/shared/bounded-serial-queue.ts:81, fc23bc864e45)
  • Production-path proof: The captured PR body reports isolated Docker proof on Linux ARM64 and Node 24.16.0 through the built production voice registry and diagnostic trace owner. Baseline observed six first-request traces; this head observed [first, first, second, second, null, null], with FIFO preserved. Chromium also exercised the production browser queue policy without a process global. These are supplied runtime observations, not reviewer-executed tests. (src/talk/voice-transcript.ts:110, b59faa74e3ad)
  • Regression and previous follow-up resolved: The added test covers distinct scopes, explicit absence, awaits, failure recovery, and queue reuse without timers or a production-only test seam. The captured body supplies the requested single-worker wall time of 1.631 seconds and CI runner time of 2.19 seconds. (src/shared/bounded-serial-queue.test.ts:7, b59faa74e3ad)
  • Browser and Node compatibility: The queue uses the Node builtin only when process exists, avoiding a static Node import in the browser-shared voice policy. The repository requires Node 24.16.0 or newer supported versions; supplied Chromium and production UI bundle evidence covers the actual browser consumer. (src/shared/bounded-serial-queue.ts:3, b59faa74e3ad)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (1 earlier review cycle)
  • reviewed 2026-10-03T06:59:40.655Z sha 5de0073 :: needs changes before merge. :: none

@obviyus

obviyus commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

Please review b59faa7. The body now includes current-main failing and candidate passing built voice-registry proof, measured single-worker test cost, and production UI build plus isolated Chromium proof for the shared browser consumer. The contributor commit is retained; the additional commit only makes Node context capture browser-compatible.

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus merged commit 5df82fa into openclaw:main Oct 3, 2026
146 of 147 checks passed
@obviyus

obviyus commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Landed as 5df82fa, with a small follow-up commit that keeps the queue loadable in the browser. Thanks @harshitgupta31415!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…penclaw#164105)

Fixes openclaw#164091.

Tasks waiting in a `BoundedSerialQueue` ran in the async context of the task that ran before them instead of the context that submitted them, so diagnostic trace context leaked between queued requests, and a task submitted without one inherited the earlier trace. Each queued task now runs in its submitter's async context. The queue also runs in the browser (voice transcripts), which has no Node async context, so `node:async_hooks` is loaded only when `process` exists. FIFO order, bounds and backpressure are unchanged.

Proof: in the built voice-transcript registry, base ran all queued work under the first request's trace, and this change keeps each submitter's trace and leaves untraced work unscoped. The production UI build and an isolated Chromium import of the queue pass. The regression test fails on base and passes here. A live gpt-5-mini smoke call passed.

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

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.

[Bug]: Waiting serial tasks inherit the previous request context

2 participants