fix: reject DeepSeek WebSocket upgrades with 426 for a zero-retry HTTP fallback - #25
Merged
fish2lab merged 1 commit intoSep 20, 2026
Conversation
…P fallback The client treats a DeepSeek model on an accepted socket as a retryable stream error and burns 5 reconnect attempts (~10-15s of backoff) before falling back to HTTP — the case the v1.2.1 release notes flagged as unverified in normal DeepSeek use. The handshake already carries the model in x-codex-routing-hint, and the client maps an upgrade-time HTTP 426 directly to its no-retry HTTP fallback (WebsocketStreamOutcome:: FallbackToHttp), so reject DeepSeek-hinted upgrades early. The first-frame close-1008 path stays as the fallback for handshakes without the hint. AGENTS.md rule 20 and both READMEs are updated.
fish2lab
pushed a commit
that referenced
this pull request
Sep 20, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
背景
v1.2.1 release notes 的「未验收」里留了一个问题:桌面端是否每个 turn 按当前模型选传输——若先打 WS,DeepSeek 任务会先吃一次 1008 再回 HTTP。正常使用中已复现,代价是首轮约 10–15 秒的重连等待。
本机实测(macOS 桌面端 + CLI,ChatGPT OAuth,DSCodex v1.2.1)
server.log的典型序列:根因
stream_max_retries默认 5,指数退避);WebsocketStreamOutcome::FallbackToHttp);x-codex-routing-hint: model=<slug>;tier=<tier>(该头已在 DSCodex 的转发白名单里)。改动
handleResponsesUpgrade:握手读x-codex-routing-hint,识别为 DeepSeek 时直接回 426,不建立 socket、不拨 upstream;AGENTS.md规则 20 与README.md/README.en.md的边界描述(两条路径都写明)。验证
routingHintModel解析(含tier、畸形值、缺失头);HTTP/1.1 426,upstream 零拨号,路由器存活;npm test:128 tests / 122 pass / 0 fail(6 skip 为 Windows 原生项);git diff --check干净;适用于 CI 三平台。Reconnecting 5/5≈ 10–15s;修复后握手即 426,端到端 4.5s、无 Reconnecting;GPT 的 WS 照常透传(chatgpt websocket ... open)。兼容性
x-codex-routing-hint的客户端(API-key 认证、旧版本)行为完全不变;如果方向或细节与你们的偏好不一致(例如希望对 426 的触发条件更保守),我可以按反馈调整。