Files
CatoandClaude ae260fc51a feat(vision): a picture goes only to a model that can read one (#68)
`complete()` has forwarded `image_url` parts since the first release. What it
never did was CHOOSE a link for them — and `freeChain()` is ordered for text,
so a screenshot meets four Groq links that cannot read it before reaching one
that can. A blind model handed a picture does not fail usefully: it answers the
words around the image, fluently, about nothing.

Three products paid for that absence separately, in three repositories:

  heidi     had the users and REFUSED them — /api/chat returns 400 "Reading a
            picture needs your own model", and byok.ts states as fact that "the
            free chain has no model that can read a picture". Never true of
            free models; true of a chain with no vision routing.
  loki      built a SECOND chain beside this one (config/vision-models.ts) and
            it drifted immediately — never learned about Google, still carries
            a dead Groq seat.
  orangecat built the decision rule and had nobody to call it with. Its own
            capability-gate reason string reads 'no caller sends images'.

The rule, the verified model list and the users existed; none could reach the
other two.

What lands:

- `Provider.visionModels` — which ids accept an image, populated from evidence
  with the provenance stated beside each entry. Groq's empty list is a claim
  (live-probed 2026-08-13: no vision model on this account); OpenRouter's
  `google/gemma-4-26b-a4b-it:free` is the strong kind (probed live, answered
  "Red" correctly); Google's three are declared-not-probed and say so.
- `src/vision.ts` — three verdicts, never two. A model in `models` but not in
  `visionModels` is "no"; a model in NEITHER (env override, private
  deployment, an id a user brought) is "unknown", and unknown is TRIED. Reading
  silence as a denial is the inversion OrangeCat's ADR-0008 named, where the
  stronger the model a user brings, the less the agent can do.
- `complete()` and `completeStream()` route on it through one shared helper, so
  the two paths cannot disagree about which model can see — the same reason
  they already share `walkChain`.
- `NoVisionLinkError`, thrown BEFORE any request when the whole chain is blind,
  naming what it skipped. "No model here can see" and "every vendor failed"
  need different answers and are indistinguishable once both arrive as
  ChainExhaustedError; the first is knowable without spending a token.
- `scripts/probe-vision.mjs` (`pnpm run check:vision`) — a claim in a list is
  worth what the last check was. Sends a real image, asks one word, and treats
  HTTP 200 with EMPTY content as a failure: that is the shape loki found in
  nemotron-nano-12b-v2-vl, and it reads as a successful analysis of a picture
  nobody looked at.

`walkChain`'s chain resolution is extracted as `walkLinks` so the filter and
the walk resolve the same defaults once. Named `walkLinks`, not `resolveChain`
— that name is taken by resolve.ts, which answers a different question.

Inert for text: a plain turn returns the caller's own options object untouched
and costs one typeof per message. Pinned by a test, because breaking that would
break every text caller in the fleet.

301 tests pass, both directions pinned: a declared-blind model must never be
sent a picture, and an unclassified one must never be refused one.


Claude-Session: https://claude.ai/code/session_014RpRyAd15YvFmQ1c1p1Rsk

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-21 05:39:49 -07:00
..