gateway: a picked model that turns an image away gets it described, not another provider (xyenon)

xyenon (Discord #feedback) picked provider-1/DeepSeek-V4.1-Flash in pi
with an Image recognition model set. An image they sent wasn't
described; the request was answered by provider-2/DeepSeek-V4.1-Flash.

Cause: provider-1's list says nothing of images, so magpie took
models.dev's word for the model (catalog.SeesImages: text+image) and sent
the raw image. The relay answered DeepSeek's 400 "Failed to deserialize
the JSON body ... unknown variant `image_url`, expected `text`". That
matches shapeWords, so the try failed as a shape refusal and went on to
the next candidate: provider-1's fallback (or the next group member),
the same model at provider-2, which sees. The describer was never asked.

Fix: a 400/415/422 whose words say images aren't taken (imageRefused:
unknown variant image_url/input_image/image, OpenAI's "only supported by
certain models", OpenRouter's "no endpoints found that support image",
vLLM's "not a multimodal model", 不支持图片 and the like) marks the model
blind for this server's run (refuseSight; blindTo checks it first). With
a describer, the same candidate is asked again at once with the images
described (seenBody, or seenGroup for a group), before any fallback or
other member; the try reads failSight, which the Routing page tells as
its own story (en/zh/zh-TW/ja/de); the row then reads answered, as
for floor's and foreign's re-asks. Later requests
are described up front, for a direct pick and a group (user or auto)
alike, on Chat, Responses and Messages.

Kept on purpose: with no describer (Image recognition off, or no model
that sees), going on to a candidate whose copy sees is the only way to
answer, so it still does (TestRefusedImageWithNoDescriberGoesToOneThatSees).
Documented in docs/subsystems/gateway-routing.md, "A model that turns an
image away".

Run (on mote, through mote-run):
- TestPickedModelThatRefusesAnImageIsGivenItDescribed (9 subtests:
  direct pick with a fallback, user group, group/auto-…; each API),
  TestRefusedImageWithNoDescriberGoesToOneThatSees, TestImageRefused: ok.
- Broken by hand: with gateway.go/vision.go/routing.go reverted to
  origin/main (d9cf85ae8), all 9 subtests fail with "the same model at
  the other provider was asked 2 times" and the raw image sent there.
- go test -tags nogui ./internal/gateway -count=1 -timeout 45m: ok (996s)
  at the d9cf85ae8 base. After rebasing onto 4534561f6: the new tests
  and -run 'Vision|Image|Shape|Group' in internal/gateway ok, and the
  three vets and gofmt again clean.
- go vet ./internal/gateway (darwin), GOOS=linux and GOOS=windows
  go vet -tags nogui ./internal/gateway, gofmt -l: clean.
- GUI: routing-sight (new, 5 languages) and i18n-keys in chromium on
  mote: ok. routing-sight and routing-shape in webkit on the Linux box
  (wsl-run): ok. WebKit on mote couldn't launch (browserType.launch
  timed out at 180s beside other sessions' webkit stuck 2h, routing-shape
  untouched failed the same), so its webkit leg ran on Linux instead.

Not tried: a real pi session against a real text-only DeepSeek relay
(no such account here); the fixture uses DeepSeek's literal 400 body.
The full go test ./... and the whole GUI suite were not run.
This commit is contained in:
yetone
2026-10-29 17:23:24 +08:00
parent 4534561f6b
commit b64ec9d64f
8 changed files with 440 additions and 6 deletions
+33
View File
@@ -906,6 +906,39 @@ Covered by `TestSearchMCPServesWebSearch`, `TestSearchMCPWithNoSearcher`,
`TestSearchMCPGuarded`, `TestSearchMCPHeldToKeyLimit`,
`TestSearchMCPRoutedAsTheAgentsCall`, `TestSearchQueryMasked` and `search-mcp.test.cjs`.
## A model that turns an image away
Whether a model sees is its provider's list's word (`ImageInput`), else
the served entry's (`blindTo`), and a list that says nothing takes
models.dev's modalities for the model (`catalog.SeesImages`). A relay's
copy of a model can take text only where models.dev says it sees: xyenon
(Discord) picked provider-1/DeepSeek-V4.1-Flash in pi with Image
recognition set, magpie sent it the raw image, DeepSeek answered 400
"unknown variant `image_url`", and since that reads as a shape refusal
(`shapeWords`) the request went on to the fallback, the same model at
provider-2, which sees. The image was never described.
A 400, 415 or 422 whose words say images aren't taken (`imageRefused`:
unknown variant image_url/input_image/image, OpenAI's "only supported by
certain models", OpenRouter's "no endpoints found that support image",
vLLM's "not a multimodal model", 不支持图片 and the like) now marks the
model blind for the server's run (`refuseSight`, `Server.blind`;
`blindTo` checks it first). With a describer (`seer`), the same candidate
is asked again at once with the images described (`seenBody`, or the
group's `seenGroup`; the try's failure is `failSight`), before any
fallback or other member, and later requests are described up front, for
a direct pick and a group alike. The pick and the describer the user set
win over another provider's copy of the model.
With no describer (Image recognition off, or nothing that sees), going on
to a candidate whose copy sees is the only way to answer, so that is kept
on purpose (`TestRefusedImageWithNoDescriberGoesToOneThatSees`).
Covered by `TestPickedModelThatRefusesAnImageIsGivenItDescribed` (direct,
user group and auto group, over Chat, Responses and Messages) and
`TestImageRefused`
([`vision_refused_test.go`](../../internal/gateway/vision_refused_test.go)).
## Image recognition as an MCP server
`VisionMCPPath`, `/mcp/magpie/vision`, serves the model that describes