Files
magpie/internal
ggbdpqandyetone 4ed379f116 gateway: error words escaped as \uXXXX are read by the other deciders too
What changed: #1669 taught failure(), resetsWritten and the per-model
rest's other-models check to read a JSON error whose encoder escapes
what isn't ASCII (Python's json.dumps does by default), but the other
word-list deciders still matched the raw body:

- modelRefused and modelRetired (fallback.go): an escaped 模型不支持
  refusal rests the whole key or account (a cooldown, longer on
  repeats) instead of the model alone (#1235's class), and the escaped
  quota words of their negation are missed the same way. The candidate
  loop's restAfterMarked feeds them the vendor's body as it arrived,
  and the decision group's decideFailed the raw postDecide body; a
  chat's rewritten error carries the decoded message, which is why the
  chat path was spared.
- retryable (fallback.go): an escaped 额度已用完 on a 400 reads as not
  retryable, so a decision group returns the error instead of asking
  its next decision model.
- alwaysThinks (gateway.go, both 400 learn-again sites): a vendor's
  escaped 思考不可关闭 refusal is not asked again with thinking left to
  the model (#699's class), so the agent sees the 400 every turn.

All three now match on wordsOf(body), as failure() already does.

Run:
- New TestAnthropicPassthroughAlwaysThinksInEscapedChinese sends the
  escaped refusal through /v1/messages: on the old code 400 after 1
  call (the re-ask not taken), with the change 200 after 2.
- New TestEscapedWordsReadByTheOtherDeciders: modelRefused(403, escaped
  模型不支持) and retryable(400, escaped 额度已用完) are false on the
  old code, true with it; the same refusals unescaped stay true.
- Both fail with the fix stashed, pass restored. go test -tags nogui
  -count=1 ./internal/gateway: ok. The named tests and the guards they
  touch (TestAnthropicPassthroughAlwaysThinksInChinese,
  TestModelNotInPlanRestsTheModelNotTheKey, TestFailureReadsEscapedWords,
  TestResetsWritten, TestWrittenResetRestsUntilThen) also -race -count=5:
  ok. go test -tags nogui -count=1 ./... under a temp HOME: ok.
  gofmt -l internal/ empty. go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: clean but the trayimage_darwin.go
  cgo -Wenum-conversion warning, as on main. Builds: darwin, linux
  (-tags nogui), windows.

Rebased by yetone onto main, where both learn-again sites ask
refusesThinkingOff (anthropic.go, #1465): the decoding moved there.

Co-authored-by: yetone <yetoneful@gmail.com>
2026-10-13 10:40:35 +08:00
..
…
…