mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-05 08:02:53 +00:00
Two client-facing errors were uninformative, and a harness cannot recover from either. 1. An unknown model was reported as 400 "the model uses an upstream protocol that opencode2api does not expose". That phrasing is accurate for a model the catalog KNOWS but cannot serve (a capability or routing problem), and wrong for a model the upstream has never offered. A model the upstream retired (it answers 410 Gone) produced this 400, so a harness kept retrying a model that no longer exists. The catalog can now tell the two cases apart (ModelCatalog.Known), and an unknown model returns 404 with code model_not_found. 2. A request whose every attempt failed while WRITING the body was reported as 504 "upstream request timed out". The upstream never finished reading the body, so the payload is too large, and a client that can shrink the request knows to shrink it. Harnesses that recover from an oversized payload generally key on HTTP 413 (and image rejection on 400), so a 504 sent the same oversized payload around forever. A write-phase failure while the request budget is still alive now returns 413 with code payload_too_large; every other phase (headers, first_event) stays a 504, because a slow upstream or a thinking model is not the client's fault. Both paths are applied to the chat, responses and messages endpoints as well as to /v1/systemone. Tests: the 404 vs 400 split, and the 413 vs 504 split. Both mutation-proved: reverting either change fails the matching test.