magpie icon indicating copy to clipboard operation
magpie copied to clipboard

Bare model IDs ("only" mode) don't apply to auto-discovered route groups with `unlists: true`

Open Sakugar opened this issue 2 weeks ago • 1 comments

magpie version

v0.1.4479

Where

Gateway only

OS

Windows

Agent, provider and model

Any OpenAI-compatible client → /v1/models → customized auto-discovered groups (e.g. auto-gpt-6-2-astra, auto-deepseek-v4-1-flash)

Steps to reproduce

  1. Settings → Gateway → "Model IDs without provider" = only
  2. Customize an auto-discovered route group (members, rules, classifier) and set its model list to "list only this group" (unlists: true)
  3. GET /v1/models

What happened, and what you expected

Expected: bare IDs like gpt-6.2-astra, since requesting gpt-6.2-astra already routes to the auto group via GroupFor.

Actual: these groups still show as auto/gpt-6.2-astra, while every other model becomes bare.

Cause (from reading the source):

  • Bare IDs are only derived from listed provider models; unlists hides the members, so no bare ID gets generated.
  • A group's own ID only becomes bare for named groups (Named: !g.Auto), so auto groups keep the auto/ prefix.

Workaround: magpie group set <id> listed=yes works, but it also lists members whose names differ (e.g. deepseek-v4.1-flash-max), which bypass the group.

Suggestion: in "only" mode, list an auto-discovered group under its bare model ID when that ID resolves to the group, even with unlists: true.

Sakugar avatar Nov 20 '26 19:11 Sakugar

I have a fix on a fork branch per docs/contributors.md:

  • Branch / Compare: https://github.com/yetone/magpie/compare/main...eisen0419:magpie:fix/7380-bare-auto-group-unlists (b8e06d08)

Root cause

Bare model IDs were previously derived only from listed provider rows, which unlists: true hides, while groupBare in internal/provider/bare.go only recognized user groups whose catalog ID matched group/<id>. Auto-discovered groups (including customized ones where Auto is cleared and ID is auto-<slug>) advertise auto/<model> (Group.Ref), so they were skipped even though GroupFor already routes the bare <model> to the group.

Fix

  • internal/provider/bare.go: added groupBareID so groupBare derives the bare <model> from auto/<model> rows (alongside existing group/<id> handling) and lists it only when bareTarget resolves that bare ID to the same row via groupForIn (matching gateway GroupFor). Under bare IDs on, <model> is listed alongside auto/<model>; under Only, <model> replaces auto/<model> while auto/<model>, group/auto-<slug>, and provider/model keep routing to the group. If unlists: false (member row already lists the bare ID) or another group owns that bare ID, no duplicate is added and the auto group keeps auto/<model>.
  • internal/gateway/bare_group_ids_test.go: added TestBareIDsListUnlistedAutoGroup, TestBareIDsListAutoGroupOfUnlistedProviders, and TestBareIDsSkipAutoGroupWhoseModelAnotherGroupTakes.
  • docs/subsystems/gateway-routing.md: updated the bare model IDs section to match.

Verification

  • gofmt -l clean on touched Go files; go vet ./internal/provider/... ./internal/gateway/... clean.
  • go test -race -count=1 ./internal/provider (ok) and go test -race -count=1 -run 'TestBare|TestGroup|TestAuto' ./internal/provider/ ./internal/gateway/ (ok).
  • Confirmed TestBareIDsListUnlistedAutoGroup and TestBareIDsListAutoGroupOfUnlistedProviders fail against origin/main and pass with this commit; verified Chat Completions, Responses, and Messages routing + mixed-case / colon / OpenRouter-style model names and key restrictions.

eisen0419 avatar Nov 20 '26 23:11 eisen0419