Fix Kilo Quota | OpenRouter error handling and retry flow#5847
Fix Kilo Quota | OpenRouter error handling and retry flow#5847Neonsy wants to merge 2 commits intoKilo-Org:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 718312c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
08da2dd to
1973da5
Compare
1973da5 to
100c218
Compare
|
before fix :
Date/time: 2026-02-13T13:50:09.047Z Provider ended the request: No output generated. Check the stream for errors. Date/time: 2026-02-13T13:50:09.047Z No output generated. Check the stream for errors. after fix:
Date/time: 2026-02-13T14:27:19.132Z 403 TLDR: this fix correctly handles case, when kimi code weekly quota is 100%, by correctly providing error code and message |
ce5c579 to
9369dec
Compare
Mirror: Fix Kilo Quota OpenRouter error handling and retry flow (Kilo-Org#5847)
9369dec to
258a399
Compare
a6255bd to
1fc28c5
Compare
1fc28c5 to
718312c
Compare
Code Review SummaryStatus: No Issues Found | Recommendation: Merge OverviewThis PR improves error handling for Kilo Quota / OpenRouter failures by:
The implementation is defensive, handles edge cases well, and the error priority chain ( Files Reviewed (5 files)
|
|
Hi! Thank you for taking the time to contribute to this project—we really appreciate it. We are currently working on re-platforming the core of our VS Code and JetBrains extensions to be based on our new Kilo CLI, with a complete rebuild based on OpenCode as our new foundation, which means this PR unfortunately won't be compatible with the new architecture. If you think this feature or fix is still relevant, we'd love for you to check out the new version and consider contributing it there. The new code is now in this repository. Alternatively, if you think this is an urgent fix to the old vscode extension (like a recent model change, or an urgent bug fix), we’d welcome the PR at https://github.com/Kilo-Org/kilocode-legacy |



Context
A user reported repeated
API Streaming Failed/Unknown API errorfailures on Moonshot (kimi-for-coding) with details like:Provider ended the request: No output generated. Check the stream for errors.This PR updates the earlier quota-focused direction and addresses the actual failing path:
MoonshotHandleruses the AI SDKOpenAICompatibleHandlerstream path.errorstream parts were not being escalated into actionable provider errors.Taskdoes not handlechunk.type === "error"in the stream switch, so those parts were effectively dropped.await result.usagecould throw generic"No output generated...", which caused downstream UI fallback to unknown/generic error handling.Implementation
Updated
src/api/providers/openai-compatible.ts:Throw immediately when
result.fullStreamemitspart.type === "error"instead of yielding a non-actionable chunk.Wrap full stream iteration and
await result.usageintry/catchand rethrow via:handleProviderError(error, providerName, { messagePrefix: "streaming" })Preserved existing tool-stream behavior (tool-input accumulation/flush and usage emission on success).
Hardened
src/api/providers/utils/error-handler.ts:Preserve status from
status,statusCode, and$metadata.httpStatusCode.Improve message extraction priority:
metadata.raw-> parsedresponseBody/data/cause-> fallbackerror.message.If top-level message is generic
"No output generated. Check the stream for errors.", prefer nested provider message when present.Preserve structured
errorDetailsfrom payloads (responseBody/data/cause) for retry/backoff/UI detail surfaces.Added regression coverage:
src/api/providers/__tests__/moonshot.spec.tserrorpart withstatusCode+responseBodyis normalized and thrown with preserved details.src/api/providers/utils/__tests__/error-handler.spec.tsstatusCode.responseBody.How to Test
Targeted regressions:
cd src && pnpm test api/providers/__tests__/moonshot.spec.tscd src && pnpm test api/providers/utils/__tests__/error-handler.spec.tsQuality gates:
pnpm check-typespnpm lintpnpm buildManual scenario:
Configure Moonshot with
kimi-for-coding.Trigger a request in a quota/credit-limited state (or equivalent provider-side failure).
Confirm the surfaced error includes actionable provider context (status/message/details), not only generic
"No output generated...".Validation Performed
pnpm check-typespassed.pnpm lintpassed.pnpm buildpassed.cd src && pnpm test api/providers/__tests__/moonshot.spec.tspassed.cd src && pnpm test api/providers/utils/__tests__/error-handler.spec.tspassed.Note
This PR focuses on the Moonshot/AI-SDK stream error path and shared error normalization hardening, not the older OpenRouter/Kilo quota branch.