While using openrouter serving deepseek/deepseek-v4.1-flash (API mode
openai-completions) the stream repeatedly dies mid-reasoning with the
OpenRouter error:
Upstream error from Together: Stream error: h2 protocol error: error reading a body from connection
- Host: pi coding agent
0.85.1 - Project:
/Users/don/dev/idfon - Provider:
openrouter - Model:
deepseek/deepseek-v4.1-flash - Upstream named in error: Together
- Occurrences: 12 (all on this provider/model; none on any other provider)
- Window: 2026-09-13 19:55Z … 2026-09-14 21:37Z (UTC)
Each occurrence is an assistant message that ends with:
stopReason: "error"errorMessage: "Upstream error from Together: Stream error: h2 protocol error: error reading a body from connection"usage: {input:0, output:0, totalTokens:0}(nothing billed/counted)- a partial
thinkingpart — the model was mid-chain-of-thought when the body read failed. Notextor tool-call was produced.
The connection drops after 2 s to 206 s of streaming. It is transient: the next
request (usually the user typing resume) succeeds. Two user turns in the log
are literally the notes resume. h2 protocol error. and
another h2 protocol error..
| timestamp (UTC) | latency | thinking chars at drop | OpenRouter generation id | pi msg id |
|---|---|---|---|---|
| 2026-09-13T19:55:36.661Z | 4s | 2,402 | gen-1789329332-J8dfAtCuWxeLtIShMNmu |
d06cac09 |
| 2026-09-13T20:04:23.101Z | 37s | 812 | gen-1789329826-hu1BwRQ8jey0G6YWEKih |
7dc71988 |
| 2026-09-13T20:11:44.996Z | 206s | 10,113 | gen-1789330098-AkgcbsJmzBfiofHOaRJD |
8817c44c |
| 2026-09-13T20:14:41.515Z | 176s | 7,293 | gen-1789330305-PmQZy2kV09BP4IYJbS7F |
74ce8e83 |
| 2026-09-13T20:16:40.659Z | 119s | 5,327 | gen-1789330481-Eayjct1EEB6846WZutxG |
db2fdfeb |
| 2026-09-13T21:17:53.314Z | 34s | 9,393 | gen-1789334239-P4YjD6RaCI29xEabOAI2 |
e36ae882 |
| 2026-09-13T21:21:15.457Z | 5s | 854 | gen-1789334470-pay4vIASvu87oNBPmq4n |
d3f2dd53 |
| 2026-09-13T21:22:20.894Z | 10s | 5,688 | gen-1789334530-iB2QfDlS04M96KQ3pBHB |
40b003da |
| 2026-09-14T02:36:58.462Z | 3s | 497 | gen-1789353415-nW7BjE4r2EYuNawuy6lm |
0846e8b5 |
| 2026-09-14T21:31:54.313Z | 2s | 450 | gen-1789421512-NLxpwPEmfjwImnFRFiOp |
5ee9b6da |
| 2026-09-14T21:34:34.142Z | 3s | 446 | gen-1789421671-h7dIG8cnSgmu46Ey4KOw |
3c60307d |
| 2026-09-14T21:37:40.843Z | 3s | 850 | gen-1789421857-fK49M0NGUxNhrCgH5hP6 |
9226466f |
Latency = error time − request start, where request start is decoded from the
OpenRouter gen-<epoch>-<hash> id.
Clusters: 8 on 2026-09-13 (19:55–21:22), 1 on 2026-09-14 02:36, 3 on 2026-09-14 21:31–21:37. Failure is intermittent within a session and hits both short and long generations.
{
"type": "message",
"id": "d06cac09",
"parentId": "52addc14",
"timestamp": "2026-09-13T19:55:36.661Z",
"message": {
"role": "assistant",
"content": [{"type": "thinking", "thinking": "…partial reasoning…"}],
"api": "openai-completions",
"provider": "openrouter",
"model": "deepseek/deepseek-v4.1-flash",
"usage": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0,
"totalTokens": 0, "cost": {"total": 0}},
"stopReason": "error",
"timestamp": 1789329332098,
"responseId": "gen-1789329332-J8dfAtCuWxeLtIShMNmu",
"errorMessage": "Upstream error from Together: Stream error: h2 protocol error: error reading a body from connection"
}
}openrouter/deepseek/deepseek-v4.1-flash: 12 × the h2/Together error above. No other provider produced anh2 protocol errorstring in any log across the whole~/.pi/agent/sessionstree.vercel-ai-gateway/deepseek/deepseek-v4.1-flash: different failure mode, 5 ×Request timed out.— no h2 errors.- OpenRouter errors generally: besides the 12 h2 errors, 23 ×
This operation was abortedand a fewProvider finish_reason: error,Stream ended without finish_reason,Upstream idle timeout exceeded,503 status code (no body)/terminated.
/Users/don/.pi/agent/sessions/--Users-don-dev-idfon--/2026-09-13T19-46-52-450Z_01a09c4e-e9a2-73bd-af78-a5ed436b2b43.jsonl(8)/Users/don/.pi/agent/sessions/--Users-don-dev-idfon--/2026-09-14T21-24-45-662Z_01a0a1ce-e3dd-71f2-9b64-72971523d84d.jsonl(3)/Users/don/.pi/agent/sessions/--Users-don-dev-idfon--/2026-09-14T02-20-57-201Z_01a09db7-b3f0-76c0-89ce-d88de2c6df74.jsonl(1)
Send a long-thinking, tool-using request to openrouter with
deepseek/deepseek-v4.1-flash (reasoning streamed; upstream routes to Together).
Observe the SSE body abort mid-stream with
Upstream error from Together: Stream error: h2 protocol error: error reading a body from connection.
The OpenRouter generation ids above can be looked up directly.
I was able to reproduce this issue with openrouter and deepseek-v4.1-flash. I didn't set out to do it, but it was occurring during development work I was doing in Rust.