Preserve Go and Zen OAuth routing while fixing authentication, secret redaction, streaming, transport, and configuration issues.
Refresh README and management guides in four languages while preserving sponsors, LinuxDo acknowledgements, and Linux/Docker quick start instructions.
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.
- Remove the new/New prefix from constructors; rename the colliding
types semantically (ModelCatalog, RuntimeController, Metrics,
LogBroker, Redactor, proxyTransports, upstreamNodes, ...).
- Unify upstream lane naming on v1 (/zen, OpenCode 1.x shape) and v2
(/inference and /zen/go, 2.x CLI shape); add models.IsV1Upstream and
drop the duplicated lane detection.
- Fix inaccurate, truncated and stale comments across all packages and
document exported symbols plus non-obvious internals.
- Fix anthropicThinking passing "enabled"/"adaptive" through as an
effort; derive the level from the budget instead.
- Delete dead code (identity.StableID, unused protocol decoders and
stream parser wrappers).
- Export EffectiveListeners, rename modelsDev* metadata constants, and
describe the metadata source as the OpenCode endpoint.
- Rename the forced-collapse log event to stream_collapse_failed and
add an anonymous field.
- Correct the README upstream.zen default and add upstream.anonymous.
When every attempt died on the proxy route itself, the gateway answered
with a generic 502 "all upstream attempts failed", pointing operators at
the upstream instead of their proxies.
Attempt errors that fail before a connection to the upstream exists
(proxy dial, CONNECT/SOCKS handshake, tunnelled TLS) are now tagged as
proxy failures on real proxies; direct transports are left untouched.
The anonymous lane also reports a proxy failure when no proxy is healthy.
When the final error is such a failure, the inference and System One
handlers return 503 with type "proxy_error". Any upstream HTTP response
is still forwarded as before, so genuine upstream errors are not
mislabelled.
attempt_timeout_seconds only reached the transport's
ResponseHeaderTimeout, which starts after the request body is written, so
an exit wedged in dial or request write could consume the whole request
budget. When the option is set, each attempt now also carries a context
deadline covering dial, write, headers and, when enabled, the first SSE
event; a committed stream is never cut. Legs record the phase an attempt
died in. A timeout after the upstream already answered is slow generation,
not a broken proxy, so it does not evict the exit.
Co-authored-by: mcheiyue <2267610721@qq.com>