zyh6036 on X: several subscriptions that all serve the Responses API were asked on Chat once they were put in a routing group. Pi, OmO, omp, StepCode, droid, dsh, Hermes, Grok CLI and the live agents ask each model on the one API catalog.Model.APIs names, and a group had Responses only when every member's Native was Responses (allResponses, #1594). A relay that serves Chat and Responses, best on Chat (no Base URL API given, not OpenAI's own host), counts as Chat there, so one such member put the whole group on Chat, and the gateway then translated Chat to Responses for the ChatGPT, Copilot GPT or Responses-relay members. Found groups (auto-<slug>) hit this without the user doing anything: a new relay that also lists gpt-5.5 moved auto/gpt-5.5 from openai-responses to Chat (pi_api_test shows it). provider.GroupAPI now gives Responses when one member is best on Responses and every other takes a Responses request as it is (Responses among the APIs it relays), or translates every request anyway (a Claude Code subscription). So no member is translated that Chat would have relayed, and the ones best on Responses are relayed, not translated from Chat. The gateway already relays a /v1/responses request to each member that serves it (usable), so nothing changes there. Mixed groups: a member that Responses doesn't reach (a Chat-only key, a Messages-only Claude) keeps the group on Chat, where that member is relayed; picking Responses there would translate it on every turn. A Messages-only group stays on Chat as before (#1594's reason: a Claude member's thinking is known by its own model id, not the group's). An agent plugin's connect is told a group's native_endpoints now (provider.GroupEndpoints: the APIs every member relays), where it had none. /v1/models still leaves them out for a group: TestRemoteMagpieNativeAPI holds that a remote magpie sends a group's request on in the client's API for the other side to pick per member. No setting added: the group's API follows from its members. Run (mote, through mote-run): - go test ./... -timeout 45m at 65780f04f on49c9491b7, under the shared lock: every package ok except three reds, all filed and not in this change's path: internal/gateway TestBurstTellsNoSpeed/ responses_from_chat_burst (passes 3 of 3 alone; #2719, commented), internal/gui TestMainWindowCorners/macOS_26_SDK (#3949), internal/provider TestRenewLoginsKeepsClaudeReading (red alone too; #5481, on main). - After rebasing onfcc0daa23: go test ./internal/agent ./internal/catalog, ./internal/provider -run 'TestGroupAPI|TestNative|Group', ./internal/gateway -run 'Group|RemoteMagpie'; go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...; gofmt -l empty. - Broken by hand: GroupAPI put back to "every member best on Responses": TestGroupAPI red (one best there plus one serving it too; the same second), TestPiModelsAskedOnTheirNativeAPI red (group/subs, and auto/gpt-5.5 once a Chat-first relay serves gpt-5.5). - New: TestGroupAPI (provider), TestGroupOfResponsesServersRelaysOnResponses (gateway: the Chat-first member is asked on /responses, relayed). Not tried: the reporter's own providers (not known: which subscriptions, which agent); a real Pi or dsh run against a real mixed-API group; the GUI (unchanged).
64 lines
2.6 KiB
Go
64 lines
2.6 KiB
Go
package provider
|
|
|
|
import (
|
|
"path/filepath"
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/catalog"
|
|
)
|
|
|
|
// A routing group is asked on Responses when one member is best there and
|
|
// every other takes a Responses request as it is too, or translates every
|
|
// request anyway (zyh6036 on X: subscriptions that all serve Responses
|
|
// were asked on Chat in a group, as only a group all of whose members were
|
|
// best on Responses went there, #1594). A member Responses doesn't reach
|
|
// keeps the group on Chat, where it is relayed.
|
|
func TestGroupAPI(t *testing.T) {
|
|
home := t.TempDir()
|
|
t.Setenv("HOME", home)
|
|
t.Setenv("USERPROFILE", home)
|
|
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
|
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
|
catalog.Reset()
|
|
t.Cleanup(catalog.Reset)
|
|
resp := Provider{ID: "resp", Responses: "http://127.0.0.1:1/v1"} // best on Responses
|
|
both := Provider{ID: "both", Chat: "http://127.0.0.1:1/v1", Responses: "http://127.0.0.1:1/v1"} // Chat first, Responses too
|
|
chat := Provider{ID: "chat", Chat: "http://127.0.0.1:1/v1"}
|
|
anth := Provider{ID: "anth", Anthropic: "http://127.0.0.1:1"}
|
|
claude := Provider{ID: "claude", Anthropic: "http://127.0.0.1:1", Account: &Account{Agent: "claude"}} // translated anyway
|
|
of := func(ps ...Provider) []Member {
|
|
var ms []Member
|
|
for _, p := range ps {
|
|
ms = append(ms, Member{Provider: p, Model: "gpt-5.5"})
|
|
}
|
|
return ms
|
|
}
|
|
if n := both.Native("gpt-5.5"); n != Chat {
|
|
t.Fatalf("the Chat-first relay's GPT is best on %q; the cases below assume Chat", n)
|
|
}
|
|
for _, c := range []struct {
|
|
name string
|
|
ms []Member
|
|
api Protocol
|
|
endpoints []string
|
|
}{
|
|
{"all best on Responses", of(resp, resp), Responses, []string{"/v1/responses"}},
|
|
{"one best there, one serving it too", of(resp, both), Responses, []string{"/v1/responses"}},
|
|
{"the one best there second", of(both, resp), Responses, []string{"/v1/responses"}},
|
|
{"with a subscription translated anyway", of(resp, claude), Responses, nil},
|
|
{"none best on Responses", of(both, both), "", []string{"/v1/chat/completions", "/v1/responses"}},
|
|
{"a Chat-only member", of(resp, chat), "", nil},
|
|
{"a Messages-only member", of(resp, anth), "", nil},
|
|
{"Messages-only", of(anth, anth), "", []string{"/v1/messages"}},
|
|
{"no members", nil, "", nil},
|
|
} {
|
|
if got := GroupAPI(c.ms); got != c.api {
|
|
t.Errorf("%s: API %q, want %q", c.name, got, c.api)
|
|
}
|
|
if got := GroupEndpoints(c.ms); !slices.Equal(got, c.endpoints) {
|
|
t.Errorf("%s: endpoints %v, want %v", c.name, got, c.endpoints)
|
|
}
|
|
}
|
|
}
|