Files
OmniRoute/tests/unit/autoCombo/builtin-vision-spec.test.ts
Hernan Javier Ardila Sanchez d7d98fe356 fix(guardrails): vision bridge reroute/pool/self-loop fixes (#9946)
- auto/best-vision and auto/pro-vision now resolve to the vision CATEGORY
  (candidate filter by capability) instead of the flat smart variant, so the
  vision-bridge describe/reroute target can actually see images
  (resolveBuiltinAutoSpec in builtinCatalog).
- vision candidate pool excludes registry entries whose catalog OVERSTATES
  vision support (opencode-go/opencode-zen/tokenrouter are forced through the
  vision bridge by isVisionBridgeForcedModel) in both the auto-combo candidate
  filter (suffixComposition) and the vision router (visionBridgeRouter).
- reroute guard: an auto/* target is a virtual combo; a missing 'auto' provider
  row (hasUsableCredentials=false) must never block the reroute.
- claude-wire backends (minimax, zai, ...) reject remote image URLs (MiniMax
  403 2013): ensureBase64ImagesForClaudeWire resolves URLs to base64 before
  rerouting, and the describe self-loop normalizes to base64 for those targets
  (isClaudeWireFormatModel).
- self-loop describe uses a real DB-backed key (resolveSelfLoopApiKey) instead
  of the sk_omniroute sentinel rejected by REQUIRE_API_KEY instances, and
  bypasses the runtime's hooked global fetch via undici (ProxyFetch with a dead
  local proxy would otherwise break every describe); compression is disabled
  on the self-loop sub-request so image payloads are never mangled.

Tests: vision-bridge-auto-reroute (2), vision-bridge-selfloop-key (4),
vision-bridge-claude-wire (6), builtin-vision-spec (4),
vision-filter-excludes-forced (4).

Co-authored-by: herjarsa <herjarsa@users.noreply.github.com>
2026-08-10 03:25:18 -03:00

44 lines
1.7 KiB
TypeScript

/**
* Regression: `auto/best-vision` must resolve to the `vision` CATEGORY (candidate
* filter by vision capability), not to the flat `smart` variant.
*
* Root cause on runtime v3.8.49: AUTO_TEMPLATE_VARIANTS mapped
* `"auto/best-vision": "smart"`, so the virtual combo scored ALL candidates
* (verified: it resolved to text-only `deepseek-v4-flash-free`), making the
* vision-bridge describe/reroute target useless.
*
* Runs under Vitest (the autoCombo suite is Vitest-only in this repo).
*/
import { describe, it, expect } from "vitest";
import { resolveBuiltinAutoSpec } from "../../../open-sse/services/autoCombo/builtinCatalog";
describe("resolveBuiltinAutoSpec — vision category ids", () => {
it("auto/best-vision resolves to category vision (not smart variant)", () => {
expect(resolveBuiltinAutoSpec("auto/best-vision", "best-vision")).toEqual({
category: "vision",
});
});
it("auto/pro-vision resolves to category vision + tier pro", () => {
expect(resolveBuiltinAutoSpec("auto/pro-vision", "pro-vision")).toEqual({
category: "vision",
tier: "pro",
});
});
it("legacy flat variants keep their variant mapping", () => {
expect(resolveBuiltinAutoSpec("auto/best-coding", "best-coding")).toEqual({
variant: "coding",
});
expect(resolveBuiltinAutoSpec("auto/fast", "fast")).toEqual({ variant: "fast" });
expect(resolveBuiltinAutoSpec("auto/chat", "chat")).toEqual({ variant: undefined });
});
it("category:tier suffix still resolves via parseAutoSuffix", () => {
expect(resolveBuiltinAutoSpec("auto/coding:fast", "coding:fast")).toEqual({
category: "coding",
tier: "fast",
});
expect(resolveBuiltinAutoSpec("auto/vision", "vision")).toEqual({ category: "vision" });
});
});