Skip to content

fix(ui): refuse a collection.* router model as the Custom model ID - #7548

Merged
kovtcharov-amd merged 2 commits into
amd:mainfrom
saruk-vedant:gaia-7525-local-router-model
Nov 13, 2026
Merged

kovtcharov-amd merged 2 commits into
amd:mainfrom
saruk-vedant:gaia-7525-local-router-model

Conversation

@saruk-vedant

Copy link
Copy Markdown
Contributor

Summary

With Local only on, the settings page saved a collection.* router model as the Custom model ID, and the failure only surfaced when the next message was refused. The save-time check now applies the same allowlist the per-turn guard uses, so a router collection is refused at save time.

Why

A router collection can forward requests to a cloud member, so Local only cannot vouch for it, but the old save-time check only refused ids the model list marks recipe == "cloud". A collection recipe passed, leaving Settings showing a model that could never answer beside "Local only: On".

Linked issue

Fixes #7525

Changes

  • refuse_blocked_cloud_model in src/gaia/ui/routers/providers.py now also refuses when Lemonade's catalog does not confirm every listed recipe runs on this PC (recipes_confirm_local(recipes_in_catalog(...))), the rule the per-turn guard already uses.
  • Ids already known to be local without the catalog (a bare id, or one GAIA declares) skip the catalog read, so saving a plain local model still works without asking the model server.
  • New tests cover collection.x, COLLECTION.X, and user.collection.x; the shared custom-model fixture now carries the recipe a real catalog entry has.

Test plan

  • python -m pytest tests/unit/chat/ui/test_providers_router.py -k "local_only or router_collection": 22 passed. The 3 new router-collection cases fail on main and pass here.
  • python -m pytest tests/unit/chat/ui/test_server.py tests/unit/chat/ui/test_providers_router.py tests/unit/test_local_only.py tests/unit/test_local_only_paths.py tests/unit/test_cloud_model_unavailable_message.py: 539 passed, 1 skipped.
  • python -m black and isort --check-only on both changed files: clean.
  • Live check in the Agent UI: save collection.x as the Custom model ID with Local only on and confirm it is refused.

Evidence

  • Agent UI: no live screenshot yet; the new unit tests exercise the same endpoints (POST /api/providers/select, and the settings save path through refuse_blocked_cloud_model).
  • CLI / MCP tools / HTTP API: N/A, no surface changed.

Checklist

  • I have linked a GitHub issue above (Fixes #7525).
  • I have described why this change is being made, not just what changed.
  • I have run linting and tests locally (python -m black, isort, pytest on the affected files).
  • I have attached real-world evidence matched to the surface I changed (see Evidence above).
  • No documentation update needed: no user-visible behavior changed except the refusal itself.

@github-actions github-actions Bot added the tests Test changes label Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Request changes

The fix is right. With Local only on, the save-time check now uses the same allowlist as the per-turn guard, so a router collection that could forward to the cloud can no longer be saved as the Custom model ID. One thing needs fixing before merge: the new refusal doesn't say why the model was blocked.

  • Every refusal reads the same, "Local only is on." That covers a router collection, an unknown recipe, and a dotted name Lemonade doesn't list at all. Before this PR the last case saved without complaint. A user who mistypes a model name is now pointed at the privacy setting, when the real problem is the name. The per-turn guard already works out the reason for each case; the save check should show it too.

Real-world evidence

N/A: no evidence bundle was produced for this run. The PR leaves its own live Agent UI check unchecked. The verdict rests on reading the code. The new behaviour is covered only by unit tests against the /api/providers/select route.

🔍 Technical details

🟡 The new 409 drops the reason the per-turn guard gives (src/gaia/ui/routers/providers.py:1618)

assert_model_permitted (src/gaia/llm/local_only.py:429-448) builds a why for each case: not listed, ambiguous match, no recipe, cloud, collection.*, unknown recipe. The save path uses the same recipes_confirm_local rule but only prints a generic message. The empty-recipes case is new behaviour from this PR, because _listed_as_cloud used to let an unlisted dotted id through. Either pull the why builder out of assert_model_permitted into a small helper both paths call, or at least split out the unlisted case:

    if recipes is not None and not recipes_confirm_local(recipes):
        reason = (
            "Lemonade's model list doesn't include it"
            if not recipes
            else "it can send requests to a cloud model"
        )
        raise HTTPException(
            status_code=409,
            detail=(
                f"Can't switch to {model_id}: Local only is on and {reason}. "
                f"{AGENT_UI_LOCAL_ONLY_HINT}"
            ),
        )

Please add a test for a dotted id that isn't in the catalog, so the changed behaviour for unlisted names is pinned.

🟢 Two catalog reads per ambiguous save (providers.py:1592-1597)

_is_cloud_model → _listed_as_cloud fetches models?show_all=true, then _catalog_recipes fetches it again. A single read would serve both checks: a cloud recipe already fails recipes_confirm_local. Not a correctness problem.

🟢 The Settings save path isn't tested with a collection

PUT /api/settings with custom_model (src/gaia/ui/routers/system.py:1183) goes through the same function, but the new parametrized test only drives /api/providers/select. One case in tests/unit/chat/ui/test_server.py beside test_a_cloud_model_only_the_server_lists_is_refused_under_local_only would cover the surface issue #7525 is actually about.

Checked: _known_local_without_catalog mirrors the pre-filter in _is_cloud_model, so bare and declared ids still save without asking the server (test_a_local_model_is_saved_under_local_only_without_asking_the_server covers this). A ProviderError from _catalog_recipes is inside the existing try, so a server that is down still gets the 503 path. No docs describe the old save-time rule.

Strengths

  • Reuses recipes_in_catalog / recipes_confirm_local instead of adding a third Local-only rule, so the save check and the turn check can't drift.
  • The parametrized test covers the case-insensitive and user.-prefixed spellings, the usual way these checks get bypassed.
  • The fixture fix (adding recipe to _CUSTOM_LISTED) makes the mock look like a real catalog entry, so the test checks behaviour that can actually happen.

@kovtcharov-amd kovtcharov-amd added bug Something isn't working agent-ui Agent UI changes llm LLM backend changes labels Nov 12, 2026
@github-actions github-actions Bot added the performance Performance-critical changes label Nov 13, 2026
@kovtcharov-amd kovtcharov-amd added the p2 low priority label Nov 13, 2026
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 13, 2026
Merged via the queue into amd:main with commit daef989 Nov 13, 2026
56 of 57 checks passed
@kovtcharov-amd kovtcharov-amd mentioned this pull request Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-ui Agent UI changes bug Something isn't working llm LLM backend changes p2 low priority performance Performance-critical changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ui): Local only still saves a collection.* router model as the Custom model ID

2 participants