zhenghaowen0967 asked for an agent's fast pick of a ChatGPT model to go as
Codex's Ultrafast without the client asking for it. settings.UltraPicks
holds the agent's fast picks that are set to Ultrafast; each one is in
FastPicks too.
- The gateway marks those candidates `ultra` in fastPick.
- On Chat and Responses, a try sends service_tier "ultrafast".
- From Messages, a try carries withUltra to forwardTranslated, which
sets Request.Ultrafast for the ChatGPT backend.
- In every case, the #1784 check decides the account. One whose list
doesn't offer Ultrafast goes after a mate that does (tierMate). With
no mate left, it is sent priority.
- That check now covers Chat as well as Responses.
- Sibling fix: chat.go dropped a Chat client's own service_tier
"ultrafast" (Fast was false, Ultrafast unset). It now parses as
Responses does.
- provider: SetFastTier (""/priority/ultrafast) behind SetFastPick.
CanUltra and UltraModels say whether one of Codex's accounts lists
Ultrafast on the model. UltraPicks follow a provider rename
(renameModelPrefs) and survive a GUI settings save.
- GUI: an option gets ultraOk/ultra. Where ultraOk is set, the bolt in
the picker steps usual -> Fast -> Ultrafast -> usual, as a camera's
flash button steps its modes. Ultrafast shows two overlapped bolts, in
the row and after the field's model. Tooltips and the status line are
in en, zh, zh-TW, ja and de. POST /api/agent-fast takes `ultra`.
- No `:ultrafast` suffix for routing groups yet.
Tests, each broken by hand and seen red:
- TestUltraPickSentUltrafast covers omp/Responses with no tier asked
(acct-pro:ultrafast), the Pro account out (then acct-plus:priority),
another agent unchanged, opencode/Chat and claude/Messages picks, a
Chat client's own ultrafast, and switching back to Fast or off.
- Red with ultra forced false (4 cases).
- Red without withUltra (claude went priority).
- Red without the chat.go parse (2 cases).
- TestSetFastPick: red without UltraPicks in renameModelPrefs.
- TestSettingsSaveKeepsWhatItDoesNotSend: red without the api.go carry.
- fast-ultra.test.cjs (en zh ja de, window and 440px panel): red (9/9)
without the Ultrafast step.
Run (vet, gofmt, GUI and full suite at base 8b84dc902; the reruns
below at a rebase onto 6b3ee5a03 and then onto 63be47717 origin/main):
- gofmt -l: clean.
- go vet -tags nogui ./... for darwin, linux and windows: clean.
- GUI, chromium + webkit: fast-ultra, fast-pick, group-member-fast,
i18n-keys, model-pick and 14 other agent-model/picker files. 197/197
pass.
- Full suite: set -o pipefail; go test -timeout 45m ./... (sandbox
HOME, macOS, 3 other sessions' suites running at the same time):
every package ok except two.
- internal/gateway: TestMaxRPMGroupPrefersMemberWithRoom hit its fixed
1s bar (1.126s) under load. It passes 5/5 alone (-count=5). Filed
as #2520.
- internal/gui: TestPanelJoinsFullScreenSpaces, red on macOS 26.2 on
main already, filed as #2450.
- Rerun of internal/gateway and internal/library after the rebase onto
6b3ee5a03 (both packages changed upstream), -timeout 60m, load
average ~290: library ok. gateway hit the 60m timeout (the test
running, TestPauseByFolder, was 13s in) and
TestQueueRefusalIsInTheUsageLedger saw b's 1s queue timeout as a
second 429. Filed as #2541. TestQueueRefusalIsInTheUsageLedger,
TestPauseByFolder and TestUltraPickSentUltrafast, -count=5 at this
head: ok.
- At the 63be47717 rebase: gofmt clean; vet darwin/linux/windows clean.
internal/provider ok, internal/settings ok. internal/agent hit the
45m timeout under load ~295 (in TestCursorLocalEffort, at 0s), so
this is not a green for that package. Its -run
"Fast|Option|Models|Picker|Cursor|Codex" subset, run through the
shared 3-slot queue, was ok in 794s. The whole package is left to
CI's Test run.
Not tried: a real Pro account's Ultrafast. The fake ChatGPT backend's
model lists offer it on one account only.
68 lines
2.2 KiB
Go
68 lines
2.2 KiB
Go
package provider
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// A model is switched fast for an agent only when magpie can ask its vendor
|
|
// for a fast mode, never a routing group (its members say it), and is kept
|
|
// by agent through a rename of its provider (#954).
|
|
func TestSetFastPick(t *testing.T) {
|
|
fastHome(t)
|
|
if err := SetFastPick("Codex", "oa/gpt-6.1-sol", true); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !IsFastPick("codex", "oa/gpt-6.1-sol") || IsFastPick("opencode", "oa/gpt-6.1-sol") {
|
|
t.Fatalf("picks %v", settings.Load().FastPicks)
|
|
}
|
|
for _, id := range []string{"rl/claude-opus-5-5", "oa/nope", GroupPrefix + "f"} {
|
|
if err := SetFastPick("codex", id, true); err == nil {
|
|
t.Errorf("%s switched fast", id)
|
|
}
|
|
}
|
|
if err := SetFastPick("", "oa/gpt-6.1-sol", true); err == nil {
|
|
t.Error("no agent, switched fast")
|
|
}
|
|
if got := FastPicks("codex"); !slices.Equal(got, []string{"oa/gpt-6.1-sol"}) {
|
|
t.Fatalf("picks %v", got)
|
|
}
|
|
// a GPT model on a provider the user added by its address (#1615)
|
|
if err := SetFastPick("codex", "rl/gpt-6.1-sol", true); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := SetFastPick("codex", "rl/gpt-6.1-sol", false); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
st := settings.Load()
|
|
// an Ultrafast pick moves with it (#1954)
|
|
st.UltraPicks = map[string][]string{"codex": {"oa/gpt-6.1-sol"}}
|
|
if !renameModelPrefs(&st, "oa", "openai") {
|
|
t.Fatal("the rename moved nothing")
|
|
}
|
|
if err := settings.Save(st); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
Changed()
|
|
if !IsFastPick("codex", "openai/gpt-6.1-sol") || IsFastPick("codex", "oa/gpt-6.1-sol") {
|
|
t.Fatalf("after the rename: %v", settings.Load().FastPicks)
|
|
}
|
|
if !IsUltraPick("codex", "openai/gpt-6.1-sol") || IsUltraPick("codex", "oa/gpt-6.1-sol") {
|
|
t.Fatalf("after the rename: %v", settings.Load().UltraPicks)
|
|
}
|
|
|
|
// switching off is allowed whatever the model is now, and drops the agent
|
|
if err := SetFastPick("codex", "openai/gpt-6.1-sol", false); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, ok := settings.Load().FastPicks["codex"]; ok {
|
|
t.Fatalf("an agent with none kept: %v", settings.Load().FastPicks)
|
|
}
|
|
if _, ok := settings.Load().UltraPicks["codex"]; ok {
|
|
t.Fatalf("Ultrafast kept with fast off: %v", settings.Load().UltraPicks)
|
|
}
|
|
}
|