CyberCaius on Discord: Claude Desktop said at every start
'Gateway rejected model "magpie-<n>.anthropic.claude-haiku-5-5[1m]"
(HTTP 400)', body "Arouter: prompt_cache_key is required". His
Routing page showed leee/claude-haiku-5-5 served by AnyRouter's
gpt-6.1-sol, with a "." prompt.
Two causes:
- Desktop checks a gateway model as it starts (and from its settings'
Test) with {"model":<it>,"max_tokens":1,"messages":[{"role":"user",
"content":"."}]}, on the shortest id with haiku in it (lWt, JUt and
YT in its app.asar, 2.7032, read from the installed app). desktopTurn
took that small tool-less request for a session title and sent it to
the session's model, AnyRouter's gpt-6.1-sol, so a failure there read
as the haiku rejected. desktopProbe now knows the check, and it goes
to the model it names. Titles still go to the session's model.
- A request translated from an Anthropic client to a Chat or Responses
upstream never had a prompt_cache_key, and AnyRouter refuses one
without. ownCacheKey/cacheKeyOf give it one per conversation (a
hash, in a UUID's shape, of the client's session header, else of its
first user message; it names nothing of magpie) on OpenAI's API with
a key and on providers the user added by address. Presets, signed-in
accounts, plugins, Bedrock and Vertex get nothing new, nor does a
provider whose extraBody (#1604) names prompt_cache_key: the user's
value is the one sent. An upstream whose 400 names the field is asked
again without it and not sent it again (the existing path for Codex's
key); any other 400 is not asked again for magpie's key, so an
unrelated refusal is tried as often as before.
What is sent changes, on purpose, for those providers: the translated
bodies in testdata/upstream_bodies (anthropic-to-chat,
anthropic-to-responses, responses-to-chat and the large one's hash) now
carry the key.
Unticking AnyRouter's Claude models had no part in it: nothing went
to them. The probe was rerouted to the session's pick.
Tests: TestClaudeDesktopProbeAsked (a fake Anthropic "leee" and a fake
Chat relay that answers AnyRouter's 400 without a key: turn, probe of
the haiku alias, title, second turn keeps the key), TestDesktopProbe,
TestOwnCacheKey (scope, extraBody's key left to the user, and a relay
refusing the field asked twice once, then once).
Run (mote):
- go test -tags nogui ./internal/gateway/ -run the new tests,
TestUpstreamBodiesUnchanged, TestExtraBody*, TestOtherBadRequestNot-
AskedAgainAtLow, TestTranslatedEffortMinimalRefused, TestTooFew-
TokensSaidWithSigns, TestHighRiskErrorFallsBack, TestVertex*Retries*
and every *CacheKey* test: ok
- a full ./... run of the first draft at 98e23350f: every package ok
but internal/gateway, whose 8 reds are the two draft faults named
under "Broken by hand", both fixed here
- GOOS=linux and GOOS=windows go vet ./internal/gateway/: ok
- gofmt -l: clean
Broken by hand:
- desktopProbe's branch off: TestClaudeDesktopProbeAsked red, "probe
went to the relay (1 calls)".
- own key off: TestClaudeDesktopProbeAsked red (turn 400 "prompt_cache_key
is required"), TestOwnCacheKey red (1 upstream call, want 2).
- extraBody check off (a first draft): TestExtraBodyTranslated red,
the user's ${sessionId} key replaced by magpie's.
- a first draft retried every 400 once without magpie's key:
TestOtherBadRequestNotAskedAgainAtLow, TestTranslatedEffortMinimal-
Refused, TestTooFewTokensSaidWithSigns, TestHighRiskErrorFallsBack,
TestVertex{Minimal,}RetriesOnlyForVertex red on the extra try; now
only a 400 naming the field drops it.
No GUI file is reached (gateway only). Not tried: a real AnyRouter
account or a real Claude Desktop against this build; the probe's bytes
come from Desktop 2.7032's app.asar.
Not run: the full suite at this head (shipped at once, as asked; it was
queued behind another session's suite on mote).