What changed: refusedOptional's recognizer (unsupportedOptionalField) gains
valueRejectedForField, for a vendor that names the field after the value it
turned away: litellm's "'priority' is not supported for 'service_tier' on
this model", handed to the agent as a plain 400 today, on both shapes the
relay sends — the bare prose (0.1.1330) and the backend's JSON embedded in
litellm's message (0.1.1829, unwrapped by the existing structure-first
walk). The name after "for" is what separates the field's refusal from a
value's ("... is not supported with this model"), which still reaches the
client as it came.
Both readers of refusedOptional take it, so the tier is dropped, the
request is asked again, and the provider isn't sent it again: a relayed
Chat or Responses request that carries the field (#393's path), and the
agent's own request on a provider the user added by its address (OwnTier),
which forwards the tier on purpose (chat.go, responses.go) and asks again
without one that turns the field away.
Run: TestRefusedOptionalNamesOnlyUnsupportedFields gains two rows (the
prose and the JSON-embedded shape, each under the direct, litellm and
openrouter wrappers) and TestServiceTierRefusedForTheValueRetried (a fake
upstream answering the issue's body) fails without the change — turn 1:
400 after 1 calls, want 2 — and passes with it: two tries, the second
without the tier, and the provider marked unfit for it. The value rows
(unsupported-value, tier-value) stay nil/pass. gofmt -l clean; go vet,
GOOS=linux go vet -tags nogui, GOOS=windows go vet ./... pass; go build,
GOOS=linux go build -tags nogui, GOOS=windows go build pass. In
go test -tags nogui ./... every package passes but three tests that fail
the same way on the unmodified base (ba3a7384f) — TestMothX,
TestProxyCheckSaysAProxyPassedBy and TestHostToldTheGatewayAddress, which
are Bun-, proxy- and port-timing-sensitive on this machine; internal/
gateway passes, targeted and in the suite.
Review (magpie): the regex needs a field name after "for", so "is
not supported with this model" still reaches the client as it came
(the table's unsupported-value rows). The tier is remembered unfit for
the provider, every model of it. Run on the Mac mini: go test
./internal/gateway -count=1 ok. Broken by hand: gateway.go at the base
- both litellm rows of TestRefusedOptionalNamesOnlyUnsupportedFields
and TestServiceTierRefusedForTheValueRetried ("400 after 1 calls")
red. Not tried: a real litellm relay.
Generated-by: GLM-5.3-Flash (ZCode)
pi-ai sends {"prompt_cache_options":{"mode":"explicit"}} on the Responses
API. The ChatGPT backend behind a Codex subscription answers 400:
{"error":{"message":"prompt_cache_options is not supported on this
model","type":"invalid_request_error","param":"prompt_cache_options",
"code":"invalid_parameter"}}
Probed on 2026-10-14 with a read-only use of the owner's Codex token
(never refreshed or written): gpt-5.5, gpt-6-sol, gpt-6-astra,
gpt-6-luna and gpt-5.6-sol all refuse it, and the same requests without
the field return 200.
- codexBody drops prompt_cache_options with the other fields the backend
turns away. prompt_cache_key stays; the backend follows it (#1473).
- prompt_cache_options joins the gateway's optional fields. Its refusal
names the field bare, at the start of the message, which none of the
existing patterns read, so unsupportedOptionalField also takes
"<field> is not supported/unsupported" when the message starts with
it. Only at the start, so a field named inside an echo of the input is
not taken for it. As for the other optional fields, the refusal is
remembered per provider, though OpenAI's wording says "on this model";
the cost of that is a cache hint left off, never a failed request.
Run: go test -tags nogui for internal/gateway (40m timeout; load ~380
from other sessions), provider, catalog, codexcat and agent; gofmt -l;
go vet darwin, GOOS=linux -tags nogui, GOOS=windows. With each fix taken
out by hand, TestRefusedOptionalNamesOnlyUnsupportedFields,
TestPromptCacheOptionsRefusedRetried and
TestCodexBodyDropsPromptCacheOptions go red.
Not tried: pi-ai itself against a Codex subscription.