Conversation
|
Maintainers/reviewers: please treat the implemented bounded prefill repair as a proposal, not the sole solution. The observed mismatch is custom target metadata (1,048,576) versus the server's reported limit (294,912); Senpi's existing clamp and the catalog correction in #1255 were already present. The server also reported input 210,744 and completion 131,072. That establishes an output-reservation overflow, but does not by itself establish an estimator bug or a missing target-admission check. Please consider alternatives:
The current proposal handles only the observed, internally consistent prefill report before any chunk; changes the completion cap once; preserves the built request, reasoning settings, and explicit fitting caps; and leaves ambiguous/unrepairable failures on existing error handling. It does not prevent the first rejection from an unknown limit or persist a learned window. Please suggest a different seam or policy if it is more appropriate for Senpi's contracts. |
Summary
Propose one evidence-based output-reservation repair at the OpenAI-compatible prefill boundary, including requests reached through model fallback. The full conversation and request options are preserved; only the completion cap changes.
Diagnosis
The incident switched from
openai-codex/gpt-6-astraafter a usage-limit error to a customog/moonshotai/kimi-k3-ultrafastmodel. Prefill reported:The custom target declared 1,048,576 context tokens. Installed OmO
5.0.0-0.beta.53/ Senpi2026.9.10-2already contained the target-context completion clamp; its declared window therefore allowed this request. The arithmetic alone did not establish a missing admission check. The catalog default was already corrected to 262,144 in #1255, but this separate custom provider retained its own metadata. Existing overflow classification did start compaction.This is distinct from candidate-admission work in #1338 and Cursor-specific server-window tracking in #1614. Neither a repeated check against the stale custom window nor a catalog-only change fixes this request.
Proposed behavior
294912 - 210744 - 4096 = 80072in the incident fixture. Reuse the built payload without re-runningonPayload.No model metadata, fallback-chain policy, installed runtime, live settings, transcripts, or credentials are changed. No logging expansion or persistent learned-window cache is added.
Verification
bun run --cwd packages/ai test --maxWorkers=4: 285 files / 2,766 tests passed; existing opt-in live gates skipped 26 suites / 884 tests.bun run --cwd packages/coding-agent test test/suite/retry-fallback-billing-swap.test.ts test/suite/rpc-worker-routing.test.ts --maxWorkers=2: 21 passed.bun run checkandbun run build: passed. Language-server diagnostics unavailable becausetypescript-language-serveris not installed; repository TypeScript/Biome checks ran instead.changes.mdupdated.Local reproducible receipts:
local-ignore/qa-evidence/20260912-fallback-budget/(not committed; synthetic request metadata only).CI baseline blocker correction
The first CI run passed every job except coding-agent shard 2, which expected catalog ID
opencode-go/deepseek-flash. Release commit0a22329afhad already changed the catalog toopencode-go/deepseek-v4.1-flash; both affected files were unchanged from this PR's base. The same failure reproduced locally.A separate one-line test-only commit updates the inventory assertion to the released ID. The legacy alias routing case and the assertion that every matching catalog model resolves to the V4.1 preset are retained. No production catalog or preset behavior was changed.
bun run --cwd packages/coding-agent test test/suite/prompt-presets-deepseek-v4-1-flash.test.ts: 37 passed; root check passed again.Limitations and review focus
This proposal cannot prevent the first rejection caused by an unknown server limit. It handles the observed report dialect only and does not claim exact cross-model token estimation. Correcting custom metadata remains the preventive remedy. Please scrutinize whether this narrowly evidenced repair is preferable to a different admission/reservation policy; a separate discussion comment compares those alternatives and diagnostic logging.
Not merged or installed by this PR.