freefcw on X: Codex, started by Mirasim, asked for gpt-6-astra by its bare
name. Its own ChatGPT subscription serves it, but magpie sent it to Devin
through the group it found (auto-gpt-6-astra, soonest renewal first).
With found groups off it still went to another vendor: Resolve takes the
first provider in the Providers order, AutoStandIn and agent.Reseat did
the same.
Now:
- A bare model id the asking agent's own subscription in magpie serves (a
provider whose Account.Agent is the agent: Codex's ChatGPT accounts,
Claude's for Claude Code, Copilot's) goes there, found groups on or off
(gateway ownFirst, provider.OwnRoute). count_tokens counts it there too.
- Kept as they were: a group the user made or changed by that name; a found
group magpie set one of the agent's fields to (agent.SetToGroup over the
applied record, #750's bare spelling included, wired as
gateway.SetToGroup); a gateway key held to some models; ids with a
provider in them and group refs; clients magpie doesn't know as an agent.
- Found groups off: a bare id several providers serve, none of them the
agent's own, is refused for an agent that has a subscription of its own
in magpie, with a 400 naming the provider/model ids and
"magpie group auto on" (provider.OffSpread). Off, magpie picks no vendor.
- AutoStandInFor and Reseat's sameModel prefer the agent's own
subscription for a found group that is gone.
Docs: gateway-routing.md's Model resolution row and the bare-ids section.
Run (mote, at this tree on c7ebb6f8d):
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: ok.
- go test -tags nogui -count=1 -timeout 45m ./internal/provider
./internal/agent ./internal/cli ./internal/gateway: all ok.
Broken by hand, each red:
- ownFirst off in serve (and AutoStandIn back):
TestBareNameGoesToTheAgentsOwnSubscription went to the relay with groups
on, and again with groups off alone (the reporter's two cases).
- OffSpread check off: TestBareNameOnSeveralVendorsRefusedWhileGroupsOff
answered 200 from the relay.
- SetToGroup check off: TestBareNameOfAGroupSetOnTheAgentStaysTheGroups.
- The user's-group and own-entry checks off: TestOwnRoute, TestOffSpread.
Not run at this head: the full ./... suite (mote's suite.lock had five
suites queued); it runs under the lock after the push, any red filed.
Not tried: a real Codex with a real Devin plugin account; Reseat's own
preference has no test of its own (needs a fetched Codex account in the
agent package's sandbox).
Reported-by: freefcw (X)
80 lines
3.3 KiB
Go
80 lines
3.3 KiB
Go
package provider
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
)
|
|
|
|
// ownEntries: Codex's ChatGPT account, Devin's plugin and a relay all
|
|
// serve gpt-6-astra (freefcw on X), the relay first in the order; only the
|
|
// relay and Devin serve glm-6.
|
|
func ownEntries() []Entry {
|
|
codex := Provider{ID: "codex", Account: &Account{Agent: "codex", User: "a@example.com"}}
|
|
devin := Provider{ID: "devin-plugin", Account: &Account{Agent: "plugin"}}
|
|
relay := Provider{ID: "relay"}
|
|
e := func(p Provider, m string) Entry { return Entry{ID: p.ID + "/" + m, Model: m, Provider: p} }
|
|
return []Entry{
|
|
e(relay, "gpt-6-astra"), e(relay, "glm-6"),
|
|
e(devin, "gpt-6-astra"), e(devin, "glm-6"),
|
|
e(codex, "gpt-6-astra"),
|
|
}
|
|
}
|
|
|
|
// A bare name the asking agent's own subscription serves goes there,
|
|
// whether found groups are on (a group of it found) or off (none), and
|
|
// says the found group it went past; a group the user made by that name,
|
|
// a provider's id, a group's ref and another agent's request don't.
|
|
func TestOwnRoute(t *testing.T) {
|
|
entries := ownEntries()
|
|
on := autoGroups(entries, nil)
|
|
for _, c := range []struct {
|
|
name string
|
|
groups []Group
|
|
agent, id string
|
|
to, group string
|
|
}{
|
|
{"on", on, "codex", "gpt-6-astra", "codex/gpt-6-astra", "group/auto-gpt-6-astra"},
|
|
{"off", nil, "codex", "gpt-6-astra", "codex/gpt-6-astra", ""},
|
|
{"1m mark", on, "codex", "gpt-6-astra[1m]", "codex/gpt-6-astra", "group/auto-gpt-6-astra"},
|
|
{"another agent", on, "claude", "gpt-6-astra", "", ""},
|
|
{"no agent", on, "", "gpt-6-astra", "", ""},
|
|
{"a plugin", on, "plugin", "gpt-6-astra", "", ""},
|
|
{"not its own", on, "codex", "glm-6", "", ""},
|
|
{"provider named", on, "codex", "relay/gpt-6-astra", "", ""},
|
|
{"group ref", on, "codex", "group/auto-gpt-6-astra", "", ""},
|
|
{"auto ref", on, "codex", "auto/gpt-6-astra", "", ""},
|
|
{"the user's group", []Group{{ID: "gpt-6-astra", Name: "Mine", Members: []string{"relay/gpt-6-astra"}}}, "codex", "gpt-6-astra", "", ""},
|
|
} {
|
|
to, group, ok := ownRouteIn(entries, c.groups, c.agent, c.id)
|
|
if to != c.to || group != c.group || ok != (c.to != "") {
|
|
t.Errorf("%s: %q %q %v, want %q %q", c.name, to, group, ok, c.to, c.group)
|
|
}
|
|
}
|
|
// spelt otherwise by the vendor (sameModel), still its own
|
|
dotted := []Entry{{ID: "codex/gpt-6.1-sol", Model: "gpt-6.1-sol", Provider: Provider{ID: "codex", Account: &Account{Agent: "codex"}}}}
|
|
if to, _, ok := ownRouteIn(dotted, nil, "codex", "gpt-6-1-sol"); !ok || to != "codex/gpt-6.1-sol" {
|
|
t.Errorf("by its vendor's spelling: %q %v", to, ok)
|
|
}
|
|
}
|
|
|
|
// With found groups off, a bare name several providers serve, none of
|
|
// them the agent's own, names them all; one the agent's own serves, one
|
|
// provider serves, or a group of the user's has, names none.
|
|
func TestOffSpread(t *testing.T) {
|
|
entries := ownEntries()
|
|
if got := offSpreadIn(entries, nil, nil, "codex", "glm-6"); !slices.Equal(got, []string{"relay/glm-6", "devin-plugin/glm-6"}) {
|
|
t.Errorf("glm-6: %v", got)
|
|
}
|
|
if got := offSpreadIn(entries, nil, nil, "codex", "gpt-6-astra"); got != nil {
|
|
t.Errorf("its own serves it: %v", got)
|
|
}
|
|
one := entries[:2]
|
|
if got := offSpreadIn(one, nil, nil, "codex", "glm-6"); got != nil {
|
|
t.Errorf("one provider: %v", got)
|
|
}
|
|
mine := []Group{{ID: "glm-6", Name: "Mine", Members: []string{"relay/glm-6"}}}
|
|
if got := offSpreadIn(entries, mine, nil, "codex", "glm-6"); got != nil {
|
|
t.Errorf("the user's group: %v", got)
|
|
}
|
|
}
|