yapapa / docs /OPENCODE.md
wiwi deploy
Deploy wiwi db5304e
4f29dcb
|
Raw History Blame Contribute Delete
28.4 kB
# OpenCode Console (`opencode`) provider
Deep dive for the one provider whose access depends on the *shape* of the
request rather than on a credential. Everything here was measured against the
live upstream on **2026-10-14**; the client fingerprint and the client-metadata
refusal were re-probed on **2026-10-15** (see
[Re-verified 2026-10-15](#re-verified-2026-10-15-the-fingerprint-itself-is-current)).
Where a claim is transcribed from documentation instead of probed, it says so.
- [What it is](#what-it-is)
- [The free-tier admission gate](#the-free-tier-admission-gate)
- [The caller's `metadata` block is refused upstream](#the-callers-metadata-block-is-refused-upstream)
- [How the shape was derived](#how-the-shape-was-derived)
- [What changed, and why](#what-changed-and-why)
- [Code map](#code-map)
- [Diagnostics](#diagnostics)
- [Re-deriving the shape when the client moves](#re-deriving-the-shape-when-the-client-moves)
- [Not fixable here](#not-fixable-here)
> This is the **worked example** for [UPSTREAM_DIAGNOSIS.md](UPSTREAM_DIAGNOSIS.md),
> which is the provider-agnostic playbook: how to tell a credential refusal from
> an entitlement one from a request-shape one, and how to isolate the cause. Read
> that one first whenever *any* provider returns a `4xx` you cannot explain.
---
## What it is
OpenCode Console (historically "Zen") is a multi-protocol gateway. Which wire a
model uses is **published per model**, not derived:
| wire | models | canonical base | endpoint | credential header |
|---|---|---|---|---|
| responses | `gpt-*`, `grok-*`, `muse-spark-*`, `muse-ember-*`, `muse-wonder-*` | `https://opencode.ai/inference/openai/v1` | `{base}/responses` | `Authorization: Bearer` |
| messages | `claude-*`, `qwen3.8-flash`, `qwen3.7-*`, `qwen3.6-*`, `qwen3.5-*` | `https://opencode.ai/inference/anthropic/v1` | `{base}/messages` | `x-api-key` |
| gemini | `gemini-*` | `https://opencode.ai/inference/google/v1beta` | `{base}/models/{id}:generateContent` | `x-goog-api-key` |
| chat | everything else | `https://opencode.ai/inference/openai/v1` | `{base}/chat/completions` | `Authorization: Bearer` |
The four wires publish **four different canonical bases** (re-fetched 2026-11-19
from the docs table and models.dev; see the adapter's `_ROUTE_BASES`). A
deployment-set `base_url` overrides them all β€” the legacy single-base escape
hatch. Base: `https://opencode.ai/inference/openai/v1`. The legacy
`https://opencode.ai/zen/v1` **still routes** and existing configs keep working;
only the default moved.
The legacy base is for **paid** models. Probed 2026-10-15 with this adapter's
exact request shape, the same anonymous request that answers 200 on
`/inference/v1` answers `403 FreeTierError` on `/zen/v1` (`space-bunny-free` and
`muse-spark-1.3-contributor-free`, both directions). So a free-tier deployment
pointed at `/zen/v1` 403s for a reason that has nothing to do with the
fingerprint β€” check `base_url` before bisecting headers.
Two consequences of the table that are easy to get wrong:
- **The qwen family straddles two wires.** `qwen3.8-max` is on chat;
`qwen3.8-flash` and the qwen3.7/3.6/3.5 lines are on messages. A `qwen`
prefix sends the wrong one to `/messages`. Hence `_ROUTE_RULES`, a table.
- **`models.dev` carries no per-model overrides.** Its `opencode` entry is a
bare `@ai-sdk/openai-compatible` with one base. The split above exists only on
the docs page, so the table is transcribed from there and is the authority.
`jev-*` is the one published model with **no completion wire**: it is a System
One model on `{base}/systemone` (a typed `state` + `questions` β†’ values/
probabilities protocol). It falls through to chat and fails upstream; this
adapter does not claim to serve it.
Every request asks for SSE (`force_stream`): Console answers as an event
stream, so a non-streaming caller's reply is pumped and reassembled by
`Gateway._complete_via_stream`. The Gemini route is the exception β€” its wire is
selected by the URL, so its body carries no `stream` field.
---
## The free-tier admission gate
`*-free` models (and the stealth `big-pickle`) answer `403 FreeTierError`
unless the request *looks like the OpenCode client*. This is a **shape** check,
not an auth check: it fires before authentication, so a bogus bearer reads
exactly like no bearer.
A request is admitted when **all** of these hold:
| # | condition | why it exists |
|---|---|---|
| 1 | `stream: true` in the body | the free tier only serves the event stream |
| 2 | `x-opencode-session` **and** `x-opencode-session-id` both present, id shaped `ses_` + 12 hex + 14 base62 | session affinity |
| 3 | `User-Agent: opencode/<version>`, version β‰₯ ~1.19 | minimum-client gate |
| 4 | tool payload contains `read` **and** `shell`, each carrying the client's real parameter schemas | "is this a coding agent" |
| 5 | `Authorization` **present** (any value; anonymous uses `Bearer public`) | the gate reads presence |
| 6 | `HTTP-Referer` and `x-opencode-request` **absent** | the client sends neither |
Two of those deserve emphasis because they contradict the obvious reading:
- **Condition 4 reads the schemas, not the names.** Six inert decoys 403
however they are named; six *real* tools with their names rewritten 403;
`read`+`shell` with `parameters` emptied 403. Only the **description** may be
substituted. This is why the decoys are the client's real tool definitions
wearing an inert description rather than empty stubs.
- **Condition 5 is about presence, not validity.** The adapter used to *omit*
`Authorization` for the `anonymous` sentinel β€” deliberately, on the theory
that a placeholder bearer would be `401`. But the gate needs the header to
exist, and the anonymous client satisfies it with `Bearer public`. Omitting it
403s even with a perfect body.
Measured matrix (each row differs from the passing row by exactly one factor):
| change | result |
|---|---|
| captured client request, replayed verbatim | **200** |
| tools: none | 403 |
| tools: 5 real | 403 |
| tools: 6 real | **200** |
| `read`+`shell`, real schemas | **200** |
| `read`+`shell`, description swapped | **200** |
| `read`+`shell`, `parameters` emptied | 403 |
| 6 inert decoys, any names | 403 |
| 6 real tools renamed | 403 |
| drop `x-opencode-session-id` | 403 |
| drop `Authorization` (the keyless path) | 403 |
| add `HTTP-Referer` | 403 |
| add `x-opencode-request` | 403 |
| drop `x-opencode-project` / `-client` / `Accept` / `b3` / `traceparent` / `x-session-affinity` / `x-session-id` | **200** |
| session `ses_`+26-char | **200** |
| session `ses_`+64-hex | 403 |
| UA `opencode/1.19.0` / `2.0.26` / `latest/2.0.26/cli` | **200** |
| UA `opencode/1.16.0` / `1.17.0` | 426 UpgradeRequired |
| UA `opencode/unknown` | 403 |
Note the session id: the **v2 CLI's own** `ses_<64 hex>` ids are rejected. That
`^ses_[0-9a-f]{64}$` pattern found in the binary belongs to a different id space;
the header carries the 26-char form, which is what we already minted.
The session id is reused per credential (TTL 1 h, LRU-capped at 1000 buckets)
rather than re-minted per request, mirroring the client. The allowance itself is
**not** accounted per session: OpenCode's support statement (2026-10-22) says it
is set and enforced for the *account, workspace and network*, and the reset
window is not exposed to clients. Re-minting ids buys no quota β€” it only stops
the request looking like the client β€” and rotating them on an exhaustion error
would be quota evasion against the vendor's own abuse control, so this adapter
never does it.
---
## The caller's `metadata` block is refused upstream
A free-model request can come back as:
```
400 <account>: Upstream request failed: [unsupported_metadata] Client metadata is not supported.
```
Three layers are stacked in that one line, and separating them *is* the
diagnosis:
| layer | contributes |
|---|---|
| Console (Zen) | `Upstream request failed: <…>` β€” its wrapper for a refusal by the provider behind it. Codes outside Console's allow-list are dropped and the original is kept as a `[code]` label in the message; opencode's own client pins that format (`packages/ai/test/provider-error.test.ts`: *"Zen drops upstream codes outside its allow-list and replaces the type, but `Protocol.errorMessage` keeps the original code as a `[code]` prefix"*). |
| the provider behind Zen | `unsupported_metadata` Β· "Client metadata is not supported." |
| wiwi | `<provider account>: <message>` β€” `base.py`'s 400 branch renders `f"{provider}: {msg}"`, so the prefix names the *account*, not the model group. |
The refused field is the **caller's**, not the adapter's fingerprint: both
inbound codecs capture a top-level `metadata` into `req.extras`, and both
delegates forward it (`openai_adapter._STANDARD`,
`anthropic_adapter._ANTHROPIC_STANDARD`) β€” right for the vendors that support
the field, wrong behind Zen. Zen's own client puts no `metadata` on the wires
this adapter speaks: its request builder attaches one only on the Responses
protocol, and only when provider options set it. So the upstream never sees the
field from a real client, and sees it from us.
`_drop_client_metadata()` therefore removes a *caller-supplied* `metadata` from
every body this adapter sends β€” free and paid alike, because this is a provider
fact rather than a tier gate β€” and logs `opencode_client_metadata_dropped` with
the route. An operator who wants the field on the wire anyway declares it
themselves: `extra_body: {metadata: …}` is left alone and wins over the caller's
copy.
Two other proxies hit the same refusal class and fixed it the same way β€”
openclaw #73963 (`{"detail":"Unsupported parameter: metadata"}` from the ChatGPT
Codex backend) and CLIProxyAPI #5112.
**One caveat, stated so it is not mistaken for a general fix:** the Responses
route never forwarded extras, so if the failing deployment is the one
responses-route free model (`muse-spark-*-contributor-free`), the caller's
`metadata` was never on that wire and something else is refusing it. Get the raw
upstream type before assuming this entry covers it.
### Re-verified 2026-10-15: the fingerprint itself is current
The report arrived framed as "our client metadata is stale, refresh it from the
client", so the fingerprint was re-derived from the client's own source
(`sst/opencode` at commit `4397ee4`, the head on 2026-10-15) and probed row by
row. It is **not** stale β€” every value the gate reads is the one the current
client sends:
| our value | current client | probe |
|---|---|---|
| `x-opencode-session` = `x-opencode-session-id` = `ses_` + 12 hex + 14 base62 | same shape: `Identifier.descending()` (`packages/schema/src/identifier.ts`) mints exactly that | 200 |
| `x-opencode-project: global` | `ProjectID.global` is the literal `global` (`packages/schema/src/project-id.ts`) | 200 |
| `x-opencode-client: cli` | `app.name` | 200 |
| `User-Agent: opencode/<version>` | `opencode/<channel>/<version>/<name>` | both 200 |
| no `x-opencode-request` | none sent | adding one still 403s |
The request *builder* now lives at `packages/core/src/session/model-request.ts`;
the path the 2026-09 capture read (`packages/opencode/src/session/llm/request.ts`)
no longer exists. It also sets `x-session-affinity`, `X-Session-Id`,
`x-opencode-parent-session-id` and a body `promptCacheKey` β€” none load-bearing
(probed: 200 with and without).
Sweep of every current free model with the adapter's exact shape: **200** for the
nine servable ones, end-to-end through the gateway as well as direct (2026-10-15,
caller `metadata` block included, chat / messages / responses inbound all three
answer). The two that are not servable are not shape failures: `jev-1.13-free`
is the System One model above β€” chat and responses both answer
`400 ModelProtocolUnsupported` β€” and `step-5-preview-free` intermittently
answers `429 … Endpoint is unavailable.` from its own upstream. (`exo-free` and
`mimo-v2.5-free` have since left the catalog.) Ablations that still 403: a
`ses_`+64-hex id in `x-opencode-session-id`, a `prj_`-style
`x-opencode-project`, and (as before) dropping the metadata headers. Ablations
that change nothing on the anonymous path: a body `metadata`, `store` or
`prompt_cache_key`.
### The free allowance is a quota, not a rate limit
When the allowance is spent, Console answers **`429 FreeUsageLimitError`**:
```
io rate limited: Free usage limit reached. Free models work in OpenCode
(https://opencode.ai); subscribe to OpenCode Go to keep going:
https://opencode.ai/go
```
Two things about that refusal matter more than its status:
- **It is not a request-shape problem and not a bad key.** The same request that
answered 200 a minute earlier gets it, and a real Zen key gets it *sooner* than
the `anonymous` sentinel (probed 2026-09-19: a paid key is charged against the
same allowance). The fix is a fresh allowance β€” a paid Console balance, a Go
subscription (`opencode-go/*` models), or another provider β€” never a new
fingerprint.
- **The window is real but not disclosed.** The error usually carries a
`Retry-After` (measured: `retryAfterMs: 32217000`, ~9 h), and users report the
countdown restarting without usage ([#58205], [#58284], [#59387]). Nothing in
the CLI/API exposes the reset time, so an operator cannot schedule around it.
A *separate* refusal means the **source address** was flagged:
```
OpenCode's free models aren't available from your current network because we've
detected abusive traffic from this IP address.
```
That one is explicitly about the network, not the account, and OpenCode says
only their team can lift it. Both refusals are the vendor's abuse/allowance
control, so wiwi does not rotate the session id or the egress address to get
around them β€” that is exactly the behaviour they exist to detect.
[#58205]: https://github.com/anomalyco/opencode/issues/58205
[#58284]: https://github.com/anomalyco/opencode/issues/58284
[#59387]: https://github.com/anomalyco/opencode/issues/59387
**What wiwi does with it** (`wiwi/providers/base.py:is_quota_refusal`): a 429
whose body names a quota marker (`FreeUsageLimitError`, `GoUsageLimitError`,
`BlackUsageLimitError`, `MonthlyLimitError`, `UserLimitError`, or the wording
"usage limit reached") is classified as an entitlement refusal β€” **402
`permission_error`, retryable, vendor type preserved** β€” not as a rate limit.
`status_for_key_pool` therefore reports `None`, so the shared `anonymous`
sentinel is **not** cooled and the tier's other deployments keep serving; the
request still fails over because the error stays retryable. A refusal that
arrives inside a 200 event stream gets the same classification from
`opencode_adapter._stream_error`. A plain 429 β€” a rate limit with no quota
wording β€” keeps the old path (`429` β†’ cool the key for its `Retry-After`).
**The refusal wraps instead of erroring.** An entitlement refusal is not a
transient fault: the same deployment answers the same way for as long as the
allowance is spent, so the retry loop must not spend its budget re-asking it
(`wiwi/router/router.py:entitlement_refusal`, AUDIT #600). The request leaves
the group at once and the **fallback group takes over** β€” declare one with
`router_settings.fallbacks`, or put a second provider in the same model group,
and the caller gets an answer in its own dialect instead of the upstream's
billing state. Measured through the gateway: before the wrap the exhausted
deployment was asked three times (and two backoff sleeps were paid) before the
fallback was even entered; now it is asked once and the fallback serves the
request. A credential failure is untouched β€” that one still fails over to the
*next key* of the same deployment (AUDIT #597), because a key can be bad
while the account is fine.
**The reset window is read from the body.** The upstream states it as
`retryAfterMs` inside the error object and sends **no** `Retry-After` header,
so the window used to be invisible: the caller was told its allowance was
spent with no idea when to come back, and the proxy log could not name it
either. `error_from_provider_status` now reads `retryAfterMs` (ms) and
`retryAfter`/`retry_after` (s) out of the body, so the client gets a
`Retry-After` header and the proxy log says "account entitlement (402): … ;
resets in 32217s".
**A single upstream 429 can read as a whole-tier outage.** Every free
deployment shares the `anonymous` marker, and an ordinary 429 is a key-health
signal (`base.status_for_key_pool`): the router cools *that key* for its
`Retry-After`, else 30 s (`wiwi/router/router.py`, standard mode β€”
`cooldown_time` is not the knob on that path). Measured 2026-10-15 through the
gateway: with **one** `anonymous` key entry, one model's `429 … Endpoint is
unavailable.` (`step-5-preview-free`) left the next 16 consecutive requests β€”
every other free model, all three inbound dialects β€” answering `503 no healthy
deployment for '<group>'`, and a second run lost 25 the same way. With **two**
entries for the marker the same blip cost three requests. The sentinel is not an
account, so "cooling the key" retires the only path every free model shares.
Serve free models for real? Declare more than one entry for `anonymous`.
Tracked as `AUDIT.md` #469, whose quota half is #556.
---
## How the shape was derived
The method matters as much as the result, because the obvious one produced a
wrong answer first.
1. **Capture.** Put a logging proxy in front of the provider via a config
override (`provider.opencode.options.baseURL`), run the real client, and dump
the headers and body it actually sends.
2. **Replay.** Send those exact bytes straight to the upstream. If that 200s,
the difference is in the request and the exercise is worth continuing.
3. **Bisect.** Remove one factor at a time, body and headers separately. Every
row in the table above is one such removal.
4. **Rebuild.** Send our adapter's request, confirm 200, then confirm each
header/body our adapter adds on top of the minimum is load-bearing.
### The trap that cost a round
An earlier round concluded the free tier had been **closed upstream**, made the
decoy cloak opt-in, and justified both with a control: *"the genuine unsigned-in
opencode CLI fails identically from this host."*
That control was invalid. It was run from a scratch directory whose
`opencode.json` overrode the provider `baseURL`, so the 403 it observed came
from the broken override rather than from the gate. Run from a clean directory,
the same command answers **200**.
> **A control that shares infrastructure with the thing under test proves
> nothing.** Re-run it in isolation before building on it. Eleven working
> deployments were detached on the strength of that broken control.
---
## What changed, and why
| # | before (v1) | after (v2) | reason |
|---|---|---|---|
| 1 | decoys `bash` + `read`, `parameters: {}` | `read` + `shell` with `_DECOY_PARAMETERS` | v2 renamed `bash`β†’`shell`; the gate reads the schemas |
| 2 | `anonymous` **omitted** `Authorization` | `Bearer public` on the OpenAI-wire routes | gate reads header presence |
| 3 | `x-opencode-session` only | both `x-opencode-session` and `x-opencode-session-id` | v2 rides the pair |
| 4 | sent `HTTP-Referer`, `x-opencode-request` | both removed | client sends neither; each one alone 403s |
| 5 | UA fallback `unknown` | fallback `1.19.0` | `unknown` 403s; <~1.19 is 426 |
| 6 | route by prefix (`"qwen"` β†’ messages) | `_ROUTE_RULES` table, chat default | `qwen3.8-max` is a chat model |
| 7 | cloak always on | `opencode_free_tier_cloak` opt-**out** | default must satisfy the gate; paid-only deployments can turn it off |
Items 3 and 4 removed symbols with no remaining caller: `OPENCODE_REQUEST_RE`,
`canonical_request_id()`, and `_spoof_request`.
Item 5 was a silent outage of its own: with a cold cache the adapter sent
`opencode/unknown`, so the first ~10 s after every boot β€” and every request while
npm was unreachable β€” failed all free-model traffic.
---
## Code map
| Concern | Where |
|---|---|
| routing table, route selection | `wiwi/providers/opencode_adapter.py` β€” `_ROUTE_RULES`, `route_for_model()` |
| default base | `opencode_adapter.OPENCODE_ZEN_BASE` |
| credentials per wire | `_CREDENTIAL_HEADER`, `headers()` |
| anonymous marker | `ANONYMOUS_KEY_SENTINEL`, `ANONYMOUS_BEARER` |
| decoy definitions | `_DECOY_NAMES`, `_DECOY_PARAMETERS`, `_decoys_chat()`, `_decoys_responses()` |
| cloak switch | `FREE_TIER_CLOAK_PARAM`, `_cloak_requested()` |
| decoy call suppression | `_filter_decoys()`, `_filter_decoys_turn()` |
| session id | `canonical_session_id()`, `OPENCODE_SESSION_RE`, `stable_session_id()` |
| caller's `metadata` drop | `_drop_client_metadata()` |
| User-Agent | `wiwi/providers/opencode_version.py` β€” `build_user_agent()`, `FALLBACK_VERSION` |
| per-deployment flag | `DeploymentParams.opencode_free_tier_cloak` β†’ `Deployment` β†’ the gateway's params dict |
```yaml
providers:
- name: zen
provider: opencode
# base_url is optional: the adapter routes each model to its canonical
# per-wire base (https://opencode.ai/inference/openai/v1 here); a set
# base_url overrides all four wires.
keys:
- {label: main, key: os.environ/OPENCODE_API_KEY} # paid models
- {label: anon, key: anonymous} # free models: Bearer public
```
```yaml
model_list:
# default: cloak on, which the free tier needs
- model_name: bunny
wiwi_params: {provider: zen, model: space-bunny-free}
# paid-only deployment: no phantom tools in the payload
- model_name: paid
wiwi_params: {provider: zen, model: glm-5.1, opencode_free_tier_cloak: false}
```
---
## Diagnostics
**Reading the error.** The string a client sees is wiwi's own classification,
not the upstream's:
```
io requires billing (403): OpenCode's free tier can only be used from within OpenCode.
```
`error_from_provider_status()` maps the upstream's `FreeTierError` to
`402 / permission_error`, and `status_for_key_pool()` returns `None` for it β€” a
policy refusal never retires a healthy key, and the request fails over to
another deployment instead. So **this message always means "the request shape
was refused"**, never "your key is wrong" and never "the tier is closed".
A **`400 <account>: Upstream request failed: [unsupported_metadata] Client
metadata is not supported.`** is a different refusal β€” Console relaying the
provider behind it, which objects to the caller's `metadata` block, not to the
fingerprint. See
[The caller's `metadata` block is refused upstream](#the-callers-metadata-block-is-refused-upstream).
A **`402 io quota exhausted (429): io rate limited: Free usage limit reached …`**
is the free allowance, not a key: `FreeUsageLimitError` on a 429 is classified as
an entitlement refusal, so the key is left in rotation and the tier keeps
serving (see [The free allowance is a quota](#the-free-allowance-is-a-quota-not-a-rate-limit)).
The refusal **wraps**: the request leaves the group at once and the fallback
group serves it, so the caller does not see the upstream's billing state β€” and
when there is nowhere to fail over to, the response carries the upstream's
own reset window as a `Retry-After` header (measured: `retryAfterMs:
32217000`, ~9 h). The vendor's own advice in the message is the remedy β€” paid
Console credit, a Go subscription, or another provider. Do **not** answer it by
rotating the session id or the egress IP: both are the vendor's abuse
controls, and the flagged-IP refusal above is what that buys.
A **`403 io blocked this network (403): … abusive traffic from this IP address`**
is the flagged-egress refusal, classified as `permission_error` rather than as a
bad credential (AUDIT #557). The key is left in rotation and a fallback group on
another provider can still serve; retrying the same egress cannot, and
`docs/UPSTREAM_DIAGNOSIS.md`'s "is it the credential, the entitlement, or the
request shape" test does not apply β€” this one is about the network.
**Triage order** when a `*-free` model suddenly 403s β€” check the cheap ones
first:
1. `User-Agent` on the wire. `opencode/unknown` means the version cache is cold
or npm is unreachable; anything below ~1.19 shows up as `426`.
2. Tool names in the body: `read` **and** `shell` present?
3. Their `parameters` non-empty? An empty `{}` is the 403.
4. `Authorization` present on an OpenAI-wire route?
5. Both session headers present?
6. No `HTTP-Referer`, no `x-opencode-request` (they should not exist any more β€”
if they are on the wire, something bypassed this adapter).
**Useful log lines** (all `debug`):
```
opencode_credential_anonymous route=chat reason: Bearer public sent
opencode_credential_omitted route=... reason=anonymous_sentinel
opencode_credential_scheme route=... scheme=... (a wrong scheme is silently unread upstream)
opencode_decoy_call_dropped tool=... index=...
opencode_client_metadata_dropped route=... (a caller's `metadata` block, refused upstream)
opencode_free_quota_exhausted message=... (warning: the free allowance is spent)
opencode_version_refreshed version=...
```
**Cheap live check** without spending a request through the gateway:
```bash
python3 - <<'PY'
import httpx
from wiwi.ir import types as ir
from wiwi.providers.base import ProviderKeyRef
from wiwi.providers.opencode_adapter import OpencodeAdapter
from wiwi.wire import openai_chat as oc
req = oc.decode_request({"model": "m", "messages": [{"role": "user", "content": "hi"}]})
a = OpencodeAdapter()
body = a.encode_request(req, "space-bunny-free", {})
url = a.build_url("", "space-bunny-free", True)
h = a.headers(ProviderKeyRef(label="anon", secret="anonymous"))
r = httpx.post(url,
content=__import__("orjson").dumps(body), headers=h, timeout=90)
print(r.status_code, r.text[:120])
PY
```
`200` means the shape is good and the fault is elsewhere (model retired,
account, route). `403` means the shape regressed.
---
## Re-deriving the shape when the client moves
This will happen again: the client renamed a tool once already, in one release.
When a free model starts 403ing across the board **and the real client still
works from the same host**, do this β€” in order, and do not skip step 1:
1. **Confirm the client works, cleanly.** Run it from a directory with no
`opencode.json` override, no `baseURL` shim, no proxy. If the client also
403s, the problem is the account, the network, or the tier β€” not our shape.
2. **Capture** its request (config `baseURL` override β†’ logging proxy β†’ dump).
3. **Replay** the bytes directly. A replay that fails means the difference is
*not* in the HTTP request; stop and look elsewhere.
4. **Bisect** one factor at a time β€” body and headers separately, because a
minimal probe body can fail for an unrelated reason (an early round spent
hours proving headers "didn't matter" with a body the gate rejected anyway).
5. **Update** `_DECOY_NAMES` / `_DECOY_PARAMETERS` / `headers()` /
`FALLBACK_VERSION`, then re-verify with the live check above.
6. **Record** the new matrix in `AUDIT.md` and `UPDATE.md`, and correct the
stale claims rather than appending to them.
Rules that keep this honest:
- Never widen a rule by guessing a prefix. Add the model's row from the docs.
- Treat "the tier is closed" as a hypothesis with a working control, never a
conclusion from a failing one.
- If a probe disagrees with the docs, record **both** and say which is which.
---
## Not fixable here
Some `403`/`410`/`404`s are upstream facts, not shape problems:
- **Retired models** answer `410 ModelDeprecated` (`exo-free`, `mimo-v2.5-free`).
- **Withdrawn from a gateway** β€” OpenRouter has dropped
`stealth/space-bunny-alpha`, `stealth/ox-alpha`, `minimax/minimax-m3:free`.
- **Paid models with an empty account** answer
`402 Insufficient account funds`. The free tier's 403 fires *before* the funds
check, so a funded account does not change it β€” but a funded account is what
paid models need.
- **Region blocks** arrive as `RegionError`, a different type.
When one of these is the cause, the fix is to remove the deployment from the
catalog, not to change the adapter. A model that answers `410` will never answer
anything else.