fix(models): one list on the provider page; image, music, video and robotics models are not offered as coworker models (OPE-252)

Owner's reading of the Gemini page: no split between reviewed rows and the
rest (one list, reviewed first, the provider's newest after, new ones above
under their own heading), and a question about Nano Banana Pro, Lyria and
Robotics-ER showing up with a tick box.

Google serves its image, music, video and robotics models through the same
generateContent method as its language models, so the method alone did not
tell them apart. The chat-only filter now reads ids and display names for
those families too. They are not coworker models: a coworker's turns need a
model that holds a conversation and calls tools, and a picker row for a
generator would only fail in a session. Generation as a capability belongs
to a tool, not to the model picker.

A listed id that is not a chat model is still "on the key": a user who types
it by hand is not told the key lacks it (the listing keeps every id for that
check and shows only the chat ones).
This commit is contained in:
Devika Verma
2026-11-17 18:38:30 +05:30
parent 3defd442df
commit dcdf80978b
7 changed files with 93 additions and 44 deletions
+44 -15
View File
@@ -23,7 +23,7 @@ import json
import os
import threading
import time
from dataclasses import asdict, dataclass
from dataclasses import asdict, dataclass, field
from pathlib import Path
from typing import Any, Optional
@@ -40,9 +40,14 @@ NO_LISTING: dict[str, str] = {
"ark-agent-plan-cn": "BytePlus Ark publishes no model list; the curated rows are shown.",
}
# Ids that are not chat models whatever the provider says (embeddings, speech, images,
# moderation, rerankers); a picker row for them would only fail in a session.
_NOT_CHAT = ("embed", "tts", "whisper", "dall-e", "moderation", "rerank", "transcri", "image-", "-image", "audio", "sora", "realtime")
# Ids and names that are not chat models whatever the provider says: embeddings, speech,
# image / music / video generators, robotics, moderation, rerankers. Google serves several
# of these through the same generateContent method as its language models (Nano Banana
# draws, Lyria composes, Veo films, Robotics-ER drives), so the method alone does not tell.
_NOT_CHAT = (
"embed", "tts", "whisper", "dall-e", "moderation", "rerank", "transcri", "image-", "-image", "imagen",
"audio", "sora", "realtime", "banana", "lyria", "veo", "music", "video", "robotics", "-live", "aqa",
)
@dataclass(frozen=True)
@@ -59,9 +64,12 @@ class LiveModel:
class Listing:
provider: str
ok: bool
models: list[LiveModel]
models: list[LiveModel] # the chat models, what the page lists
error: Optional[str] = None
status: Optional[int] = None
# Every id the provider listed, chat or not: an image or music model is not offered
# as a coworker's model, but a user who types its id is not told the key lacks it.
all_ids: list[str] = field(default_factory=list)
# -- the request ---------------------------------------------------------------------------
@@ -165,10 +173,11 @@ def _row(name: str, item: dict[str, Any]) -> Optional[LiveModel]:
kind = item.get("type")
if isinstance(kind, str) and kind not in ("chat", "model", "language", "llm"):
return None # Together: image / embedding / audio rows
lowered = model_id.lower()
if any(mark in lowered for mark in _NOT_CHAT):
return None
display = item.get("display_name") or item.get("displayName")
lowered = model_id.lower()
shown = display.lower() if isinstance(display, str) else ""
if any(mark in lowered or mark in shown for mark in _NOT_CHAT):
return None
if not isinstance(display, str) or not display.strip():
display = item.get("name") if isinstance(item.get("name"), str) and item.get("name") != raw_id else None
tools: Optional[bool] = None
@@ -195,18 +204,38 @@ def _row(name: str, item: dict[str, Any]) -> Optional[LiveModel]:
)
def parse_listing(name: str, payload: Any) -> list[LiveModel]:
"""The chat models in a provider's answer, newest first. Tolerant of the three shapes
in use: {"data": [...]} (OpenAI and most), {"models": [...]} (Gemini, Cohere), a bare
list (Together)."""
def _items(payload: Any) -> list[Any]:
if isinstance(payload, dict):
items = payload.get("data")
if not isinstance(items, list):
items = payload.get("models")
else:
items = payload
if not isinstance(items, list):
return []
return items if isinstance(items, list) else []
def listed_ids(name: str, payload: Any) -> list[str]:
"""Every model id in the answer, chat or not, in the provider's order."""
out: list[str] = []
for item in _items(payload):
if not isinstance(item, dict):
continue
raw_id = item.get("id") if isinstance(item.get("id"), str) else item.get("name")
if not isinstance(raw_id, str) or not raw_id.strip():
continue
model_id = raw_id.strip()
if name == "gemini" and model_id.startswith("models/"):
model_id = model_id[len("models/"):]
if model_id not in out:
out.append(model_id)
return out
def parse_listing(name: str, payload: Any) -> list[LiveModel]:
"""The chat models in a provider's answer, newest first. Tolerant of the three shapes
in use: {"data": [...]} (OpenAI and most), {"models": [...]} (Gemini, Cohere), a bare
list (Together)."""
items = _items(payload)
rows: dict[str, LiveModel] = {}
for item in items:
if not isinstance(item, dict):
@@ -242,7 +271,7 @@ def fetch(name: str, profile: dict[str, Any], descriptor: Any, *, timeout: float
payload = resp.json()
except ValueError:
return Listing(name, False, [], error="The provider's model list was not JSON.", status=resp.status_code)
return Listing(name, True, parse_listing(name, payload), status=resp.status_code)
return Listing(name, True, parse_listing(name, payload), status=resp.status_code, all_ids=listed_ids(name, payload))
# -- facts the rest of the app can read without the manager --------------------------------
+4 -1
View File
@@ -5581,6 +5581,7 @@ class SessionManager:
entry = {
"fetched_at": now,
"ids": ids,
"all_ids": listing.all_ids or ids,
"seen": seen,
"new": [i for i in ids if i not in seen_set],
"models": {m.id: live_models.as_dict(m) for m in listing.models},
@@ -5690,7 +5691,9 @@ class SessionManager:
if not ids:
return None
_prov, bare = split_id(model)
if self._listed(bare, ids) is not None:
# Typed by hand, any id the provider lists is on the key, chat model or not (an
# image or music model is not offered in the list, but it is not refused either).
if self._listed(bare, [str(i) for i in entry.get("all_ids") or ids]) is not None:
return None
close = difflib.get_close_matches(bare, ids, n=3, cutoff=0.5)
return {
@@ -65,12 +65,11 @@ describe("ProviderModels with a live listing", () => {
expect(getProviderCatalog).toHaveBeenCalledWith("openrouter", false);
expect(screen.getByTestId("catalog-status").textContent).toContain("4 models on this key");
expect(screen.getByTestId("catalog-new").textContent).toContain("Brand New");
expect(screen.getByTestId("catalog-recommended").textContent).toContain("GLM-5.2");
expect(screen.getByTestId("catalog-recommended").textContent).toContain("Kimi K3");
const all = screen.getByTestId("catalog-all").textContent || "";
expect(all).toContain("GPT-6 Astra");
expect(all).toContain("Mystery");
expect(all).not.toContain("Brand New");
const list = screen.getByTestId("catalog-list");
const names = Array.from(list.querySelectorAll(".mlist-name")).map((n) => n.textContent);
expect(names).toEqual(["GLM-5.2 · via OpenRouter", "OpenAI: GPT-6 Astra", "Mystery", "Kimi K3 · via OpenRouter"]); // the backend's order, one list
expect(list.textContent).not.toContain("Brand New");
expect(screen.queryByText("Reviewed by OpenWorker")).toBeNull();
// the facts and where they came from
expect(screen.getByTestId("catalog-tags-lab/brand-new").textContent).toContain("new");
expect(screen.getByTestId("catalog-tags-openai/gpt-6-astra").textContent).toContain("922K context");
@@ -80,8 +79,6 @@ describe("ProviderModels with a live listing", () => {
expect(screen.getByTestId("catalog-tags-openai/gpt-6-astra").textContent).not.toContain("PDF");
expect(screen.getByTestId("catalog-tags-z-ai/glm-5.2").textContent).toContain("images + PDF");
expect(screen.getByTestId("catalog-tags-lab/mystery").textContent).toContain("unverified");
expect(screen.getByTestId("catalog-recommended").textContent).toContain("Reviewed by OpenWorker");
expect(screen.getByTestId("catalog-all").textContent).toContain("Also on your key");
expect(screen.getByTestId("catalog-tags-moonshotai/kimi-k3").textContent).toContain("not on this key");
expect(screen.getByTestId("catalog-not-on-key").textContent).toContain("1 ticked models are not on this key");
// the default row is ticked and locked
@@ -128,7 +125,7 @@ describe("ProviderModels with a live listing", () => {
fireEvent.click(screen.getByTestId("catalog-refresh"));
await waitFor(() => expect(getProviderCatalog).toHaveBeenLastCalledWith("openrouter", true));
await waitFor(() => expect(screen.getByTestId("catalog-error").textContent).toContain("HTTP 503"));
expect(screen.getByTestId("catalog-recommended").textContent).toContain("GLM-5.2");
expect(screen.getByTestId("catalog-list").textContent).toContain("GLM-5.2");
});
it("search narrows every section and long lists fold", async () => {
@@ -136,12 +133,12 @@ describe("ProviderModels with a live listing", () => {
vi.mocked(getProviderCatalog).mockResolvedValue({ ...LIVE, rows: [...LIVE.rows, ...many] });
renderPanel();
await flush();
expect(screen.getByTestId("catalog-all").querySelectorAll(".mlist-row").length).toBe(12);
expect(screen.getByTestId("catalog-show-all").textContent).toContain("Show all 22");
expect(screen.getByTestId("catalog-list").querySelectorAll(".mlist-row").length).toBe(12);
expect(screen.getByTestId("catalog-show-all").textContent).toContain("Show all 24");
fireEvent.click(screen.getByTestId("catalog-show-all"));
expect(screen.getByTestId("catalog-all").querySelectorAll(".mlist-row").length).toBe(22);
expect(screen.getByTestId("catalog-list").querySelectorAll(".mlist-row").length).toBe(24);
fireEvent.change(screen.getByTestId("catalog-search"), { target: { value: "astra" } });
expect(screen.getByTestId("catalog-all").querySelectorAll(".mlist-row").length).toBe(1);
expect(screen.getByTestId("catalog-list").querySelectorAll(".mlist-row").length).toBe(1);
expect(screen.queryByTestId("catalog-new")).toBeNull();
});
});
@@ -89,12 +89,14 @@ export function ProviderModels({
const rows = catalog?.rows || [];
const q = query.trim().toLowerCase();
// One list (owner's call 2026-11-09: no reviewed-versus-rest split): the rows the
// backend ordered, reviewed first, then the provider's own newest first. Models the
// provider added since the last check sit above it under their own heading.
const sections = useMemo(() => {
const match = (r: ProviderCatalogRow) => !q || r.id.toLowerCase().includes(q) || r.label.toLowerCase().includes(q);
const fresh = rows.filter((r) => r.new && match(r));
const recommended = rows.filter((r) => !r.new && (r.recommended || r.verified === "catalog") && match(r));
const rest = rows.filter((r) => !r.new && !(r.recommended || r.verified === "catalog") && match(r));
return { fresh, recommended, rest };
const rest = rows.filter((r) => !r.new && match(r));
return { fresh, rest };
}, [rows, q]);
const setRow = (model: string, patch: Partial<ProviderCatalogRow>) =>
@@ -230,12 +232,12 @@ export function ProviderModels({
);
};
const section = (title: string, items: ProviderCatalogRow[], testid: string, foldable = false) => {
const section = (title: string | null, items: ProviderCatalogRow[], testid: string, foldable = false) => {
if (!items.length) return null;
const shown = foldable && !showAll && !q ? items.slice(0, FOLD) : items;
return (
<div className="mt-3" data-testid={testid}>
<div className="text-meta font-semibold text-muted uppercase tracking-wide mb-1">{title}</div>
{title && <div className="text-meta font-semibold text-muted uppercase tracking-wide mb-1">{title}</div>}
<div className="mlist">{shown.map(rowEl)}</div>
{foldable && !q && items.length > FOLD && (
<button className="text-meta text-muted underline underline-offset-2 hover:text-ink mt-1" onClick={() => setShowAll((v) => !v)} data-testid="catalog-show-all">
@@ -268,8 +270,7 @@ export function ProviderModels({
<p className="text-meta text-muted mt-1" data-testid="catalog-not-on-key">{t("manage.catalog_not_on_key_help", { count: catalog.not_on_key.length })}</p>
)}
{section(t("manage.catalog_new_since"), sections.fresh, "catalog-new")}
{section(t("manage.catalog_reviewed"), sections.recommended, "catalog-recommended")}
{section(t("manage.catalog_also_on_key"), sections.rest, "catalog-all", true)}
{section(null, sections.rest, "catalog-list", true)}
{rows.some((r) => r.verified === "unverified" && r.in_picker) && (
<p className="text-meta text-muted mt-2" data-testid="catalog-unverified-help">{t("manage.catalog_unverified_help")}</p>
)}
-2
View File
@@ -1467,8 +1467,6 @@
"catalog_tag_images_pdf": "images + PDF",
"catalog_tag_context_title": "Context window: {{tokens}} tokens. From our reviewed list or the provider's own list, never a guess.",
"catalog_tag_context": "{{size}} context",
"catalog_also_on_key": "Also on your key",
"catalog_reviewed": "Reviewed by OpenWorker",
"catalog_tag_unverified": "unverified",
"catalog_tag_not_on_key": "not on this key",
"catalog_unverified_help": "Unverified: nobody has checked this model's facts yet. It runs with safe defaults, and the app lowers its window if the provider refuses a long prompt. Set the window under the model's settings if you know it.",
-2
View File
@@ -1437,8 +1437,6 @@
"catalog_tag_images_pdf": "图片 + PDF",
"catalog_tag_context_title": "上下文窗口:{{tokens}} 个 token。来自我们的审核列表或提供方自己的列表,从不猜测。",
"catalog_tag_context": "{{size}} 上下文",
"catalog_also_on_key": "此密钥还可用",
"catalog_reviewed": "OpenWorker 已审核",
"catalog_tag_unverified": "未核实",
"catalog_tag_not_on_key": "不在此密钥上",
"catalog_unverified_help": "未核实:尚无人核对此模型的参数。它以保守默认值运行;若提供方拒绝过长的提示,应用会自动调低其上下文窗口。如果你知道窗口大小,可在模型设置中设定。",
+27 -4
View File
@@ -114,14 +114,27 @@ def test_anthropic_shape_uses_display_names_and_iso_dates():
]
def test_gemini_shape_strips_the_prefix_and_keeps_generate_content_models_only():
def test_gemini_shape_strips_the_prefix_and_keeps_language_models_only():
"""Google serves image, music, video and robotics models through generateContent too
(seen 2026-11-09 with a real key: Nano Banana Pro, Lyria 3.5, Veo, Robotics-ER); the
method alone does not tell, the names and ids do."""
gc = ["generateContent", "countTokens"]
rows = live_models.parse_listing("gemini", {"models": [
{"name": "models/gemini-3-pro", "displayName": "Gemini 3 Pro", "inputTokenLimit": 2_097_152, "outputTokenLimit": 65_536,
"supportedGenerationMethods": ["generateContent", "countTokens"]},
{"name": "models/gemini-3-pro", "displayName": "Gemini 3 Pro", "inputTokenLimit": 2_097_152, "outputTokenLimit": 65_536, "supportedGenerationMethods": gc},
{"name": "models/gemma-4-31b-it", "displayName": "Gemma 4 31B IT", "inputTokenLimit": 262_144, "supportedGenerationMethods": gc},
{"name": "models/text-embedding-005", "displayName": "Embedding", "supportedGenerationMethods": ["embedContent"]},
{"name": "models/imagen-4", "displayName": "Imagen", "supportedGenerationMethods": ["predict"]},
{"name": "models/gemini-3-pro-image-preview", "displayName": "Nano Banana Pro", "inputTokenLimit": 131_072, "supportedGenerationMethods": gc},
{"name": "models/lyria-3-5", "displayName": "Lyria 3.5", "inputTokenLimit": 1_048_576, "supportedGenerationMethods": gc},
{"name": "models/veo-4", "displayName": "Veo 4", "supportedGenerationMethods": gc},
{"name": "models/gemini-robotics-er-2-preview", "displayName": "Gemini Robotics-ER 2 Preview", "inputTokenLimit": 131_072, "supportedGenerationMethods": gc},
{"name": "models/gemini-3-flash-live", "displayName": "Gemini 3 Flash Live", "supportedGenerationMethods": ["bidiGenerateContent"]},
{"name": "models/gemini-3-flash-tts", "displayName": "Gemini 3 Flash TTS", "supportedGenerationMethods": gc},
]})
assert [(r.id, r.name, r.context) for r in rows] == [("gemini-3-pro", "Gemini 3 Pro", 2_097_152)]
assert sorted((r.id, r.name, r.context) for r in rows) == [
("gemini-3-pro", "Gemini 3 Pro", 2_097_152),
("gemma-4-31b-it", "Gemma 4 31B IT", 262_144),
]
def test_openrouter_shape_carries_context_tools_and_images():
@@ -377,6 +390,16 @@ def test_add_model_accepts_an_id_the_key_lists_whatever_its_case(manager, fake_p
assert "openrouter:openai/gpt-6-astra" in manager.get_settings()["models"]
def test_a_listed_non_chat_model_is_not_offered_but_not_refused_either(manager, fake_provider):
"""Owner's question 2026-11-09: image and music models are not coworker models, so
the list leaves them out; a user who types one by hand is not told the key lacks it."""
_key(manager)
out = manager.provider_catalog("openrouter")
assert "openai/text-embedding-4" not in {r["id"] for r in out["rows"]}
assert manager.add_model("openrouter:openai/text-embedding-4")["ok"] is True
assert manager.add_model("openrouter:openai/text-embedding-9")["ok"] is False
def test_add_model_is_not_gated_without_a_listing(manager, fake_provider):
_key(manager, "anthropic") # configured, list never asked
assert manager.add_model("anthropic:claude-opus-5-5")["ok"] is True