Repository navigation
Description
Client or integration
Codex App
Provider or upstream service
deepseek
OpenCodex version
2.69.0
Endpoint or capability
streaming
Current behaviour
A request with stream:true deterministically ends in response.failed:
{"type":"upstream_error","code":"upstream_reset","message":"Upstream stream terminated unexpectedly: The socket connection was closed unexpectedly."}
Identical on every run. Via the ChatGPT client it surfaces as 502 upstream_server_error, failureStage=protocol-prelude, disconnecting after ~336ms.
Expected behaviour
The upstream SSE stream should stay alive — at least no worse than a direct curl, which streams DeepSeek /responses end-to-end without errors.
Minimal redacted request or reproduction
$b = @{ model = "deepseek/deepseek-flash"; input = "hi"; max_output_tokens = 10; stream = $true } | ConvertTo-Json -Depth 5
Invoke-RestMethod -Uri "http://localhost:10100/v1/responses" -Method Post -Body $b -ContentType "application/json" -TimeoutSec 60Actual response or error
event: response.failed
data: {"type":"response.failed","response":{"status":"failed","error":{"type":"upstream_error","code":"upstream_reset","message":"Upstream stream terminated unexpectedly: The socket connection was closed unexpectedly."}}}
data: [DONE]
HTTP 502 upstream_server_error.Upstream documentation
https://api-docs.deepseek.com/guides/responses_api
Consider re-applying the bounded-JSON upstream policy (#1026) for DeepSeek as a fallback when upstream SSE fails in proxied environments.
Suggested mapping or implementation notes
No response
Additional context and attachments
- OpenCodex 2.69.0, Windows, PowerShell
- Transparent TUN proxy in use; api.deepseek.com resolves to fake-IP 198.18.0.27
- Failure is deterministic: identical on every run
- Control cases: non-streaming via OpenCodex OK; direct curl -N streaming to DeepSeek OK
- Related: fix(deepseek): transport-neutral bounded-JSON policy with terminal SSE synthesis (#875) #1026 (bounded-JSON policy), fix(responses): restore DeepSeek streaming and routed code-mode tools #1361 (restored upstream streaming), fix(provider): treat deepseek-flash as native multimodal #4500 (multimodal)
Checks
- I searched existing provider and compatibility issues.
- The request and response were redacted.
- The expected behaviour is based on an upstream specification or a concrete client requirement.
Activity
cybertingzhen commentedon Sep 28, 2026
Update: worked around it locally.
Root cause in my environment: Clash (Mihomo) fake-ip DNS returns 198.18.0.0/15 for api.deepseek.com, and OpenCodex's direct connection to the fake IP got its upstream SSE socket killed.
Workaround: set an explicit outbound proxy on the deepseek provider in config.json:
"proxy": "http://127.0.0.1:7897"
(per #2037 this arms the allowBenchmarkAddresses opt-in, so the hostname rides the proxy CONNECT instead of the fake IP)
After that, the minimal stream:true repro returns a complete SSE stream — no more upstream_reset.
Note: my provider already had "allowPrivateNetwork": true, which alone was not sufficient; the explicit proxy is what fixed it.