fix: handle empty AI Gateway streams and model routing#26005
fix: handle empty AI Gateway streams and model routing#26005ibetitsmike wants to merge 3 commits into
Conversation
|
/coder-agents-review |
|
Chat: Review posted | View chat Review historydeep-review v0.6.1 | Round 4 | Last posted: Round 4, 24 findings (3 P2, 11 P3, 1 P4, 8 Nit, 1 Note), COMMENT. Review Finding inventoryFindings
Contested and acknowledgedCRF-1 (Nit, sse_filter.go:73) - isEventStreamContentType duplicates isSSEContentType
CRF-3 (Note, sse_filter.go:1) - No dedicated unit test file for sse_filter.go
Round logRound 1Panel. Netero first pass: 1 P3, 1 Nit, 1 Note. Panel (20 reviewers): 3 P2, 9 P3, 1 P4, 8 Nit new. 2 dropped. Reviewed against efbaede..deb4344. Round 2BLOCKED. 21 addressed, 2 silent (CRF-1, CRF-3). No review. Round 3Panel. CRF-1 panel closed (8/8). CRF-3 panel closed (7/7). 1 new P3 (CRF-26). Reviewed against efbaede..e991ec6. Round 4CRF-26 addressed (3f79eb5). All findings resolved. Reviewed against efbaede..3f79eb5. About deep-reviewCRF = Coder Review Finding (P0-P4, Nit, Note)
|
There was a problem hiding this comment.
Good PR. The SSE filter is well-designed: correct pipe lifecycle, clean goroutine shutdown, proper SSE spec compliance. The defense-in-depth validation (config time + runtime) is the right pattern. The logUpstreamStreamFailure structured logging is exemplary operator tooling. Test density is healthy at 53% with genuine assertions that verify both new behavior and absence of old failure modes.
Severity count: 3 P2, 9 P3, 1 P4, 8 Nit.
The three P2s cluster around the pre-existing misconfiguration experience: the runtime error lacks chat error classification (CRF-4), the update endpoint blocks unrelated edits on already-broken configs (CRF-5), and the mapStreamError doc comment no longer describes what the function does (CRF-11). The P3s are a mix of operator signal quality (CRF-6, CRF-10), test gaps (CRF-9, CRF-14), and structural observations about the heuristic scope (CRF-7).
Highlight quote from Pariston: "The SSE filter exists because the OpenAI SDK's stream decoder doesn't strip SSE comment lines per the SSE spec. If the SDK handled comments correctly, the filter becomes overhead with no behavioral effect. Worth tracking."
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review |
There was a problem hiding this comment.
21 of 23 findings addressed in e991ec6. Excellent responsiveness across the board: all three P2s fixed, all P3s resolved, and the nits cleaned up.
Two findings remain without a response:
- CRF-1 (Nit)
sse_filter.go:73:isEventStreamContentTypeduplicatesisSSEContentTypefromchatdebug/transport.go:404. Both parse media type and compare againsttext/event-stream. Thread was resolved without a comment. - CRF-3 (Note)
sse_filter.go:1: No dedicated unit test file for the 193-linesse_filter.go. Internal functions (stats methods, filter goroutine lifecycle, pipe error propagation) are exercised only through integration tests. Thread was resolved without a comment.
Further review is blocked until these are addressed, acknowledged ("won't fix" is fine), or deferred with a ticket. These are low-severity items; a brief response on each thread is sufficient to unblock.
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review |
There was a problem hiding this comment.
All 21 fixes verified across multiple reviewers. No regressions found. CI green.
Contested findings resolved:
- CRF-1 (Nit, code duplication): panel closed 8/8. Dependency direction prevents sharing; two 5-line functions in separate packages is acceptable.
- CRF-3 (Note, no unit test file): panel closed 7/7. Integration tests at the interceptor seam cover the behavioral contract across 8 scenarios.
One new finding (1 P3). The CRF-13 fix extracted ProviderBaseURLHostname as a shared function but the scheme-fallback branch (no-scheme URLs) has no test coverage.
Mafu-san: "21 of 23 non-dropped findings addressed in one commit. Both contested findings now have documented defenses. No findings silently ignored. The fix commit touches exactly 11 files, the same 11 as the original commit. No scope drift."
🤖 This review was automatically generated with Coder Agents.
|
/coder-agents-review |
There was a problem hiding this comment.
CRF-26 fixed in 3f79eb5 with TestProviderBaseURLHostname covering full URL, bare host (scheme-fallback), host with port, and invalid URL.
All 26 findings across 4 rounds are resolved: 22 fixed, 2 panel-closed (contested), 2 dropped. CI green. Test density 59.5%.
🤖 This review was automatically generated with Coder Agents.
OpenRouter can return comment-only SSE heartbeats with no data frames, which previously surfaced as a generic JSON EOF error.
This adds SSE stream accounting for chat completions so empty or malformed upstream streams become clear 502 responses, and rejects OpenRouter-like providers typed as native
openaiwhen slash-namespaced models would otherwise be stripped. Validopenrouterandopenai-compatroutes continue to preserve full model IDs.