Skip to content

fix(openrouter): preserve completed music when stream cleanup fails - #111056

Merged
steipete merged 3 commits into
openclaw:mainfrom
ZengWen-DT:fix/openrouter-preserve-completed-music
Jul 19, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
ZengWen-DT:fix/openrouter-preserve-completed-music

Conversation

@ZengWen-DT

Copy link
Copy Markdown
Contributor
Additional instructions

Allow edits from maintainers is enabled for this PR.

What Problem This Solves

Fixes an issue where OpenRouter music generation could return a failure after a complete audio stream and [DONE] marker had already been received, when best-effort stream cancellation rejected.

Why This Change Was Made

The completed audio result now remains authoritative while reader cancellation is still attempted and awaited. Risk: cleanup must still run exactly once and release the reader lock; the regression and runtime proof cover both conditions.

User Impact

Users keep successfully generated OpenRouter music instead of seeing a cleanup error after generation has completed.

Evidence

Node v24.18.0 production-entry proof used buildOpenRouterMusicGenerationProvider(), a native Response/ReadableStream, and only replaced the network transport seam. The underlying cancel callback rejected after [DONE].

Before on ec998a0:

{"outcome":"rejected","error":"cancel failed","cancelCalls":1}

After on current upstream main plus this commit:

{"outcome":"resolved","audio":"live-audio","lyrics":["live lyrics"],"cancelCalls":1}

Focused regression:

node scripts/run-vitest.mjs extensions/openrouter/music-generation-provider.test.ts
Test Files  1 passed (1)
Tests  14 passed (14)

The same test failed before the production change with promise rejected Error: cancel failed. Targeted oxfmt, direct oxlint, and git diff --check passed. The changed-check wrapper was blocked before reaching these files by current checkout plugin-SDK boundary DTS errors in packages/net-policy/src/ip.ts; full build/check/test are left to fork CI.

AI-assisted: Codex helped implement and review the change; the behavior proof was run manually.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 19, 2026
@clawsweeper

clawsweeper Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 18, 2026, 10:46 PM ET / July 19, 2026, 02:46 UTC.

Summary
The PR preserves a completed OpenRouter music result when cancellation of its already-complete stream reader rejects, with focused regression coverage.

PR surface: Source +2, Tests +6. Total +8 across 2 files.

Reproducibility: yes. with medium confidence: the PR supplies a concrete native Response/ReadableStream reproduction in which [DONE] precedes a rejecting cancellation callback, and the changed source maps directly to that path; this read-only review did not execute it.

Review metrics: none identified.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Refresh mergeability and let the in-progress required checks finish for commit 990c197731057e781d93515d818d181dda05397d.

Risk before merge

  • [P1] The branch is behind current main, and several required checks for the current head are still running; merge only after refreshing the three-way merge state and required-check results for that exact head.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow cancellation-error containment after the assigned reviewer confirms the current-head merge result and required checks; retain the existing lock-release and incomplete-stream error behavior.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] No discrete repair remains; the assigned reviewer should confirm the refreshed merge result and in-progress required checks for the latest head.

Security
Cleared: The diff only adjusts provider stream-cleanup error handling and its test harness; it adds no dependency, permission, secret, workflow, package-resolution, or external-execution surface.

Review details

Best possible solution:

Land the narrow cancellation-error containment after the assigned reviewer confirms the current-head merge result and required checks; retain the existing lock-release and incomplete-stream error behavior.

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

Yes, with medium confidence: the PR supplies a concrete native Response/ReadableStream reproduction in which [DONE] precedes a rejecting cancellation callback, and the changed source maps directly to that path; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes: once [DONE] has made the generated audio authoritative, awaiting cancellation for cleanup while ignoring only its rejection is the narrowest fix; the regression continues to require cancellation and lock release.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This fixes a bounded provider-specific failure that can discard an otherwise completed music-generation result.
  • 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 PR body provides before-and-after production-entry output using a native stream and a rejecting post-[DONE] cancellation callback, supplemented by focused regression results; no private material is exposed in the supplied output.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides before-and-after production-entry output using a native stream and a rejecting post-[DONE] cancellation callback, supplemented by focused regression results; no private material is exposed in the supplied output.
Evidence reviewed

PR surface:

Source +2, Tests +6. Total +8 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 1 +2
Tests 1 12 6 +6
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 15 7 +8

What I checked:

  • Completed-result authority: The PR changes the [DONE] branch so a rejected reader.cancel() is treated as cleanup failure rather than replacing the completed audio result with a transport error. (extensions/openrouter/music-generation-provider.ts:298, 990c19773105)
  • Focused regression coverage: The updated test makes stream cancellation reject after a completed audio response and asserts that the provider still resolves while cancellation and lock release each run once. (extensions/openrouter/music-generation-provider.test.ts:214, 990c19773105)
  • After-fix runtime proof: The PR body records a native Response/ReadableStream production-entry run: the baseline rejected with cancel failed, while the patched path resolved live-audio and preserved lyrics with one cancellation call. (extensions/openrouter/music-generation-provider.test.ts:214, 990c19773105)
  • Review continuity and current state: The previous completed ClawSweeper cycle found no patch defect; the head was subsequently force-pushed to 990c197, and the supplied check state still has build, lint, type, dependency, and extension-boundary jobs in progress. (990c19773105)

Likely related people:

  • steipete: The timeline records assignment to this PR and a subsequent force-push of the current review head, making this the clearest routing contact in the available history. (role: assigned reviewer and current-head updater; confidence: medium; commits: 990c19773105; files: extensions/openrouter/music-generation-provider.ts, extensions/openrouter/music-generation-provider.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (5 earlier review cycles)
  • reviewed 2026-07-19T00:06:50.112Z sha 0fd5d2dee9475124518bdcf28326f139bc7686cd :: needs maintainer review before merge. :: none
  • reviewed 2026-07-19T00:58:05.783Z sha 5071935121988e6b1eeca7b6148e121416f9a4fa :: needs maintainer review before merge. :: none
  • reviewed 2026-07-19T01:06:24.996Z sha 24d74bc95d03027a97b9dbf94e153e4b507f368b :: needs maintainer review before merge. :: none
  • reviewed 2026-07-19T01:12:39.735Z sha 73cf2f2fe15ac6674a0771dd09ff0203f858fcce :: needs maintainer review before merge. :: none
  • reviewed 2026-07-19T01:54:53.171Z sha 73cf2f2fe15ac6674a0771dd09ff0203f858fcce :: needs maintainer review before merge. :: none

@ZengWen-DT

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 19, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 19, 2026
@ZengWen-DT

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 19, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@ZengWen-DT
ZengWen-DT force-pushed the fix/openrouter-preserve-completed-music branch from 24d74bc to 73cf2f2 Compare July 19, 2026 01:09
@ZengWen-DT

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 19, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@steipete steipete self-assigned this Jul 19, 2026
@steipete
steipete force-pushed the fix/openrouter-preserve-completed-music branch from 73cf2f2 to 990c197 Compare July 19, 2026 02:43
@steipete
steipete merged commit 491b87c into openclaw:main Jul 19, 2026
82 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 19, 2026
…penclaw#111056)

* fix(openrouter): preserve completed music when stream cleanup fails

* test(openrouter): clarify stream cleanup authority

* test(openrouter): propagate stream cancellation
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…penclaw#111056)

* fix(openrouter): preserve completed music when stream cleanup fails

* test(openrouter): clarify stream cleanup authority

* test(openrouter): propagate stream cancellation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: openrouter 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: XS 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.

2 participants