Repository navigation
fix(core): tolerate repeated invalid model streams #6712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wenshao
merged 8 commits into
QwenLM:main
from
yiliang114:codex/fix-6670-dashscope-stream-retry
Jul 11, 2026
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5620e88
fix(core): tolerate repeated invalid model streams
yiliang114 eb0406a
fix(core): preserve invalid stream retry invariants
yiliang114 92ea1e8
Merge branch 'main' into codex/fix-6670-dashscope-stream-retry
wenshao 697b3d4
Merge branch 'main' into codex/fix-6670-dashscope-stream-retry
yiliang114 037b4e0
fix(core): use transient stream retry budget
yiliang114 dbb5365
fix(core): cap continuation protocol leak retries
yiliang114 4a1a0b7
fix(core): keep invalid stream retry budgets independent
yiliang114 dce63cc
fix(core): separate continuation stream retry budgets
yiliang114 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # DashScope Invalid Stream Retry Implementation Plan | ||
|
|
||
| > **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. | ||
|
|
||
| **Goal:** Make Qwen Code tolerate up to four consecutive transient invalid model streams before surfacing `InvalidStreamError`. | ||
|
|
||
| **Architecture:** Keep the existing provider-independent `InvalidStreamError` validation and retry path. Increase only its independent retry budget, preserving the existing linear delay and abort behavior; prove the change with stream factories that return a fresh async generator for every attempt. | ||
|
|
||
| **Tech Stack:** TypeScript, Vitest, fake timers, Qwen Code core streaming pipeline. | ||
|
|
||
| ### Task 1: Add the regression test | ||
|
|
||
| **Files:** | ||
|
|
||
| - Modify: `packages/core/src/core/geminiChat.test.ts` | ||
|
|
||
| **Step 1: Write the failing test** | ||
|
|
||
| Add a test under `sendMessageStream with retries` that returns four fresh invalid streams followed by a valid response. Assert five generator calls, four retry telemetry events, a successful response chunk, and clean two-turn history. | ||
|
|
||
| **Step 2: Run the focused test to verify it fails** | ||
|
|
||
| Run: `cd packages/core && npx vitest run src/core/geminiChat.test.ts -t "should recover after four consecutive invalid streams"` | ||
|
|
||
| Expected: FAIL because the current two-retry budget stops after three calls. | ||
|
|
||
| ### Task 2: Increase the invalid-stream retry budget | ||
|
|
||
| **Files:** | ||
|
|
||
| - Modify: `packages/core/src/core/geminiChat.ts` | ||
| - Modify: `packages/core/src/core/geminiChat.test.ts` | ||
|
|
||
| **Step 1: Implement the minimal change** | ||
|
|
||
| Change `INVALID_STREAM_RETRY_CONFIG.maxRetries` from `2` to `4`. | ||
|
|
||
| **Step 2: Update the persistent-failure assertions** | ||
|
|
||
| Update the existing persistent invalid-content test to expect five total stream calls and four retry telemetry events. | ||
|
|
||
| **Step 3: Run focused tests to verify they pass** | ||
|
|
||
| Run: `cd packages/core && npx vitest run src/core/geminiChat.test.ts -t "sendMessageStream with retries"` | ||
|
|
||
| Expected: PASS. | ||
|
|
||
| ### Task 3: Verify the change | ||
|
|
||
| **Files:** | ||
|
|
||
| - Verify: `packages/core/src/core/geminiChat.ts` | ||
| - Verify: `packages/core/src/core/geminiChat.test.ts` | ||
|
|
||
| **Step 1: Run the full affected test file** | ||
|
|
||
| Run: `cd packages/core && npx vitest run src/core/geminiChat.test.ts` | ||
|
|
||
| Expected: PASS. | ||
|
|
||
| **Step 2: Run repository checks** | ||
|
|
||
| Run: `npm run lint`, `npm run typecheck`, and `npm run build` from the worktree root. | ||
|
|
||
| Expected: all commands exit successfully. | ||
|
|
||
| **Step 3: Review the diff** | ||
|
|
||
| Check that the change is limited to the retry budget, its regression coverage, and these planning artifacts. | ||
|
|
||
| **Step 4: Commit** | ||
|
|
||
| Run: `git add docs/plans/2026-07-11-dashscope-invalid-stream-retry.md packages/core/src/core/geminiChat.ts packages/core/src/core/geminiChat.test.ts && git commit -m "fix(core): tolerate repeated invalid model streams"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.