gateway, gui: the web searcher picked in Settings is never handed on to another provider, and one that answered without searching is said so (Gearclickist on Discord)

Cause: Gearclickist picked the Grok subscription's grok-4.7 in Settings ›
Web search. Their grok rows were about 1.3k tokens. That is the size of a
Grok request that ran no search. With the tool and searching, our real
Grok account gives 6k-66k input every time, and /models says
supports_backend_search for all four models. So on their account Grok
answered from what it knew. searchWith read that as "found nothing", and
modelSearch handed the search to the next of Searchers() by rank: Codex's
gpt-6-astra, a pricier subscription model they never picked.

Change:
- modelSearch: a searcher named in Settings gives way to no other
  provider. Its error goes back to the model ("no other provider searches
  in its place"), and webSearch then asks the search APIs, if any are set
  up. Automatic keeps its fallback (#669) with the Routing row that says
  why.
- searchWith tells a reply with no server_tool_use or
  web_search_tool_result (errNotSearched) apart from one that searched and
  named no page (errFoundNothing). CallFor gets notSearched.
- namedFailed/SearcherFailed keep the named searcher's last failed search,
  cleared by its next success or by picking another searcher.
  /api/settings returns it as searchFailed.
- Settings › Web search puts a warning at the start of the row's help
  (before the ellipsis) naming the searcher, when, and why ("answered
  without searching the web, so its account or plan may not offer web
  search"). The help text now says a picked provider is never replaced by
  another provider. The Routing row (kindWhy) says not-searched too.
  zh, zh-TW, ja and de strings added.
- docs/subsystems/gateway-routing.md rewritten for the rule.

Run (worktree on origin/main fd0359233):
- Real Grok account (sandbox, requests only): grok-4.x with the
  web_search tool searched each time (6k-66k input, cache 3456). Without
  it, about 1.3k input, cache 1152, which matches the reporter's rows.
- go test -tags nogui ./internal/gateway ./internal/gui: ok.
- gofmt -l is clean. go vet passes on darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- Broken by hand, the tests go red:
  - Dropping the no-handover rule turns TestPickedSearcherIsNotHandedOn
    and TestSearcherFindingNothingGivesWay red.
  - Dropping the !searched check turns the NotSearched assertions red.
  - Reverting app.js/routing.js turns the new searcher-pick and
    search-instead cases red.
- GUI (playwright 1.62.0), chromium and webkit, every language, widths
  560 and 1000: search-instead, searcher-pick, i18n-keys, settings-search,
  provider-search, search-api, search-first and search-mcp all pass,
  except searcher-pick's "search help preserves ellipsis and hover titles"
  on webkit en/ja/de. That case is red on origin/main too (#1745).

Not run or not changed:
- The reporter's own account wasn't reproducible, so why Grok skipped the
  search there isn't known.
- No change to the Grok plugin or the built-in: supports_backend_search
  is true for every model, so reading it wouldn't have caught this case.
- Not tried on Windows or Linux GUI.
This commit is contained in:
yetone
2026-10-13 02:30:53 +08:00
parent 1404faad51
commit 50adf78e66
10 changed files with 417 additions and 94 deletions
+34 -13
View File
@@ -168,7 +168,9 @@ Search API, [`canSearchFor`](../../internal/gateway/search_kimi.go) does not off
`ownSearcher` and the model list another magpie reads (`webSearchOf`, which then says no search) follow it too.
A provider's native search on the client's protocol remains unchanged.
An empty `searcher` still selects a provider automatically; an unavailable
named provider still falls back to that selection.
named provider (gone, off, can't search) still falls back to that selection.
One that is available but fails a search is not replaced by another
provider (below).
[`webSearch`](../../internal/gateway/search.go) enforces the API-only path.
Covered by `TestSearchProviderOff`, `TestSearchProviderOffForwarding`, `TestSearchProviderOffTellsRemoteMagpie`,
@@ -194,18 +196,35 @@ literal WebSearch request, the real service's reply bytes) and
## A searcher that fails or finds nothing
`modelSearch` asks the searcher picked in Settings (or the one magpie picks)
first. When it fails, or its reply names no page it found
(`errFoundNothing`), the next of `Searchers()` searches in its place, up to
three in all (#669). That fallback is not silent: `searchingInstead` puts
on the search's `CallFor` the searcher asked first (`instead`), whether the
user picked it (`picked`), and why it didn't search (`why`, or
`nothingFound`). The Routing row of the search that answered says which
searcher was asked first, for whom, why it didn't search, and which one
searched in its place (`kindWhy`). Gearclickist on Discord had Grok picked
and saw Codex's model search, with nothing saying why.
first. `searchWith` tells three outcomes apart: an error, a reply that
searched and named no page (`errFoundNothing`), and a reply with no search
in it at all, no `server_tool_use` or `web_search_tool_result`
(`errNotSearched`, which is found nothing too). The last is a vendor that
ran no search: the tool dropped or left unused, and the model answered
from what it knew.
Covered by `TestSearchInPlaceOfPickedSaysWhy` and
`search-instead.test.cjs`.
A searcher magpie picked by itself gives way to the next of `Searchers()`,
up to three in all (#669). That fallback is not silent: `searchingInstead`
puts on the search's `CallFor` the searcher asked first (`instead`), and
why it didn't search (`why`, `nothingFound` or `notSearched`). The Routing
row of the search that answered says which searcher was asked first, for
whom, why it didn't search, and which one searched in its place
(`kindWhy`).
A searcher named in Settings gives way to no other provider. Its error goes
back to the model, and `webSearch` then asks the search APIs, when any are
set up. `namedFailed` keeps the last search it didn't make, cleared when it
next searches. Settings › Web search shows that (`SearcherFailed`,
`searchFailed`) at the start of the row's help, ahead of its ellipsis.
Gearclickist on Discord picked Grok. Their grok-4.7 rows were about 1.3k
tokens, the size of a request Grok ran no search for (one that searched
took 6k-66k on our account). Every search then went on to Codex's
gpt-6-astra, a pricier model they hadn't picked. Rows recorded
before this, with `picked` set, still read as before.
Covered by `TestPickedSearcherIsNotHandedOn`,
`TestSearchInPlaceOfAutoSaysWhy`, `TestSearcherFindingNothingGivesWay`,
`search-instead.test.cjs` and `searcher-pick.test.cjs`.
## A search API's base URL
@@ -324,7 +343,9 @@ agents what magpie offers, don't flip with a window. Such a pick isn't
asked: `askVisionWith` (`autoSpent`) answers with the reason and when it is
back, and `modelSearch` (`searcherSpent`) skips it, puts spent searchers
after the others and joins the reason into its error. A model named in
Settings is asked as before. Image and video generation (`AutoDrawer`,
Settings is asked as before, and a searcher named there is not handed on
to another provider when it fails (see "A searcher that fails or finds
nothing"). Image and video generation (`AutoDrawer`,
`AutoVideomaker`) are not held this way.
Covered by `TestAutoVisionPassesOverOneOut`,
+95 -6
View File
@@ -76,9 +76,12 @@ type CallFor struct {
// says so. Picked is that the first was the one picked in Settings.
// A fallback that said nothing read as magpie ignoring the pick
// (Gearclickist on Discord: Grok picked, Codex's model searched).
// NotSearched is that the first answered without searching at all
// (errNotSearched), apart from searching and naming no page.
Instead string `json:"instead,omitempty"`
Why string `json:"why,omitempty"`
NothingFound bool `json:"nothingFound,omitempty"`
NotSearched bool `json:"notSearched,omitempty"`
Picked bool `json:"picked,omitempty"`
}
@@ -564,9 +567,13 @@ var errNoSearcher = errors.New("no provider that can search the web, nor a searc
// before it goes to the search APIs.
const searchersInTurn = 3
// modelSearch searches the web with the searcher's model; one that fails
// or finds nothing gives way to the next searcher magpie would pick, all
// of them within searchTimeout.
// modelSearch searches the web with the searcher's model; one magpie
// picked that fails or finds nothing gives way to the next searcher magpie
// would pick, all of them within searchTimeout. One Settings names gives
// way to none: the search APIs, when set up, search in its place
// (webSearch), and Settings says it didn't search (SearcherFailed). Handed
// on, a search for Grok, picked, went to Codex's gpt-6-astra, a pricier
// model the user hadn't picked, on every search (Gearclickist on Discord).
func (s *Server) modelSearch(ctx context.Context, query string) (string, []Hit, error) {
p, model, ok := searcher()
if !ok {
@@ -581,12 +588,24 @@ func (s *Server) modelSearch(ctx context.Context, query string) (string, []Hit,
// one magpie picked that is out of its allowance isn't asked: it
// would only be refused again (#1801); one the Settings name is
err := searcherSpent(p, model)
if cp, _, why := chosenSearcher(); why == "" && cp != nil && cp.ID == p.ID {
cp, _, why := chosenSearcher()
named := why == "" && cp != nil && cp.ID == p.ID
if named {
err = nil
}
if err == nil {
said, hits, err = s.searchBy(ctx, p, model, query)
}
if named {
// a search the agent stopped waiting for is no failure of its
if !errors.Is(ctx.Err(), context.Canceled) {
namedFailed(p, model, err)
}
if err != nil {
return "", nil, fmt.Errorf("%w (the searcher picked in Settings › Web search: no other provider searches in its place)", err)
}
return said, hits, nil
}
// the others in turn, those with allowance left first
var turn, spent []SearcherChoice
for _, c := range Searchers() {
@@ -623,6 +642,61 @@ func (s *Server) modelSearch(ctx context.Context, query string) (string, []Hit,
return said, hits, err
}
// lastNamedFail is the last search the searcher Settings names didn't
// make, for Settings to say (SearcherFailed); cleared when it searches.
var lastNamedFail struct {
sync.Mutex
f SearchFailure
}
// SearchFailure is a search the searcher Settings names didn't make: why,
// and when.
type SearchFailure struct {
Searcher string // "<provider>/<model>", or "<provider>"
Why string // the error, when it neither found nothing nor didn't search
NothingFound bool // it searched and named no page
NotSearched bool // it answered without searching (errNotSearched)
At time.Time
}
func namedFailed(p provider.Provider, model string, err error) {
name := p.ID
if model != "" {
name += "/" + model
}
lastNamedFail.Lock()
defer lastNamedFail.Unlock()
if err == nil {
if lastNamedFail.f.Searcher == name {
lastNamedFail.f = SearchFailure{}
}
return
}
f := SearchFailure{Searcher: name, At: time.Now(), NotSearched: errors.Is(err, errNotSearched)}
f.NothingFound = !f.NotSearched && errors.Is(err, errFoundNothing)
if !f.NothingFound && !f.NotSearched {
f.Why = strings.TrimPrefix(err.Error(), name+": ")
}
lastNamedFail.f = f
}
// SearcherFailed is the last search the searcher Settings names now didn't
// make, since it last searched; ok false when there is none.
func SearcherFailed() (SearchFailure, bool) {
p, m, why := chosenSearcher()
if p == nil || why != "" {
return SearchFailure{}, false
}
name := p.ID
if m != "" {
name += "/" + m
}
lastNamedFail.Lock()
defer lastNamedFail.Unlock()
f := lastNamedFail.f
return f, f.Searcher != "" && f.Searcher == name
}
// searcherSpent is why a searcher's model isn't asked: every account or
// key of it is out of its allowance (spentModel). nil when it has
// allowance, or searches with no model (a Kimi Code plan's service).
@@ -658,9 +732,10 @@ func searchingInstead(ctx context.Context, p provider.Provider, model string, er
if c, _, why := chosenSearcher(); why == "" && c != nil && c.ID == p.ID {
g.Picked = true
}
g.NothingFound = errors.Is(err, errFoundNothing)
g.NotSearched = errors.Is(err, errNotSearched)
g.NothingFound = !g.NotSearched && errors.Is(err, errFoundNothing)
g.Why = ""
if !g.NothingFound {
if !g.NothingFound && !g.NotSearched {
g.Why = strings.TrimPrefix(err.Error(), g.Instead+": ")
}
return context.WithValue(ctx, searchForKey{}, &g)
@@ -669,6 +744,13 @@ func searchingInstead(ctx context.Context, p provider.Provider, model string, er
// errFoundNothing is a searcher's reply that names no page it found.
var errFoundNothing = errors.New("found nothing")
// errNotSearched is a searcher's reply with no search in it at all: the
// vendor ran no search, the tool dropped or left unused, and the model
// answered from what it knew (Gearclickist on Discord: grok-4.7 answered
// in 1.4k tokens, the size of a request with no search tool, where one
// that searched took 6k-66k). It is found nothing too.
var errNotSearched = fmt.Errorf("answered without searching the web: %w", errFoundNothing)
// searchWith asks one searcher's model to search: what it said, with the
// pages its searches found. A reply with no page found and no address in
// what it says found nothing: the model answered without searching (#669:
@@ -711,11 +793,15 @@ func (s *Server) searchWith(ctx context.Context, p provider.Provider, model, que
var text strings.Builder
var sources []string
var found []Hit
searched := false
for _, b := range out.Content {
switch b.Type {
case "text":
text.WriteString(b.Text)
case "server_tool_use":
searched = true
case "web_search_tool_result":
searched = true
// each result read on its own, its title, address and age
// only: a vendor's encrypted_content is for that vendor, and
// an error ({"type":"web_search_tool_result_error"}) has none
@@ -738,6 +824,9 @@ func (s *Server) searchWith(ctx context.Context, p provider.Provider, model, que
}
said := strings.TrimSpace(text.String())
if said == "" || (len(found) == 0 && !strings.Contains(said, "://")) {
if !searched {
return "", nil, fmt.Errorf("%s/%s %w", p.ID, model, errNotSearched)
}
return "", nil, fmt.Errorf("%s/%s %w", p.ID, model, errFoundNothing)
}
if len(sources) > 0 && len(sources) <= 20 {
+17 -6
View File
@@ -356,20 +356,31 @@ func TestSearcherFindingNothingGivesWay(t *testing.T) {
// another searcher, next in magpie's order, answers before the APIs
apis.asked = nil
ds2 := newFakeDeepSeek(t)
searchesOn(t, provider.Anthropic, ds2.URL)
save(t, provider.Provider{ID: "ds2", Name: "DeepSeek 2", Key: "k", Anthropic: ds2.URL + "/anthropic", Models: []string{"deepseek-flash"}})
searchesOn(t, provider.Responses, ds2.URL)
save(t, provider.Provider{ID: "ds2", Name: "DeepSeek 2", Key: "k", Responses: ds2.URL + "/v1", Models: []string{"deepseek-flash"}})
if p, _, _ := searcher(); p.ID != "ds" {
t.Fatalf("magpie's searcher is %s", p.ID)
}
blocks = searchAsClaudeCode(t)
if len(apis.asked) != 0 || len(ds2.searches()) != 1 {
t.Fatalf("APIs asked %q, the next searcher %q", apis.asked, ds2.searches())
}
if found, _ = blocks[0]["content"].([]any); len(found) != 1 || found[0].(map[string]any)["url"] != "https://www.weather.com.cn/weather/101020100.shtml" {
t.Fatalf("blocks %v", blocks)
}
// one picked in Settings gives way to the APIs only, never to ds2
// (Gearclickist on Discord)
apis.asked = nil
st := settings.Load()
st.Searcher = "ds"
if err := settings.Save(st); err != nil {
t.Fatal(err)
}
blocks = searchAsClaudeCode(t)
if len(apis.asked) != 0 || len(ds2.searches()) != 1 {
if strings.Join(apis.asked, "|") != "tavily: 今天上海天气" || len(ds2.searches()) != 1 {
t.Fatalf("APIs asked %q, the next searcher %q", apis.asked, ds2.searches())
}
if found, _ = blocks[0]["content"].([]any); len(found) != 2 {
t.Fatalf("blocks %v", blocks)
}
}
// With the search APIs put first (#928), a search goes to them before the
+153 -52
View File
@@ -11,41 +11,74 @@ import (
"github.com/yetone/magpie/internal/settings"
)
// When the searcher picked in Settings fails or finds nothing and the
// next one searches in its place, the row of the search that answered
// names the picked one and why (Gearclickist on Discord: Grok was picked,
// Codex's model searched, and nothing said Grok had failed). Without it
// the fallback's row reads as an ordinary search by the other model.
func TestSearchInPlaceOfPickedSaysWhy(t *testing.T) {
// pickedSearchSetup is a search for glm/glm-flash, which can't search, with
// ds/deepseek-flash, on DeepSeek's Responses API, the first searcher: one
// that answers without searching (blind), or one whose every search is
// refused (failing). next is another searcher that would search.
func pickedSearchSetup(t *testing.T, failing bool, nextOn provider.Protocol) (ds, next *fakeDeepSeek, result func() string) {
t.Helper()
searchSandbox(t)
forget := func() {
lastNamedFail.Lock()
lastNamedFail.f = SearchFailure{}
lastNamedFail.Unlock()
}
forget()
t.Cleanup(forget)
ds = newFakeDeepSeek(t)
ds.blind = true
first := ds.URL
if failing {
broken := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasSuffix(r.URL.Path, "/models") {
w.Write([]byte(`{"data":[{"id":"deepseek-flash"}]}`))
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(`{"error":{"message":"search quota used up"}}`))
}))
t.Cleanup(broken.Close)
first = broken.URL
}
glm, result := newBlindModel(t)
next = newFakeDeepSeek(t)
searchesOn(t, provider.Responses, first)
searchesOn(t, nextOn, next.URL)
ds2 := provider.Provider{ID: "ds2", Name: "DeepSeek 2", Key: "k", Models: []string{"deepseek-flash"}}
if nextOn == provider.Anthropic {
ds2.Anthropic = next.URL + "/anthropic"
} else {
ds2.Responses = next.URL + "/v1"
}
save(t, provider.Provider{ID: "ds", Name: "DeepSeek", Key: "k", Responses: first + "/v1", Models: []string{"deepseek-flash"}},
provider.Provider{ID: "glm", Name: "GLM", Key: "k", Chat: glm.URL, Models: []string{"glm-flash"}}, ds2)
return ds, next, result
}
func searchForGLM(t *testing.T, s *Server) {
t.Helper()
body := `{"model":"glm/glm-flash","max_tokens":3000,"stream":true,"messages":[{"role":"user","content":"用 web_search 工具搜索:今天上海天气"}],"tools":[{"type":"web_search_20250305","name":"web_search"}]}`
rec := httptest.NewRecorder()
s.Handler().ServeHTTP(rec, httptest.NewRequest(http.MethodPost, "/v1/messages", strings.NewReader(body)))
if rec.Code != 200 {
t.Fatalf("%d %s", rec.Code, rec.Body.String())
}
}
// The searcher picked in Settings that fails, or answers without
// searching, gives way to no other provider: Gearclickist on Discord
// picked Grok, whose grok-4.7 answered without searching, and every search
// went on to Codex's gpt-6-astra, a pricier model never picked. The model
// is told the search failed, Settings says why (SearcherFailed), and only
// the search APIs, when set up, search in its place.
func TestPickedSearcherIsNotHandedOn(t *testing.T) {
for _, tc := range []struct {
name string
failing bool
}{{"found nothing", false}, {"failed", true}} {
}{{"answered without searching", false}, {"failed", true}} {
t.Run(tc.name, func(t *testing.T) {
searchSandbox(t)
ds := newFakeDeepSeek(t)
ds.blind = true
picked := ds.URL
if tc.failing {
broken := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasSuffix(r.URL.Path, "/models") {
w.Write([]byte(`{"data":[{"id":"deepseek-flash"}]}`))
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(`{"error":{"message":"search quota used up"}}`))
}))
t.Cleanup(broken.Close)
picked = broken.URL
}
glm, _ := newBlindModel(t)
next := newFakeDeepSeek(t)
searchesOn(t, provider.Responses, picked)
searchesOn(t, provider.Anthropic, next.URL)
save(t, provider.Provider{ID: "ds", Name: "DeepSeek", Key: "k", Responses: picked + "/v1", Models: []string{"deepseek-flash"}},
provider.Provider{ID: "glm", Name: "GLM", Key: "k", Chat: glm.URL, Models: []string{"glm-flash"}},
provider.Provider{ID: "ds2", Name: "DeepSeek 2", Key: "k", Anthropic: next.URL + "/anthropic", Models: []string{"deepseek-flash"}})
ds, next, result := pickedSearchSetup(t, tc.failing, provider.Anthropic)
st := settings.Load()
st.Searcher = "ds/deepseek-flash"
if err := settings.Save(st); err != nil {
@@ -53,40 +86,108 @@ func TestSearchInPlaceOfPickedSaysWhy(t *testing.T) {
}
s := New()
body := `{"model":"glm/glm-flash","max_tokens":3000,"stream":true,"messages":[{"role":"user","content":"用 web_search 工具搜索:今天上海天气"}],"tools":[{"type":"web_search_20250305","name":"web_search"}]}`
rec := httptest.NewRecorder()
s.Handler().ServeHTTP(rec, httptest.NewRequest(http.MethodPost, "/v1/messages", strings.NewReader(body)))
if rec.Code != 200 || len(next.searches()) != 1 {
t.Fatalf("%d, the next searcher asked %q: %s", rec.Code, next.searches(), rec.Body.String())
searchForGLM(t, s)
if got := next.searches(); len(got) != 0 {
t.Fatalf("another provider searched in place of the picked one: %q", got)
}
if r := result(); strings.Contains(r, "22/17℃") || !strings.Contains(r, "no other provider searches in its place") {
t.Fatalf("the model was told %q", r)
}
var first, instead *Route
for _, r := range s.Trace(context.Background(), 0, 0).Routes {
if r.Kind != "web_search" {
continue
if r.Kind == "web_search" && strings.HasPrefix(r.Model, "ds2/") {
t.Fatalf("a web search row for ds2: %+v", r)
}
r := r
if strings.HasPrefix(r.Model, "ds2/") {
}
f, ok := SearcherFailed()
if !ok || f.Searcher != "ds/deepseek-flash" || f.At.IsZero() {
t.Fatalf("SearcherFailed = %+v %v", f, ok)
}
if tc.failing && (f.NotSearched || f.NothingFound || !strings.Contains(f.Why, "search quota used up")) {
t.Fatalf("SearcherFailed = %+v, want the picked searcher's error", f)
}
if !tc.failing && (!f.NotSearched || f.NothingFound || f.Why != "") {
t.Fatalf("SearcherFailed = %+v, want answered without searching", f)
}
// a search API set up searches in its place, still not ds2
apis := newSearchAPIs(t)
if err := provider.SetSearchAPI(apis.api("tavily", "tvly-k")); err != nil {
t.Fatal(err)
}
searchForGLM(t, New())
if strings.Join(apis.asked, "|") != "tavily: 今天上海天气" || len(next.searches()) != 0 {
t.Fatalf("search APIs asked %q, ds2 %q", apis.asked, next.searches())
}
if r := result(); !strings.Contains(r, "go1.27.1") {
t.Fatalf("the model was told %q", r)
}
// another pick says nothing of it, and a search by it clears it
st.Searcher = "ds2"
if err := settings.Save(st); err != nil {
t.Fatal(err)
}
if f, ok := SearcherFailed(); ok {
t.Fatalf("another searcher picked, SearcherFailed = %+v", f)
}
if !tc.failing {
st.Searcher = "ds/deepseek-flash"
if err := settings.Save(st); err != nil {
t.Fatal(err)
}
ds.mu.Lock()
ds.blind = false
ds.mu.Unlock()
searchForGLM(t, New())
if f, ok := SearcherFailed(); ok {
t.Fatalf("the picked searcher searched, SearcherFailed = %+v", f)
}
}
})
}
}
// When the searcher magpie picked by itself fails or finds nothing and the
// next one searches in its place, the row of the search that answered
// names the first and why: one that answered without searching is said so,
// apart from one that searched and named no page.
func TestSearchInPlaceOfAutoSaysWhy(t *testing.T) {
for _, tc := range []struct {
name string
failing bool
}{{"answered without searching", false}, {"failed", true}} {
t.Run(tc.name, func(t *testing.T) {
_, next, _ := pickedSearchSetup(t, tc.failing, provider.Responses)
if p, m, ok := searcher(); !ok || p.ID != "ds" || m != "deepseek-flash" {
t.Fatalf("magpie's searcher is %s/%s", p.ID, m)
}
s := New()
searchForGLM(t, s)
if len(next.searches()) != 1 {
t.Fatalf("the next searcher asked %q", next.searches())
}
var instead *Route
for _, r := range s.Trace(context.Background(), 0, 0).Routes {
if r.Kind == "web_search" && strings.HasPrefix(r.Model, "ds2/") {
r := r
instead = &r
} else if strings.HasPrefix(r.Model, "ds/") {
first = &r
}
}
if instead == nil || instead.For == nil {
t.Fatalf("no row for the search that answered: %+v", s.Trace(context.Background(), 0, 0).Routes)
}
f := instead.For
if f.Instead != "ds/deepseek-flash" || !f.Picked || f.Agent == "" || f.Model != "glm/glm-flash" {
t.Fatalf("the answering search's row is for %+v, want it to name the picked ds/deepseek-flash", *f)
if f.Instead != "ds/deepseek-flash" || f.Picked || f.Model != "glm/glm-flash" {
t.Fatalf("the answering search's row is for %+v", *f)
}
if tc.failing && (f.NothingFound || !strings.Contains(f.Why, "search quota used up")) {
t.Fatalf("why %q nothing %v, want the picked searcher's error", f.Why, f.NothingFound)
if tc.failing && (f.NothingFound || f.NotSearched || !strings.Contains(f.Why, "search quota used up")) {
t.Fatalf("why %q nothing %v not searched %v, want the first searcher's error", f.Why, f.NothingFound, f.NotSearched)
}
if !tc.failing && (!f.NothingFound || f.Why != "") {
t.Fatalf("why %q nothing %v, want found nothing", f.Why, f.NothingFound)
if !tc.failing && (f.NothingFound || !f.NotSearched || f.Why != "") {
t.Fatalf("why %q nothing %v not searched %v, want answered without searching", f.Why, f.NothingFound, f.NotSearched)
}
// the picked one's own row is an ordinary search for the model
if first != nil && first.For != nil && first.For.Instead != "" {
t.Fatalf("the picked searcher's own row says it was in place of %q", first.For.Instead)
if _, ok := SearcherFailed(); ok {
t.Fatal("SearcherFailed with no searcher picked")
}
})
}
+16
View File
@@ -406,6 +406,10 @@ type settingsJSON struct {
SearchAuto string `json:"searchAuto,omitempty"`
SearchUnused string `json:"searchUnused,omitempty"`
SearchRelays []string `json:"searchRelays,omitempty"`
// the last search the one it names didn't make, since it last
// searched: no other provider searched in its place (Gearclickist on
// Discord)
SearchFailed *searchFailedJSON `json:"searchFailed,omitempty"`
// the providers on that aren't offered, as they can't search the web
// by themselves (#825)
SearchLeftOut []string `json:"searchLeftOut,omitempty"`
@@ -502,6 +506,9 @@ func searchState(s *settingsJSON) {
}
s.SearchProvider = gateway.Searcher()
s.SearchAuto, s.SearchUnused = gateway.AutoSearcher(), gateway.SearcherUnused()
if f, ok := gateway.SearcherFailed(); ok {
s.SearchFailed = &searchFailedJSON{Searcher: f.Searcher, Why: f.Why, NothingFound: f.NothingFound, NotSearched: f.NotSearched, At: f.At}
}
s.SearchChoices = []searchChoiceJSON{}
for _, c := range gateway.Searchers() {
p := c.Provider
@@ -522,6 +529,15 @@ func searchState(s *settingsJSON) {
}
}
// searchFailedJSON is gateway.SearchFailure as Settings shows it.
type searchFailedJSON struct {
Searcher string `json:"searcher"`
Why string `json:"why,omitempty"`
NothingFound bool `json:"nothingFound,omitempty"`
NotSearched bool `json:"notSearched,omitempty"`
At time.Time `json:"at"`
}
func settingsState() settingsJSON {
s := settingsJSON{Settings: settings.Load(), Version: Version, Dir: tilde(settings.Dir()), Portable: settings.Portable() != "", Gateway: gateway.URL()}
s.AddrEnv = os.Getenv("MAGPIE_ADDR")
+10 -1
View File
@@ -21981,11 +21981,20 @@ function renderSearcher(s, keep, box) {
const icOf = (id) => choices.find((x) => x.id === id.split("/")[0])?.icon;
const r = el("div", "row pref searcher-row");
const who = el("div", "who");
const sub = el("div", "sub", off ? t("When provider search is off, only configured Search APIs are used. Without a Search API, magpie does not add a search tool. Providers' native web search is unchanged.") : t("When a model can't search the web directly, the selected provider searches for it and returns the results. Searches may use the service's quota or incur charges; if a search fails, magpie tries other available sources."));
const sub = el("div", "sub", off ? t("When provider search is off, only configured Search APIs are used. Without a Search API, magpie does not add a search tool. Providers' native web search is unchanged.") : t("When a model can't search the web directly, the selected provider searches for it and returns the results. Searches may use the service's quota or incur charges; if the provider magpie picks fails, it tries other available sources, but a provider you select here is never replaced by another provider, only by your Search APIs."));
if (!off && v && s.searchUnused) {
const why = { gone: t("it is no longer in magpie"), off: t("it is turned off"), cant: t("it can't search the web by itself"), nomodel: t("it lists no model") }[s.searchUnused] || s.searchUnused;
sub.append(" · ", el("span", "warn searcher-unused", t("{who} isn't used: {why}, so magpie picks one", { who: named(v), why })));
}
// the one named didn't search last time, and no other provider searched
// in its place (Gearclickist on Discord: Grok picked answered without
// searching, and Codex's pricier model searched instead, unasked). First,
// so the one-line help's ellipsis doesn't hide it.
const failed = s.searchFailed;
if (!off && v && !s.searchUnused && failed) {
const why = failed.notSearched ? t("it answered without searching the web, so its account or plan may not offer web search") : failed.nothingFound ? t("its reply named no page it found") : failed.why || t("it failed");
sub.prepend(el("span", "warn searcher-failed", t("{who} didn't search {when}: {why}. No other provider searched in its place; pick Automatic or another provider, or add a Search API.", { who: named(v), when: ago(failed.at), why })), " · ");
}
const plans = choices.filter((c) => c.service).map((c) => c.name);
if (!off && plans.length) sub.append(" · ", el("span", "searcher-own",
t("A Kimi Code plan ({names}) searches for its own models first, with its web search; for other models only when named here", { names: plans.join(", ") })));
+12 -4
View File
@@ -997,7 +997,9 @@ const I18N = {
"When provider search is off, only configured Search APIs are used. Without a Search API, magpie does not add a search tool. Providers' native web search is unchanged.": "关闭供应商代搜后,仅使用已配置的搜索 API;未配置时,Magpie 不添加搜索工具。供应商自带的联网搜索不受影响。",
"Provider search is off; only these APIs are used": "已关闭供应商代搜,仅使用这些 API",
"Searches for other models": "代搜供应商",
"When a model can't search the web directly, the selected provider searches for it and returns the results. Searches may use the service's quota or incur charges; if a search fails, magpie tries other available sources.": "当模型无法直接联网搜索时,由所选供应商代为搜索并返回结果。代搜可能消耗所用服务的额度或产生费用;失败时会尝试其他可用来源。",
"When a model can't search the web directly, the selected provider searches for it and returns the results. Searches may use the service's quota or incur charges; if the provider magpie picks fails, it tries other available sources, but a provider you select here is never replaced by another provider, only by your Search APIs.": "当模型无法直接联网搜索时,由所选供应商代为搜索并返回结果。代搜可能消耗所用服务的额度或产生费用;magpie 自动选择的供应商失败时会尝试其他可用来源,但在此手动选中的供应商不会被换成其他供应商,只会改用你配置的搜索 API。",
"{who} didn't search {when}: {why}. No other provider searched in its place; pick Automatic or another provider, or add a Search API.": "{who} {when}没能搜索:{why}。没有换用其他供应商代搜;可改选“自动”或其他供应商,或添加搜索 API。",
"it answered without searching the web, so its account or plan may not offer web search": "它没有联网搜索就直接回答了,它的账号或套餐可能不支持联网搜索",
"no provider that searches": "没有能搜索的供应商",
"{model}, its small model": "{model}(它的小模型)",
"its web search": "它自带的联网搜索",
@@ -5463,7 +5465,9 @@ const I18N = {
"When provider search is off, only configured Search APIs are used. Without a Search API, magpie does not add a search tool. Providers' native web search is unchanged.": "關閉供應商代搜後,僅使用已設定的搜尋 API;未設定時,Magpie 不新增搜尋工具。供應商內建的聯網搜尋不受影響。",
"Provider search is off; only these APIs are used": "已關閉供應商代搜,僅使用這些 API",
"Searches for other models": "代搜供應商",
"When a model can't search the web directly, the selected provider searches for it and returns the results. Searches may use the service's quota or incur charges; if a search fails, magpie tries other available sources.": "當模型無法直接聯網搜尋時,由所選供應商代為搜尋並返回結果。代搜可能消耗所用服務的額度或產生費用;失敗時會嘗試其他可用來源。",
"When a model can't search the web directly, the selected provider searches for it and returns the results. Searches may use the service's quota or incur charges; if the provider magpie picks fails, it tries other available sources, but a provider you select here is never replaced by another provider, only by your Search APIs.": "當模型無法直接聯網搜尋時,由所選供應商代為搜尋並返回結果。代搜可能消耗所用服務的額度或產生費用;magpie 自動選擇的供應商失敗時會嘗試其他可用來源,但在此手動選中的供應商不會被換成其他供應商,只會改用你設定的搜尋 API。",
"{who} didn't search {when}: {why}. No other provider searched in its place; pick Automatic or another provider, or add a Search API.": "{who} {when}沒能搜尋:{why}。沒有換用其他供應商代搜;可改選「自動」或其他供應商,或新增搜尋 API。",
"it answered without searching the web, so its account or plan may not offer web search": "它沒有聯網搜尋就直接回答了,它的帳號或方案可能不支援聯網搜尋",
"no provider that searches": "沒有能搜尋的供應商",
"{model}, its small model": "{model}(它的小模型)",
"its web search": "它自帶的聯網搜尋",
@@ -9899,7 +9903,9 @@ const I18N = {
"When provider search is off, only configured Search APIs are used. Without a Search API, magpie does not add a search tool. Providers' native web search is unchanged.": "プロバイダによる代行検索がオフの場合、設定済みの検索 API のみを使用します。検索 API がない場合、magpie は検索ツールを追加しません。プロバイダのネイティブなウェブ検索には影響しません。",
"Provider search is off; only these APIs are used": "プロバイダによる代行検索はオフです。これらの API のみを使用します",
"Searches for other models": "他のモデルの代わりに検索",
"When a model can't search the web directly, the selected provider searches for it and returns the results. Searches may use the service's quota or incur charges; if a search fails, magpie tries other available sources.": "モデルが直接ウェブ検索できない場合、選択したプロバイダが代わりに検索し、結果を返します。検索にはサービスの利用枠を消費したり、料金が発生したりする場合があります。検索に失敗すると、magpie は他の利用可能な検索元を試します。",
"When a model can't search the web directly, the selected provider searches for it and returns the results. Searches may use the service's quota or incur charges; if the provider magpie picks fails, it tries other available sources, but a provider you select here is never replaced by another provider, only by your Search APIs.": "モデルが直接ウェブ検索できない場合、選択したプロバイダが代わりに検索し、結果を返します。検索にはサービスの利用枠を消費したり、料金が発生したりする場合があります。magpie が自動で選んだプロバイダが失敗すると他の利用可能な検索元を試しますが、ここで選んだプロバイダが別のプロバイダに置き換えられることはなく、設定済みの検索 API だけが代わりに使われます。",
"{who} didn't search {when}: {why}. No other provider searched in its place; pick Automatic or another provider, or add a Search API.": "{who} は{when}、検索できませんでした:{why}。他のプロバイダが代わりに検索することはありません。「自動」か別のプロバイダを選ぶか、検索 API を追加してください。",
"it answered without searching the web, so its account or plan may not offer web search": "ウェブ検索をせずに回答しました。アカウントやプランがウェブ検索に対応していない可能性があります",
"no provider that searches": "検索できるプロバイダなし",
"{model}, its small model": "{model}(その小型モデル)",
"its web search": "そのウェブ検索",
@@ -14354,7 +14360,9 @@ const I18N = {
"When provider search is off, only configured Search APIs are used. Without a Search API, magpie does not add a search tool. Providers' native web search is unchanged.": "Wenn die Anbietersuche ausgeschaltet ist, werden nur konfigurierte Such-APIs verwendet. Ohne Such-API fügt magpie kein Suchwerkzeug hinzu. Die native Websuche der Anbieter bleibt unverändert.",
"Provider search is off; only these APIs are used": "Die Anbietersuche ist ausgeschaltet; nur diese APIs werden verwendet",
"Searches for other models": "Sucht für andere Modelle",
"When a model can't search the web directly, the selected provider searches for it and returns the results. Searches may use the service's quota or incur charges; if a search fails, magpie tries other available sources.": "Wenn ein Modell nicht direkt im Web suchen kann, übernimmt der ausgewählte Anbieter die Suche und liefert die Ergebnisse. Suchen können das Kontingent des Dienstes verbrauchen oder Kosten verursachen. Schlägt eine Suche fehl, versucht magpie andere verfügbare Quellen.",
"When a model can't search the web directly, the selected provider searches for it and returns the results. Searches may use the service's quota or incur charges; if the provider magpie picks fails, it tries other available sources, but a provider you select here is never replaced by another provider, only by your Search APIs.": "Wenn ein Modell nicht direkt im Web suchen kann, übernimmt der ausgewählte Anbieter die Suche und liefert die Ergebnisse. Suchen können das Kontingent des Dienstes verbrauchen oder Kosten verursachen. Schlägt der von magpie gewählte Anbieter fehl, versucht magpie andere verfügbare Quellen; ein hier ausgewählter Anbieter wird jedoch nie durch einen anderen Anbieter ersetzt, nur durch Ihre Such-APIs.",
"{who} didn't search {when}: {why}. No other provider searched in its place; pick Automatic or another provider, or add a Search API.": "{who} hat {when} nicht gesucht: {why}. Kein anderer Anbieter hat an seiner Stelle gesucht; wählen Sie Automatisch oder einen anderen Anbieter, oder fügen Sie eine Such-API hinzu.",
"it answered without searching the web, so its account or plan may not offer web search": "es hat ohne Websuche geantwortet, daher bietet sein Konto oder Tarif möglicherweise keine Websuche",
"no provider that searches": "kein Anbieter mit Suche",
"{model}, its small model": "{model}, sein kleines Modell",
"its web search": "seine Websuche",
+1 -1
View File
@@ -1837,7 +1837,7 @@
const whom = f.mcp ? t("{agent}'s call to magpie's web_search MCP tool", { agent: agentName(f.agent) })
: f.model ? t("{agent}'s {model}", { agent: agentName(f.agent), model: f.model })
: t("a model that can't search the web by itself");
const why = f.nothingFound ? t("its reply named no page it found") : f.why || t("it failed");
const why = f.notSearched ? t("it answered without searching the web, so its account or plan may not offer web search") : f.nothingFound ? t("its reply named no page it found") : f.why || t("it failed");
return f.picked
? t("{failed}, the searcher picked in Settings › Models › Web search, didn't search for {whom}: {why}. So magpie had {searcher}, the next searcher it can use, search in its place. Not a turn of the conversation.", { failed: f.instead, whom, why, searcher: r.model })
: t("{failed}, the searcher magpie picked, didn't search for {whom}: {why}. So magpie had {searcher}, the next searcher it can use, search in its place. Not a turn of the conversation.", { failed: f.instead, whom, why, searcher: r.model });
+12 -6
View File
@@ -17,22 +17,27 @@ const words = {
en: {
failed: /grok\/grok-4\.3, the searcher picked in Settings › Models › Web search, didn't search for Codex's zai\/glm-5\.2: 502 upstream closed\. So magpie had codex\/gpt-6\.1-sol, the next searcher it can use, search in its place\. Not a turn of the conversation\.$/,
nothing: /grok\/grok-4\.3, the searcher magpie picked, didn't search for Codex's zai\/glm-5\.2: its reply named no page it found\. So magpie had codex\/gpt-6\.1-sol/,
notSearched: /grok\/grok-4\.3, the searcher magpie picked, didn't search for Codex's zai\/glm-5\.2: it answered without searching the web, so its account or plan may not offer web search\. So magpie had codex\/gpt-6\.1-sol/,
},
zh: {
failed: /grok\/grok-4\.3 是在 设置 › 模型 › 联网搜索 里选的代搜模型,但它没能为 Codex 的 zai\/glm-5\.2 搜索:502 upstream closed。所以 magpie 改让下一个可用的代搜模型 codex\/gpt-6\.1-sol 来搜。不属于对话轮次。$/,
nothing: /grok\/grok-4\.3 是 magpie 自动选的代搜模型,但它没能为 Codex 的 zai\/glm-5\.2 搜索:它的回复里没有搜到的网页。/,
notSearched: /grok\/grok-4\.3 是 magpie 自动选的代搜模型,但它没能为 Codex 的 zai\/glm-5\.2 搜索:它没有联网搜索就直接回答了,它的账号或套餐可能不支持联网搜索。/,
},
"zh-TW": {
failed: /grok\/grok-4\.3 是在 設定 › 模型 › 聯網搜尋 裡選的代搜模型,但它沒能為 Codex 的 zai\/glm-5\.2 搜尋:502 upstream closed。所以 magpie 改讓下一個可用的代搜模型 codex\/gpt-6\.1-sol 來搜。不屬於對話輪次。$/,
nothing: /grok\/grok-4\.3 是 magpie 自動選的代搜模型,但它沒能為 Codex 的 zai\/glm-5\.2 搜尋:它的回覆裡沒有搜到的網頁。/,
notSearched: /grok\/grok-4\.3 是 magpie 自動選的代搜模型,但它沒能為 Codex 的 zai\/glm-5\.2 搜尋:它沒有聯網搜尋就直接回答了,它的帳號或方案可能不支援聯網搜尋。/,
},
ja: {
failed: /設定 › モデル › ウェブ検索 で選んだ検索モデル grok\/grok-4\.3 は Codex の zai\/glm-5\.2 の代わりに検索できませんでした:502 upstream closed。そのため magpie は次に使える検索モデル codex\/gpt-6\.1-sol に代わりに検索させました。会話のターンではありません。$/,
nothing: /magpie が自動で選んだ検索モデル grok\/grok-4\.3 は Codex の zai\/glm-5\.2 の代わりに検索できませんでした:返答に見つけたページがありませんでした。/,
notSearched: /magpie が自動で選んだ検索モデル grok\/grok-4\.3 は Codex の zai\/glm-5\.2 の代わりに検索できませんでした:ウェブ検索をせずに回答しました。アカウントやプランがウェブ検索に対応していない可能性があります。/,
},
de: {
failed: /grok\/grok-4\.3, der unter Einstellungen › Modelle › Websuche gewählte Sucher, hat nicht für zai\/glm-5\.2 von Codex gesucht: 502 upstream closed\. Daher ließ magpie codex\/gpt-6\.1-sol, den nächsten nutzbaren Sucher, an seiner Stelle suchen\. Keine Runde des Gesprächs\.$/,
nothing: /grok\/grok-4\.3, der von magpie gewählte Sucher, hat nicht für zai\/glm-5\.2 von Codex gesucht: seine Antwort nannte keine gefundene Seite\./,
notSearched: /grok\/grok-4\.3, der von magpie gewählte Sucher, hat nicht für zai\/glm-5\.2 von Codex gesucht: es hat ohne Websuche geantwortet, daher bietet sein Konto oder Tarif möglicherweise keine Websuche\./,
},
};
@@ -45,9 +50,10 @@ const route = (id, f) => ({
tries: [{ id: "codex", model: "gpt-6.1-sol", start: new Date(now.getTime() - id * 60e3).toISOString(), done: true, status: 200, ms: 900 }],
done: true, status: 200, ms: 900, tokens: 1200,
});
// newest first: the picked searcher that failed, then magpie's own pick
// that found nothing
const routes = [route(1, { picked: true, why: "502 upstream closed" }), route(2, { nothingFound: true })];
// newest first: the picked searcher that failed (a row kept from before a
// picked searcher stopped being handed on), magpie's own pick that found
// nothing, and its pick that answered without searching
const routes = [route(1, { picked: true, why: "502 upstream closed" }), route(2, { nothingFound: true }), route(3, { notSearched: true })];
function serve(lang) {
const settings = { lang, theme: "light", searcher: "grok/grok-4.3", gateway: "http://127.0.0.1:3999", port: 3999 };
@@ -100,17 +106,17 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.locator(".rt-days .rt-day").nth(1).click();
// each row's story, read once its own is drawn
const said = [];
for (const i of [0, 1]) {
for (const i of [0, 1, 2]) {
const req = page.locator(".rt-req").nth(i);
await req.waitFor();
await req.click();
const h = await page.waitForFunction((prev) => {
const s = document.querySelector(".rt-steps li.kind")?.textContent.trim();
return s && s !== prev && s;
}, said[0] || "");
}, said.at(-1) || "");
said.push(await h.jsonValue());
}
for (const want of [w.failed, w.nothing]) {
for (const want of [w.failed, w.nothing, w.notSearched]) {
assert(said.some((s) => want.test(s)), `${width}px: ${want} in\n${said.join("\n")}`);
}
assert(await page.evaluate(() => document.scrollingElement.scrollWidth <= innerWidth + 1), `no sideways scroll at ${width}px`);
+67 -5
View File
@@ -49,22 +49,22 @@ const words = {
};
const helpWords = {
en: {
help: "When a model can't search the web directly, the selected provider searches for it and returns the results. Searches may use the service's quota or incur charges; if a search fails, magpie tries other available sources.",
help: "When a model can't search the web directly, the selected provider searches for it and returns the results. Searches may use the service's quota or incur charges; if the provider magpie picks fails, it tries other available sources, but a provider you select here is never replaced by another provider, only by your Search APIs.",
relays: "These relays must be selected manually and are not used for automatic selection or fallback: MyRelay.",
left: "These providers can't be selected to search for other models with the current configuration: MiniMax, Kimi For Coding. Their models can still get search results through other available search providers or configured search APIs.",
},
zh: {
help: "当模型无法直接联网搜索时,由所选供应商代为搜索并返回结果。代搜可能消耗所用服务的额度或产生费用;失败时会尝试其他可用来源。",
help: "当模型无法直接联网搜索时,由所选供应商代为搜索并返回结果。代搜可能消耗所用服务的额度或产生费用;magpie 自动选择的供应商失败时会尝试其他可用来源,但在此手动选中的供应商不会被换成其他供应商,只会改用你配置的搜索 API。",
relays: "以下中转服务需手动指定,不参与自动选择或自动回退:MyRelay。",
left: "以下供应商在当前配置下不可选为代搜供应商:MiniMax, Kimi For Coding。它们的模型仍可通过其他可用的代搜供应商或已配置的搜索 API 获取搜索结果。",
},
ja: {
help: "モデルが直接ウェブ検索できない場合、選択したプロバイダが代わりに検索し、結果を返します。検索にはサービスの利用枠を消費したり、料金が発生したりする場合があります。検索に失敗すると、magpie は他の利用可能な検索元を試します。",
help: "モデルが直接ウェブ検索できない場合、選択したプロバイダが代わりに検索し、結果を返します。検索にはサービスの利用枠を消費したり、料金が発生したりする場合があります。magpie が自動で選んだプロバイダが失敗すると他の利用可能な検索元を試しますが、ここで選んだプロバイダが別のプロバイダに置き換えられることはなく、設定済みの検索 API だけが代わりに使われます。",
relays: "次の中継サービスは手動で選択する必要があり、自動選択や自動フォールバックの対象にはなりません:MyRelay。",
left: "次のプロバイダは現在の設定では他のモデルの検索用に選択できません:MiniMax, Kimi For Coding。これらのモデルも、他の利用可能な検索用プロバイダや設定済みの検索 API を通じて検索結果を取得できます。",
},
de: {
help: "Wenn ein Modell nicht direkt im Web suchen kann, übernimmt der ausgewählte Anbieter die Suche und liefert die Ergebnisse. Suchen können das Kontingent des Dienstes verbrauchen oder Kosten verursachen. Schlägt eine Suche fehl, versucht magpie andere verfügbare Quellen.",
help: "Wenn ein Modell nicht direkt im Web suchen kann, übernimmt der ausgewählte Anbieter die Suche und liefert die Ergebnisse. Suchen können das Kontingent des Dienstes verbrauchen oder Kosten verursachen. Schlägt der von magpie gewählte Anbieter fehl, versucht magpie andere verfügbare Quellen; ein hier ausgewählter Anbieter wird jedoch nie durch einen anderen Anbieter ersetzt, nur durch Ihre Such-APIs.",
relays: "Diese Relays müssen manuell ausgewählt werden und werden weder automatisch noch als Fallback gewählt: MyRelay.",
left: "Diese Anbieter können mit der aktuellen Konfiguration nicht für die Suche anderer Modelle ausgewählt werden: MiniMax, Kimi For Coding. Ihre Modelle können weiterhin über andere verfügbare Suchanbieter oder konfigurierte Such-APIs Suchergebnisse erhalten.",
},
@@ -73,7 +73,7 @@ const helpWords = {
function serve(lang, posted, st) {
const settings = () => ({ lang, theme: st.theme || "light", searchVendors: [], searchAPIs: st.apis || [], searchFirst: st.first || "", searchChoices: choices,
searchAuto: "Claude · claude-haiku-4-5", searchProvider: st.searcher === "off" ? "" : st.unused || !st.searcher ? "Claude · claude-haiku-4-5" : st.searcher,
searchRelays: st.relays || ["MyRelay"], searchLeftOut: st.leftOut || ["MiniMax", "Kimi For Coding"], searcher: st.searcher, searchUnused: st.unused });
searchRelays: st.relays || ["MyRelay"], searchLeftOut: st.leftOut || ["MiniMax", "Kimi For Coding"], searcher: st.searcher, searchUnused: st.unused, searchFailed: st.failed });
return async (r) => {
const url = new URL(r.request().url());
const json = (data, status = 200) => r.fulfill({ status, json: data });
@@ -99,7 +99,69 @@ function serve(lang, posted, st) {
};
}
// The searcher picked that didn't search last time is said first in the
// row, ahead of the one-line help's ellipsis: no other provider searched in
// its place (Gearclickist on Discord: Grok picked answered without
// searching, and Codex's gpt-6-astra searched instead, unasked).
const failedWords = {
en: { notSearched: /^GPT Five Five · OpenAI didn't search .+: it answered without searching the web, so its account or plan may not offer web search\. No other provider searched in its place; pick Automatic or another provider, or add a Search API\.$/,
error: /^GPT Five Five · OpenAI didn't search .+: 400 search quota used up\. No other provider/ },
zh: { notSearched: /^GPT Five Five · OpenAI .+没能搜索:它没有联网搜索就直接回答了,它的账号或套餐可能不支持联网搜索。没有换用其他供应商代搜;可改选“自动”或其他供应商,或添加搜索 API。$/,
error: /^GPT Five Five · OpenAI .+没能搜索:400 search quota used up。/ },
"zh-TW": { notSearched: /^GPT Five Five · OpenAI .+沒能搜尋:它沒有聯網搜尋就直接回答了,它的帳號或方案可能不支援聯網搜尋。沒有換用其他供應商代搜;可改選「自動」或其他供應商,或新增搜尋 API。$/,
error: /^GPT Five Five · OpenAI .+沒能搜尋:400 search quota used up。/ },
ja: { notSearched: /^GPT Five Five · OpenAI は.+、検索できませんでした:ウェブ検索をせずに回答しました。アカウントやプランがウェブ検索に対応していない可能性があります。他のプロバイダが代わりに検索することはありません。「自動」か別のプロバイダを選ぶか、検索 API を追加してください。$/,
error: /^GPT Five Five · OpenAI は.+、検索できませんでした:400 search quota used up。/ },
de: { notSearched: /^GPT Five Five · OpenAI hat .+ nicht gesucht: es hat ohne Websuche geantwortet, daher bietet sein Konto oder Tarif möglicherweise keine Websuche\. Kein anderer Anbieter hat an seiner Stelle gesucht; wählen Sie Automatisch oder einen anderen Anbieter, oder fügen Sie eine Such-API hinzu\.$/,
error: /^GPT Five Five · OpenAI hat .+ nicht gesucht: 400 search quota used up\. Kein anderer Anbieter/ },
};
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of Object.keys(failedWords)) {
test(`${engine} ${lang}: the picked searcher that didn't search is said first`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const page = await (await browser.newContext({ reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(5000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
const posted = [];
const at = new Date(Date.now() - 5 * 60e3).toISOString();
const st = { searcher: "openai/gpt-5.5", unused: "", failed: { searcher: "openai/gpt-5.5", notSearched: true, at } };
await page.route("**/*", serve(lang, posted, st));
const w = failedWords[lang];
for (const width of [560, 1000]) {
for (const [kind, failed] of [["notSearched", { searcher: "openai/gpt-5.5", notSearched: true, at }], ["error", { searcher: "openai/gpt-5.5", why: "400 search quota used up", at }]]) {
st.failed = failed;
await page.mouse.move(0, 0);
await page.setViewportSize({ width, height: 900 });
await watchSettingsReads(page);
await page.goto("http://magpie.test/?view=settings&tab=models");
await settingsDrawn(page);
const row = page.locator("#searchList .searcher-row");
await row.waitFor();
const note = row.locator(".sub .searcher-failed");
assert.match(await note.innerText(), w[kind], `${width} ${kind}`);
const where = await row.evaluate((r) => {
const sub = r.querySelector(".sub"), n = sub.querySelector(".searcher-failed");
const a = sub.getBoundingClientRect(), b = n.getBoundingClientRect();
return { first: sub.firstChild === n, starts: b.left >= a.left - 1 && b.left < a.right && b.top < a.bottom };
});
assert(where.first && where.starts, `${width} ${kind}: ${JSON.stringify(where)}`);
}
}
// turned off, or the one named not used: no such note
st.unused = "off";
await watchSettingsReads(page);
await page.goto("http://magpie.test/?view=settings&tab=models");
await settingsDrawn(page);
await page.locator("#searchList .searcher-unused").waitFor();
assert.equal(await page.locator("#searchList .searcher-failed").count(), 0);
assert.deepEqual(posted, [], "reading the note must not change settings");
assert.deepEqual(errors, []);
});
}
for (const lang of ["en", "zh"]) {
const w = words[lang];
const h = helpWords[lang];