Repository navigation
fix(gateway): preserve retry decisions and catalog errors - #15367
Conversation
|
➖ v2 migration progress: 0.9% → 0.9% (0 done, 0 total, 0 dropped; 92/9829 cells) Placement: 0 new marked lines in shared files, 1 new Ratchets: 12 core-internal imports (base 9); shared patches by rung 20 seam, 16 patch (base 20 seam, 16 patch). No change to the progress map. |
Code Review SummaryStatus: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (18 files)
The follow-up commit Previous Review Summary (commit 974f78c)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 974f78c)Status: 5 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (16 files)
No CRITICAL findings: the model/error wrapper, LayerNode replacement, and plugin catalog state were checked for recursion, identity, and lifecycle problems and are sound. No memory leaks were introduced. Retry decisions match v1 ( Reviewed by deepseek-flash-latest · Input: 203.1K · Output: 26.3K · Cached: 955.5K Review guidance: REVIEW.md from base branch |
What Problem This Solves
Permanent Gateway errors in HTTP-200 SSE streams lost their retry decision before native classification. Paid-auth and promotion failures could repeat instead of stopping. Catalog failures also lost their cause before a selected Kilo model reached the CLI error boundary.
Why This Change Was Made
The initial comparison used main
9e4e3a43c802and v2981607bf544. Main was refreshed to4481e06d8af1; the four relevant retry/error files are unchanged. Current v2f50d908f132, including merged #15366, is integrated normally. No main merge or open peer-branch merge is included.Main has dedicated terminal handling for
PAID_MODEL_AUTH_REQUIREDandPROMOTION_MODEL_LIMIT_REACHED. Its stream parser supports numeric/string codes, JSON-wrapped errors andresponse.failed. Billing documentation uses numeric 402 witherror.metadata.buyCreditsUrl.Review exposed a main behavior that should not be copied: its broad prose fallback can retry deterministic errors mentioning
500 tokensorProvider returned error, and HTTP 429 exhausted quota can retry through the SDK flag. This PR deliberately retains v2's native permanent classifications instead. Unknown provider failures also keep the native retry default. Only known Kilo terminal signals and the existing top-up exception override it; no new error framework or retry engine is added.User Impact
messagecannot replace a structured outer error.stream, bufferedgenerate, and native triggercompact. Generic validation, quota, rate-limit, server, unknown, and non-Kilo provider behavior stays with the native classifier.kind, optional HTTPstatus) through the existing models RPC. The host uses a shared safe formatter, not message parsing. No raw response, credential, endpoint query, or organization ID is included.Review Decisions
api_errorbypassed its guardcompactbypassed normalizationerror.typeorganization_missingwith selection guidance and no fabricated status@opencode/schemato runtime dependencies; no version changesAll six addressed remote review threads were resolved after the fixes were pushed, without replies.
Evidence
Bun 1.4.2. Package tests used fresh
OPENCODE_TEST_HOMEand XDG directories. Integrated-branch checks:bun testinpackages/kilo-gateway-corebun test test/catalog-errors.test.ts test/gateway.test.tsinpackages/kilo-pluginbun test test/gateway-errors.test.ts test/catalog-errors.test.ts test/host.test.ts test/rpc.test.ts test/gateway-usage.test.tsinpackages/kilo-clibun test test/kilocode/gateway-usage.test.ts test/kilocode/session-stats.test.tsinpackages/corebun test upstream/progress.test.ts upstream/placement.test.tsinscriptbun run checkbun run generateinpackages/client--check, marker/shared-patch/import checks,git diff --checkTests execute production normalization, native OpenRouter/OpenAI Responses/Anthropic parsing,
toSessionError, andSessionRunnerRetry.policy. Counted buffered/native-trigger retries useModelRetry.retryand TestClock: paid-auth/promotion stop after one request; top-up recovers on request two, for botherrorandresponse.failed. Trigger compaction returns the real encrypted checkpoint. This is not a claim that the JSON compact endpoint accepts SSE.The nested worktree initially selected ancestor v1 Node types.
bun install --linker hoisted --frozen-lockfilecorrected generated dependency layout only. No source workaround, version change, type relaxation, or disabled check was added.Real CLI And TUI Self-Tests
Used controlled counted loopback fixtures, fresh profiles,
--standalone, and an allowlistedenv -ichild environment. No production balance, entitlement, policy, or credential was changed. Fixture/harness processes were stopped.CLI command:
bun dev run --standalone --model kilo/fixture/<case> <prompt>, with a freshKILO_V2_PROFILE/HOME, fixtureKILO_API_URL, pinned Bun PATH, TERM, andKILO_DISABLE_MODELS_FETCH=true.message500 tokensor provider-error prose, including message-only bodyinsufficient_quotahttps://app.kilo.ai/creditsdisplayedAfter integrating current v2, repeated HTTP/SSE promotion, exhausted quota, credits, top-up, native transient, and an ordinary successful CLI call. Primary failures stayed at one request; transients recovered at three. The merged client integration also verified routed costs, auxiliary calls, statistics, and persistence across a server restart.
The
vscode-self-testsessiongateway-errors-e-20261022used--mode noneand isolated workspace/profile. Real TUI picker selection and submission produced one request each for auth/promotion and terminal guidance; transient recovery used three requests and settled in 5.7 seconds. Explicit-model catalog guidance was also read in the harness terminal. Not every policy code or native compaction was manually driven through the TUI; those have actual-path automated coverage.Placement
kilo-gateway-core/src/errors.ts, error branch ofstream.ts, plugin and schema Gateway contractkilo-cli/src/gateway-errors.ts, existing LLMClient node decoratorkilo-cli/src/gateway-model.ts, existing runner node decorated with scoped RPCRelative to current v2, no shared upstream source, generic classifier default, or new mirror is changed. Logic stays in Kilo-owned paths. Three new core-internal imports provide the existing LLM node, scoped RPC, and runner boundary (
effect/app-node-platform,rpc,session/runner/model). Runtime workspace manifest/lock changes are required by those host consumers. The progress tool fix below is Kilo-owned tooling.Progress map
Current base
gateway: 61/75 to 61/75, 12 dropped; module 31/35, patch 12/18, test 18/22. The initial 59/75 became 61/75 through already-merged #15366, not extra claims in this error PR. Two existing error proofs now cover actual streamed/buffered/native-compaction execution instead of parser-only evidence. No error cell is newly closed or dropped.Core-internal imports grow from 9 to 12 for the host boundaries above. Shared patches remain at the current base's 36; this PR adds none. The 14 existing open Gateway cells (cloud/event clients, remaining handlers/request transforms, and associated tests) remain outside this error change.
CI Follow-Up
On prior head
5436a8607f8, CI's synthetic merge followed v2's first parent while local regeneration followed feature-branch history. That made onlyREADME.mdandhistory.svgstale.66570fd2c08anchors history toorigin/v2, adds a regression, and regenerates those artifacts with unchanged cell totals and strict checks.The same run failed
Git trees > refresh handles check-ignore exit 128with a LinuxEPIPE. Git source/test, process/spawner and fixtures are byte-identical to current v2 and pinned upstream. Isolated macOS checks passed the related cases 75 times, exit 128 another 100 times, the full Git file, and 40 production-path probes. This does not prove the Linux issue is fixed. No swallowing, skip, retry addition, workflow rerun, or unrelated Git change was used. On head 66570fd, all GitHub Actions checks passed, including the previously failing Linux unit and progress-map jobs. The external Kilo Code Review check remained a terminal failure; it is not reported green. Human review was approved, there were no unresolved GitHub review threads, and the PR was merged at 10:34 UTC as e346cbf.Limits
Manual Test