Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

gateway: the decision model's timeout is a setting (#2934, reyoung)

Yang Yua1cce7faa19e
diff --git a/docs/subsystems/gateway-routing.md b/docs/subsystems/gateway-routing.md
index 2a0fffd6e..4b9f72473 100644
--- a/docs/subsystems/gateway-routing.md
+++ b/docs/subsystems/gateway-routing.md
@@ -92,7 +92,8 @@ recorded as a prediction failure (`noPrediction`).
- Rules and image inputs are handled here too.
- A rule is decided as a user's turn begins and held for the rest of it (`ruleFor`, [`rules.go`](../../internal/gateway/rules.go)). What counts as the user's own words is one helper, `userWords`/`userSaid` in [`prompt.go`](../../internal/gateway/prompt.go), which the turn count (`turnIn`), the classifier's question (`userText`), the conversation's key (`firstWords`, in `ruleKey` and the affinity scope), Copilot's Auto (`lastUserText`) and the prompt breakdown's turns (`userSays`) all go by. It drops `<system-reminder …>` blocks (a `source=` attribute too) and any text that begins as an agent writes for the model alone: Codex's `<environment_context>`, `<user_instructions>`, `<turn_aborted>`, `<user_shell_command>`, `<subagent_notification>` and `# AGENTS.md instructions for …`; Claude Code's and ZCode's `<task-notification>`, `<subagent-notification>`, agent lists ("Available agent types …", "New agent types are now available …"), TodoWrite and task-tool nudges and rewind notices; ZCode's `<plugin_reference>`; the Codex app's `<in-app-browser-context …>`. The Codex app's context before `## My request (for Codex):` is dropped and what follows it kept (the `injected` list beside `agentsFor`). A user message with nothing of the user's in it (and no image or file) begins no turn: after an answer or a tool round it carries the turn on (`within`), so the turn's rule and stick hold and the classifier isn't asked; right after the user's words it leaves their turn as it began. The classifier is asked about the last user message that has words of the user's, only those words (`userText`: past 4000 runes, its first 3000 and last 1000). It is told what came before it too (`turnBefore`, @HirotaNagai on X: a short follow-up said alone, 继续 or fix that, came out the hardest kind): the user's message before it, the same way and cut to 1000 runes (`priorCap`: the first 750 and the last 250), and the assistant's last reply between the two, its text parts alone and their last 1000 runes. A tool call's arguments, a tool's result, thinking, a search's hits and the system prompt are never in either, and a reply of only tool calls is none. Jev gets them in its `state` as `previous_user_message` and `previous_assistant_reply` beside `message`, `previous_message_kind` and `previous_message_reasoning`, each only when there is one, and its intent, level and effort instructions name the ones there are (`jevState`, `priorAsk` in [`decide.go`](../../internal/gateway/decide.go)); a classifier asked in words gets them in `<previous_user_message>` and `<previous_assistant_reply>` before `<message>` (`writePrior`). Both come from the request the rules parsed, so Privacy masks them as it masks the message, and the answer kept for a message is kept for it with what came before (`classify`'s key). `TestTurnBeforeEachProtocol`, `TestTurnBeforeCuts`, `TestJevIsToldWhatCameBefore`, `TestChatClassifierIsToldWhatCameBefore`, `TestClassifyKeepsAnAnswerPerTurnBefore`, `TestJevSeesTheTurnBefore`. `firstWords` hashes the words of the first user message that has any, so an instruction file or notice the agent changes beside them doesn't move the conversation to a new key and lose its stick mid-turn (#1826: ZCode's TodoWrite nudge classified as a new, harder turn, and three keys for one ZCode session). `TestTurnInSkipsWhatTheAgentPutIn`, `TestUserTextSkipsWhatTheAgentPutIn`, `TestFirstWordsAreWhatTheUserSaid`, `TestIntentHoldsPastWhatTheAgentPutIn`.
- A rule's members go first (`ruleOver`, `applyRule`): the member it names, then those the matching rules after it name (`ruleOrder`), each not resting, then the group's others to fail over to. A member that is a group in the group is one member here: its models keep the order the group's own routing planned them, where ranking each by the group's listed order pinned a rotate group's first member on every request the rule put it first (#2407, `TestRuleNamingARotateGroupKeepsItsTurns`). That holds within the turn too, at the group's rule and at each nested group's (`nestedRules`): the one the turn stays on (affinity) stays first while it is of the rule's member that goes first, and the member's others follow it ahead of the group's others, so a failure fails over within the member the rule chose before going outside it. One the turn was kept on outside that member, which took over when the member failed, isn't held there: once one of the member is out of its rest, the turn's next request goes back to it (`Affinity.Why` `rule`). Before #1946 (XcodeFish) a held rule's order wasn't applied to a kept turn at all: a coding-quality member failing mid-turn failed over to coding-fast, the parent's first, and the turn stayed there. `TestHeldRuleFailsOverWithinItsMember`. Two groups in the group may share a model (the same provider, model and effort): it is asked once a request, where the walk met it first, and `provider.Member.Also` keeps its later places, each with its own path, `At` (its place in the walk) and Fast. A rule naming the later group has the model as that group does (`Member.In`, `membersNamed`), in that group's own order, and the nested rules below it, Fast and the first token's wait go by that group's way down (`homed`, `homeCands`). Before #2361 (davisjiahao) such a rule found none of the shared models, read unready, and the group ahead of it answered. A pause rule naming the later group still leaves a shared model to the group ahead of it. `rule_shared_test.go`.
- - A classifier that can't say which kind a turn is (an error, no answer within `classifyTimeout`, an answer that isn't a number, or resting `classifyRest` after a failure) leaves a turn whose conversation had an intent, still one of this turn's, with that intent (`Classified.Fallback` is `previous`, its `Error` kept), so the turn goes where the turn before went rather than to the group's first member; with no intent before, no rule with an intent matches, as before. The Routing page says the turn kept it (`classWhy`). The turn's decision itself (`turnRules`) is kept in memory only: after a restart a turn under way waits for the next one and the stick holds it meanwhile. `TestIntentClassifierFailsKeepsThePreviousIntent`, `routing-intent-fallback.test.cjs`.
+ - A classifier's timeout is global (`Settings.ClassifyTimeout`, JSON `classifyTimeout`, seconds, in [`settings.go`](../../internal/settings/settings.go)). Missing or 0 keeps the 8-second default; saving accepts 1–60 seconds or 0 and rejects negative values or values above 60. `Settings.ClassifyWait` bounds a hand-edited value above 60 to 60 seconds and uses the default for a value below 1. `classifyTimeout()` reads it for each call: both `askChat` in [`classify.go`](../../internal/gateway/classify.go) and `askJev` in [`decide.go`](../../internal/gateway/decide.go) give the classifier that time, including its provider's failover. Settings → Models → Replies → *Intent classifier timeout* (`renderReplies` in [`app.js`](../../internal/gui/assets/app.js)) offers 8, 15, 30 and 60 seconds and shows a custom valid value as its own choice. A change applies to the next classifier call, with no restart; the existing fallback, 30-second cooldown (`classifyRest`) and 10-minute answer cache (`classifyKeep`) still apply.
+ - A classifier that can't say which kind a turn is (an error, no answer within `classifyTimeout()`, an answer that isn't a number, or resting `classifyRest` after a failure) leaves a turn whose conversation had an intent, still one of this turn's, with that intent (`Classified.Fallback` is `previous`, its `Error` kept), so the turn goes where the turn before went rather than to the group's first member; with no intent before, no rule with an intent matches, as before. The Routing page says the turn kept it (`classWhy`). The turn's decision itself (`turnRules`) is kept in memory only: after a restart a turn under way waits for the next one and the stick holds it meanwhile. `TestIntentClassifierFailsKeepsThePreviousIntent`, `routing-intent-fallback.test.cjs`.
- The classifier's requests are magpie's own (#1839). Asked in words, they go out with `RouterAgent`'s User-Agent (`magpie-router/1`), so their records' agent is magpie and `callKind` marks them `routing`; a decision model's (Jev, System One) record is written with `Kind: "routing"` too. They go to the same key or account as any other request and count in its totals, while `usage.Group.Own` (`Record.ByMagpie`: agent `magpie` or one of its `magpie-` User-Agents, with search's and image description's) says how many of an account's, key's or model's calls, tokens and cost were magpie's own. A classifier set to a subscription's model (`modelRef.Sub`, or a group whose first member is one) asks that subscription as every turn begins, twice when it picks both intent and effort in words; the Routing page says so beside it (`classifierSub` in `plugins/routing/client.js`). `TestIntentRoutesATurn`, `TestJevPicksTheIntent`, `TestSummaryCountsMagpiesOwnCallsApart`, `TestByMagpie`, `TestServedRefSaysASubscription`, `own-requests.test.cjs`.
- A rule can set the reasoning its member is asked for (`Rule.UseEffort`, `useEffort` in the group's JSON, `use-effort=low` typed; #2633, dengtongcai: an intent picks the model and the effort as a pair). It is an output like `Use`, not a condition like `Effort`. `ruleFor` copies it onto the hit (`RuleHit.UseEffort`) from the rule that put a member first, outer or nested; `ruleOver` keeps that rule's members, and `ruleEffort` gives each candidate of them the level fitted to its model's own (`fitLevel`), which `withFixedEffort` writes into the request's field for its protocol (Chat's `reasoning_effort`, Responses' `reasoning.effort`, Anthropic's thinking budget or `output_config.effort`) even when the agent asked none. A member fixed at an effort keeps its own; otherwise the rule's beats the model's suffix, the turn's pick and the agent's pick, and isn't bounded by the group's levels. A model whose levels aren't known (`Efforts` empty) is asked as the agent asked, as with the auto verdict. The members the group fails over to are asked as the agent asked. A Gemini-protocol client's request is left as it came, as for every effort magpie sets. `cleanRules` refuses a value outside `provider.Efforts` and a pause with one. The try records it (`Try.RuleEffort`), and the Routing page says the rule set it. `rule_effort_test.go`, `grouprule_useeffort_test.go`, `routing-rule-effort.test.cjs`.
- A rule by folder (`Rule.Folders`, `folders=~/work/acme,~/oss`; Cario0x on X: routing by the project being worked on) matches when the folder the agent works in is one of them or inside one (`provider.FolderUnder`, [`rulefolder.go`](../../internal/provider/rulefolder.go)): at a path's boundary, so `/a/b` is not under `/a/bc`; `~` is the home folder; a Windows drive is one with its WSL mount (`C:\work` is `/mnt/c/work`) and a `\\wsl$\<distro>` or `\\wsl.localhost\<distro>` share is the distro's own path; case doesn't count on macOS and Windows, nor ever for a drive. A rule outside folders (`Rule.ExceptFolders`, `except-folders=~/big-task`; #1606, Ti800) matches when the folder is in none of them, and an agent that says none isn't known to be in one, so it matches; a rule may have both (`Rule.ByFolder`, `inFolders`). The folder is read from the request only when a rule of the group has folders or except-folders (`workDir` in [`workdir.go`](../../internal/gateway/workdir.go)), in each agent's own words, taken from captured requests: Claude Code's ` - Primary working directory: <path>` (its `<`/`>` as entities; ` (was <old>)` after a change dropped), Codex's `<environment_context>` `<cwd>`, Pi's `<cwd>` in the system prompt, and OpenCode's `Working directory:` inside its `<env>` block. Only the system prompt and the user's and system messages' text count, never the model's words or a tool's result, and the last said wins. An agent that says none has no folder, and no `folders=` rule matches it (unknown, never empty). The same reading tells a plugin's fetch where its agent works ([provider-plugins](provider-plugins.md#where-the-agent-works-for-a-plugins-fetch)). A pause rule may hold by folder too (below). The trace's `RuleHit.Folder` is the folder read, and the Routing page tells it beside the rule's `folder …` condition. `TestFolderUnder`, `TestRuleMatchesByFolder`, `TestParseRuleFolders`, `TestWorkDirOfEachAgent`, `TestRuleByFolder`, `TestRuleMatchesExceptFolders`, `routing-folder.test.cjs`. Rules by folder are never in a shared group (`ShareGroup` drops every `ByFolder` rule).
diff --git a/internal/gateway/classify.go b/internal/gateway/classify.go
index 5db5f4f09..41876540f 100644
--- a/internal/gateway/classify.go
+++ b/internal/gateway/classify.go
@@ -27,17 +27,29 @@ import (
"time"
"github.com/yetone/magpie/internal/provider"
+ "github.com/yetone/magpie/internal/settings"
)
// RouterAgent is the User-Agent magpie's own classifier calls carry.
const RouterAgent = "magpie-router/1"
var (
- classifyTimeout = 8 * time.Second
- classifyKeep = 10 * time.Minute // an answer, for the same message and intents
- classifyRest = 30 * time.Second // after a failure, before the classifier is asked again
+ classifyKeep = 10 * time.Minute // an answer, for the same message and intents
+ classifyRest = 30 * time.Second // after a failure, before the classifier is asked again
)
+// classifyTimeout is how long the classifier is given to answer, its
+// provider's failover included. It is Settings' Classifier timeout (#2934:
+// a Kiro subscription's haiku needed more than the 8 seconds it was fixed
+// at), read as each turn asks, in classifyUnit seconds.
+func classifyTimeout() time.Duration {
+ return settings.Shared().ClassifyWait() / time.Second * classifyUnit
+}
+
+// classifyUnit is a second of classifyTimeout: a test makes it shorter,
+// rather than wait the seconds out.
+var classifyUnit = time.Second
+
// classifier asks a model which of intents text is — the intent, or ""
// for none of them — and, when effort, how much reasoning the turn wants. prev is what
// the conversation's turn before was said to be: a message that only
@@ -447,7 +459,8 @@ func readEffort(answer string) (string, float64, error) {
// askChat sends a chat model body through the gateway and returns its
// answer's text.
func (s *Server) askChat(model string, body []byte) (string, error) {
- ctx, cancel := context.WithTimeout(context.Background(), classifyTimeout)
+ wait := classifyTimeout()
+ ctx, cancel := context.WithTimeout(context.Background(), wait)
defer cancel()
r, err := http.NewRequestWithContext(ctx, http.MethodPost, "http://magpie/v1/chat/completions", nil)
if err != nil {
@@ -458,7 +471,7 @@ func (s *Server) askChat(model string, body []byte) (string, error) {
w := httptest.NewRecorder()
s.serve(w, r, provider.Chat, body)
if ctx.Err() != nil {
- return "", fmt.Errorf("%s gave no answer in %s", model, classifyTimeout)
+ return "", fmt.Errorf("%s gave no answer in %s", model, wait)
}
var out struct {
Choices []struct {
diff --git a/internal/gateway/classify_test.go b/internal/gateway/classify_test.go
index 29bdb6c35..31744eb2c 100644
--- a/internal/gateway/classify_test.go
+++ b/internal/gateway/classify_test.go
@@ -2,6 +2,7 @@ package gateway
import (
"encoding/json"
+ "fmt"
"io"
"net/http"
"net/http/httptest"
@@ -12,6 +13,7 @@ import (
"github.com/yetone/magpie/internal/catalog"
"github.com/yetone/magpie/internal/provider"
+ "github.com/yetone/magpie/internal/settings"
"github.com/yetone/magpie/internal/usage"
)
@@ -281,9 +283,9 @@ func TestIntentClassifierFails(t *testing.T) {
t.Fatalf("rested: %s %+v", out, r.Rule)
}
// slow: past the timeout it's no answer
- was := classifyTimeout
- classifyTimeout = 200 * time.Millisecond
- t.Cleanup(func() { classifyTimeout = was })
+ was := classifyUnit
+ classifyUnit = 25 * time.Millisecond // the 8 seconds unset are 200ms
+ t.Cleanup(func() { classifyUnit = was })
c.mu.Lock()
c.wait = 2 * time.Second
c.mu.Unlock()
@@ -294,6 +296,44 @@ func TestIntentClassifierFails(t *testing.T) {
}
}
+// #2934 (aurochs-code): a Kiro subscription's haiku answered past the 8
+// seconds a classifier was given, so every turn fell back. Settings'
+// Classifier timeout gives it longer: a classifier slower than the 8
+// seconds unset routes the turn by its answer once it is given 60, and
+// one given 8 again is no answer.
+func TestClassifierTimeoutSetting(t *testing.T) {
+ was := classifyUnit
+ classifyUnit = 100 * time.Millisecond // 8 seconds are 800ms, 60 are 6s
+ t.Cleanup(func() { classifyUnit = was })
+ s, _, _, c := intented(t, provider.Rule{Use: "b/big", Intent: "refactoring"})
+ c.set("1", 0)
+ c.mu.Lock()
+ c.wait = 2 * time.Second
+ c.mu.Unlock()
+ for i, x := range []struct {
+ seconds int
+ answers bool
+ }{{0, false}, {60, true}, {8, false}} {
+ st := settings.Load()
+ st.ClassifyTimeout = x.seconds
+ if err := settings.Save(st); err != nil {
+ t.Fatal(err)
+ }
+ // a failure rests the classifier: each case asks it afresh
+ classified.Lock()
+ delete(classified.failed, "c/cls")
+ classified.Unlock()
+ out, r := postOK(t, s, fmt.Sprintf("ct%d", i), chat(fmt.Sprintf("rename package %d", i), nil, 0, ""))
+ cl := r.Rule.Classified
+ if x.answers && (!strings.Contains(out, "from kb") || r.Rule.N != 1 || cl.Intent != "refactoring" || cl.Error != "") {
+ t.Fatalf("given %ds: %s %+v %+v", x.seconds, out, r.Rule, cl)
+ }
+ if !x.answers && (!strings.Contains(out, "from ka") || r.Rule.N != 0 || !strings.Contains(cl.Error, "no answer in 800ms")) {
+ t.Fatalf("given %ds: %s %+v %+v", x.seconds, out, r.Rule, cl)
+ }
+ }
+}
+
// A classifier that fails, times out or rests on a turn whose conversation
// had an intent keeps that intent, marked as kept, rather than sending the
// turn to the group's first member (#1826: two timeouts in a row sent
diff --git a/internal/gateway/decide.go b/internal/gateway/decide.go
index 1290d3af1..8ac49e754 100644
--- a/internal/gateway/decide.go
+++ b/internal/gateway/decide.go
@@ -350,10 +350,23 @@ func (s *Server) jevLevelled(ctx context.Context, p provider.Provider, model str
return l, nil
}
+// errNoAnswer is a System One call the classifier's wait cut off; askJev
+// says which provider and how long it was given.
+var errNoAnswer = errors.New("no answer in the classifier's wait")
+
// askJev asks a decision provider's model through its System One API.
-func (s *Server) askJev(p provider.Provider, model string, intents []string, prev before, effort bool, text string) (verdict, error) {
- ctx, cancel := context.WithTimeout(context.Background(), classifyTimeout)
- defer cancel()
+func (s *Server) askJev(p provider.Provider, model string, intents []string, prev before, effort bool, text string) (v verdict, err error) {
+ wait := classifyTimeout()
+ ctx, cancel := context.WithTimeout(context.Background(), wait)
+ defer func() {
+ // only a call cut off by the wait is reworded: a refusal or an
+ // answer read as the wait ran out keeps its own type, which
+ // askDecideTries rests the account by
+ if errors.Is(err, errNoAnswer) {
+ err = fmt.Errorf("%s gave no answer in %s", p.Name, wait)
+ }
+ cancel()
+ }()
if model == "" {
model = p.Jev()
}
@@ -408,7 +421,7 @@ func (s *Server) systemOne(ctx context.Context, p provider.Provider, model strin
status, b, header, err := s.postDecide(ctx, p, model, body)
if err != nil {
if ctx.Err() != nil {
- return nil, fmt.Errorf("%s gave no answer in %s", p.Name, classifyTimeout)
+ return nil, errNoAnswer
}
return nil, err
}
diff --git a/internal/gateway/decide_test.go b/internal/gateway/decide_test.go
index 7e23cc84e..4f0dfac3c 100644
--- a/internal/gateway/decide_test.go
+++ b/internal/gateway/decide_test.go
@@ -17,6 +17,7 @@ import (
"github.com/yetone/magpie/internal/catalog"
"github.com/yetone/magpie/internal/provider"
+ "github.com/yetone/magpie/internal/settings"
"github.com/yetone/magpie/internal/usage"
)
@@ -359,6 +360,45 @@ func TestJevPicksTheIntent(t *testing.T) {
}
}
+// Jev is given Settings' Classifier timeout as the chat classifier is
+// (#2934): slower than the 8 seconds unset, its pick routes the turn once
+// it is given 60.
+func TestJevGivenTheClassifierTimeout(t *testing.T) {
+ was := classifyUnit
+ classifyUnit = 100 * time.Millisecond // 8 seconds are 800ms, 60 are 6s
+ t.Cleanup(func() { classifyUnit = was })
+ s, _, _, j := jevved(t, "", provider.Rule{Use: "b/big", Intent: "debugging"})
+ j.choice = "debugging"
+ slow := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ select {
+ case <-time.After(2 * time.Second):
+ case <-r.Context().Done():
+ return
+ }
+ j.ServeHTTP(w, r)
+ }))
+ t.Cleanup(slow.Close)
+ if err := provider.Save(provider.Provider{ID: "ts", Name: "TypeSafe", Key: "kts", Decide: slow.URL + "/v1"}); err != nil {
+ t.Fatal(err)
+ }
+ _, r := postOK(t, s, "s1", chat("why does this crash?", nil, 0, ""))
+ if r.Rule.N != 0 || !strings.Contains(r.Rule.Classified.Error, "no answer in 800ms") {
+ t.Fatalf("unset: %+v", r.Rule.Classified)
+ }
+ st := settings.Load()
+ st.ClassifyTimeout = 60
+ if err := settings.Save(st); err != nil {
+ t.Fatal(err)
+ }
+ classified.Lock()
+ delete(classified.failed, "ts/jev-latest")
+ classified.Unlock()
+ out, r := postOK(t, s, "s2", chat("why does this hang?", nil, 0, ""))
+ if !strings.Contains(out, "from kb") || r.Rule.N != 1 || r.Rule.Classified.Intent != "debugging" || r.Rule.Classified.Error != "" {
+ t.Fatalf("given 60s: %s %+v", out, r.Rule.Classified)
+ }
+}
+
// Intents that are levels (how hard a request is) leave no message out:
// Jev's answer without "none of these" counts for them, and whether they
// are is asked once for the set.
diff --git a/internal/gui/api.go b/internal/gui/api.go
index 076622f68..92fe2b6ed 100644
--- a/internal/gui/api.go
+++ b/internal/gui/api.go
@@ -1198,6 +1198,10 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {
if _, sent := fields["imageTimeout"]; !sent {
in.ImageTimeout = cur.ImageTimeout
}
+ // nor how long a routing group's classifier is given (#2934)
+ if _, sent := fields["classifyTimeout"]; !sent {
+ in.ClassifyTimeout = cur.ClassifyTimeout
+ }
in.AgentOrder, in.AgentsHidden, in.AgentsShown = cur.AgentOrder, cur.AgentsHidden, cur.AgentsShown
in.Window, in.WindowMaximised = cur.Window, cur.WindowMaximised // the window's own, as it was last resized
// and what other pages keep here: which models an agent is shown, and
diff --git a/internal/gui/api_settings_test.go b/internal/gui/api_settings_test.go
index d8cf3d6aa..92cac8a3e 100644
--- a/internal/gui/api_settings_test.go
+++ b/internal/gui/api_settings_test.go
@@ -231,6 +231,36 @@ func TestSettingsImageTimeout(t *testing.T) {
}
}
+// How long a routing group's classifier is given (#2934) is set by the
+// Settings page, 0 for the default 8 seconds, kept by a save from a page
+// that doesn't send it, and refused past 60 with the saved value kept.
+func TestSettingsClassifyTimeout(t *testing.T) {
+ h := t.TempDir()
+ t.Setenv("HOME", h)
+ t.Setenv("USERPROFILE", h)
+ t.Setenv("XDG_CONFIG_HOME", filepath.Join(h, ".config"))
+ handler := Handler(nil, nil)
+ for _, x := range []struct {
+ body string
+ code int
+ want int
+ }{
+ {`{"theme":"dark","classifyTimeout":30}`, http.StatusOK, 30},
+ {`{"theme":"light"}`, http.StatusOK, 30},
+ {`{"theme":"light","classifyTimeout":61}`, http.StatusBadRequest, 30},
+ {`{"theme":"light","classifyTimeout":0}`, http.StatusOK, 0},
+ } {
+ rec := httptest.NewRecorder()
+ handler.ServeHTTP(rec, httptest.NewRequest("POST", "/api/settings", strings.NewReader(x.body)))
+ if rec.Code != x.code {
+ t.Fatalf("%s: %d %s", x.body, rec.Code, rec.Body)
+ }
+ if got := settings.Load().ClassifyTimeout; got != x.want {
+ t.Fatalf("%s: classifyTimeout %d", x.body, got)
+ }
+ }
+}
+
func TestSettingsColorblindMode(t *testing.T) {
h := t.TempDir()
t.Setenv("HOME", h)
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index 6dcf4e69e..628d6148b 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -21268,18 +21268,19 @@ function renderImageGen(s, keep, box) {
box.append(r);
// how long a vendor is given to draw an image and send it: 5 minutes
// unless set, as a slow image endpoint needs more (neighbads on X)
- const w = el("div", "row pref");
- w.id = "imageTimeoutRow";
- const wwho = el("div", "who");
- wwho.append(el("div", "name", t("Image generation timeout")),
- el("div", "sub wraps", t("How long a provider is given to draw an image and send it, before the request is given up. A slow image endpoint may need longer")));
- const mins = [5, 10, 15, 30, 60].map((n) => [String(n), t("{n} min", { n })]);
- const m = String(s.imageTimeout > 0 ? s.imageTimeout : 5);
- if (!mins.some(([id]) => id === m)) mins.push([m, t("{n} min", { n: m })]); // set by hand in settings.json
- const wval = el("div", "val");
- wval.append(segs(mins, m, (v) => savePrefs({ ...keep, imageTimeout: Number(v) })));
- w.append(wwho, wval);
- box.append(w);
+ box.append(waitRow("imageTimeoutRow", t("Image generation timeout"), t("How long a provider is given to draw an image and send it, before the request is given up. A slow image endpoint may need longer"),
+ [5, 10, 15, 30, 60], s.imageTimeout > 0 ? s.imageTimeout : 5, "{n} min", (n) => savePrefs({ ...keep, imageTimeout: n })));
+}
+
+// waitRow: a Settings row of how long something is given, ns (in unit)
+// offered, and cur too when set by hand in settings.json
+function waitRow(id, name, sub, ns, cur, unit, pick) {
+ const r = el("div", "row pref"), who = el("div", "who"), val = el("div", "val");
+ r.id = id;
+ who.append(el("div", "name", name), el("div", "sub wraps", sub));
+ val.append(segs([...new Set([...ns, cur])].map((n) => [String(n), t(unit, { n })]), String(cur), (v) => pick(Number(v))));
+ r.append(who, val);
+ return r;
}
// mcpAddress: where one of the gateway's own MCP servers is, at path. A
@@ -21718,6 +21719,9 @@ function renderReplies(s, keep) {
fval.append(segs([...counts, ["", t("All")]], n,
(v) => savePrefs({ ...keep, refusalRetries: v === "" ? null : Number(v) })));
f.append(fwho, fval);
+ // how long a routing group's classifier is given: 8 seconds unless set (#2934)
+ const k = waitRow("classifyTimeoutRow", t("Intent classifier timeout"), t("How long a routing group's classifier is given to say which intent a turn is. The turn waits for it before it goes anywhere, and past it goes on without its answer. A slow classifier may need longer"),
+ [8, 15, 30, 60], s.classifyTimeout > 0 ? s.classifyTimeout : 8, "{n} s", (n) => savePrefs({ ...keep, classifyTimeout: n }));
// the agent's instructions as a Claude run's system prompt (off unless on)
const c = el("div", "row pref");
c.id = "claudeLeanRow";
@@ -21728,7 +21732,7 @@ function renderReplies(s, keep) {
cval.append(segs([["off", t("Off")], ["on", t("On")]], s.claudeLeanPrompt ? "on" : "off",
(v) => savePrefs({ ...keep, claudeLeanPrompt: v === "on" })));
c.append(cwho, cval);
- box.append(r, l, f, c);
+ box.append(r, l, f, k, c);
}
// renderDisabledModels: the models the user turned off for every request
@@ -23642,7 +23646,7 @@ function prefsKeep(s) {
codexWarmAts: warmTimes(s.codexWarmAts, s.codexWarmAt), claudeWarmAts: warmTimes(s.claudeWarmAts, s.claudeWarmAt), workbuddyCheckin: !!s.workbuddyCheckin, traeCheckin: !!s.traeCheckin, minimaxCheckin: !!s.minimaxCheckin, qoderCheckin: !!s.qoderCheckin, noStats: !!s.noStats, noUsageStats: !!s.noUsageStats,
memberModel: !!s.memberModel, noLoopGuard: !!s.noLoopGuard, claudeLeanPrompt: !!s.claudeLeanPrompt, refusalRetries: s.refusalRetries ?? null,
noUpdatePill: !!s.noUpdatePill, noAutoUpdate: !!s.noAutoUpdate, updateEvery: s.updateEvery || 360, autoRestart: !!s.autoRestart, noAutoDownload: !!s.noAutoDownload,
- trayUsage: s.trayUsage || "", trayUsageEvery: s.trayUsageEvery || 3, trayNoLogos: !!s.trayNoLogos, trayNoBird: !!s.trayNoBird, trayPace: !!s.trayPace, trayNoCost: !!s.trayNoCost, vision: s.vision || "", visionEffort: s.visionEffort || "", searcherEffort: s.searcherEffort || "", imageGen: s.imageGen || "", imageTimeout: s.imageTimeout || 0, searcher: s.searcher || "", searchFirst: s.searchFirst || "", currency: s.currency || "usd",
+ trayUsage: s.trayUsage || "", trayUsageEvery: s.trayUsageEvery || 3, trayNoLogos: !!s.trayNoLogos, trayNoBird: !!s.trayNoBird, trayPace: !!s.trayPace, trayNoCost: !!s.trayNoCost, vision: s.vision || "", visionEffort: s.visionEffort || "", searcherEffort: s.searcherEffort || "", imageGen: s.imageGen || "", imageTimeout: s.imageTimeout || 0, classifyTimeout: s.classifyTimeout || 0, searcher: s.searcher || "", searchFirst: s.searchFirst || "", currency: s.currency || "usd",
chineseUnits: !!s.chineseUnits, usageAlert: s.usageAlert || 0, balanceAlert: s.balanceAlert || 0, resetReminder: s.resetReminder || 0,
turnDoneAlert: s.turnDoneAlert || 0 };
}
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index abd545bd3..3c399761d 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -897,6 +897,8 @@ const I18N = {
"{model}, picked here, isn't set up any more: its provider was removed or turned off, or no longer has it. No other model draws, so a request that names no model is turned away. Pick another model here.": "这里选的 {model} 已不可用:它的服务商被删除或关闭了,或者不再提供这个模型。也没有其他能生图的模型,所以没指定模型的请求会被拒绝。请在这里另选一个模型。",
"images turned away": "带图的请求被拒绝",
"Image generation": "生图模型",
+ "Intent classifier timeout": "意图判断超时",
+ "How long a routing group's classifier is given to say which intent a turn is. The turn waits for it before it goes anywhere, and past it goes on without its answer. A slow classifier may need longer": "路由组的意图判断模型判断这一轮属于哪种意图可用的时间。这一轮要等它判断完才会发出,超过则不等它的回答直接继续。较慢的判断模型可能需要更长时间",
"Image generation timeout": "生图超时",
"How long a provider is given to draw an image and send it, before the request is given up. A slow image endpoint may need longer": "提供商生成并返回一张图可用的时间,超过即放弃这次请求。较慢的生图接口可能需要更长",
"The model Magpie Image draws with, for the agents given the Magpie Image tool; images are saved in their project": "Magpie Image 生图所用的模型,供添加了 Magpie Image 工具的 Agent 使用;图片保存在其项目目录",
@@ -4784,6 +4786,8 @@ const I18N = {
"{model}, picked here, isn't set up any more: its provider was removed or turned off, or no longer has it. No other model draws, so a request that names no model is turned away. Pick another model here.": "這裡選的 {model} 已無法使用:它的服務商被刪除或關閉了,或者不再提供這個模型。也沒有其他能生圖的模型,所以沒指定模型的請求會被拒絕。請在這裡另選一個模型。",
"images turned away": "帶圖的請求被拒絕",
"Image generation": "生圖模型",
+ "Intent classifier timeout": "意圖判斷逾時",
+ "How long a routing group's classifier is given to say which intent a turn is. The turn waits for it before it goes anywhere, and past it goes on without its answer. A slow classifier may need longer": "路由組的意圖判斷模型判斷這一輪屬於哪種意圖可用的時間。這一輪要等它判斷完才會送出,超過則不等它的回答直接繼續。較慢的判斷模型可能需要更長時間",
"Image generation timeout": "生圖逾時",
"How long a provider is given to draw an image and send it, before the request is given up. A slow image endpoint may need longer": "提供者生成並傳回一張圖可用的時間,超過即放棄這次請求。較慢的生圖端點可能需要更長",
"The model Magpie Image draws with, for the agents given the Magpie Image tool; images are saved in their project": "Magpie Image 生圖所用的模型,供新增了 Magpie Image 工具的 Agent 使用;圖片儲存在其專案目錄",
@@ -8643,6 +8647,8 @@ const I18N = {
"{model}, picked here, isn't set up any more: its provider was removed or turned off, or no longer has it. No other model draws, so a request that names no model is turned away. Pick another model here.": "ここで選んだ {model} は使えなくなっています。プロバイダーが削除またはオフにされたか、このモデルがなくなりました。画像を生成できるモデルが他にないため、モデルを指定しないリクエストは拒否されます。ここで別のモデルを選んでください。",
"images turned away": "画像付きリクエストは拒否",
"Image generation": "画像生成",
+ "Intent classifier timeout": "インテント判定のタイムアウト",
+ "How long a routing group's classifier is given to say which intent a turn is. The turn waits for it before it goes anywhere, and past it goes on without its answer. A slow classifier may need longer": "ルーティンググループの分類モデルが、このターンがどのインテントかを答えるまで待つ時間。ターンは答えを待ってから送られ、過ぎると答えなしで進みます。遅い分類モデルではもっと長く必要なことがあります",
"Image generation timeout": "画像生成のタイムアウト",
"How long a provider is given to draw an image and send it, before the request is given up. A slow image endpoint may need longer": "プロバイダーが画像を生成して送るまで待つ時間。過ぎるとリクエストは打ち切られます。遅い画像エンドポイントにはより長い時間が必要なことがあります",
"The model Magpie Image draws with, for the agents given the Magpie Image tool; images are saved in their project": "Magpie Image ツールを付与したエージェントが画像生成に使うモデルです。画像はそのプロジェクトに保存されます",
@@ -12516,6 +12522,8 @@ const I18N = {
"{model}, picked here, isn't set up any more: its provider was removed or turned off, or no longer has it. No other model draws, so a request that names no model is turned away. Pick another model here.": "{model}, hier gewählt, ist nicht mehr eingerichtet: Sein Anbieter wurde entfernt oder ausgeschaltet, oder er hat das Modell nicht mehr. Kein anderes Modell erzeugt Bilder, daher wird eine Anfrage ohne Modell abgewiesen. Wähle hier ein anderes Modell.",
"images turned away": "Bilder werden abgelehnt",
"Image generation": "Bilderzeugung",
+ "Intent classifier timeout": "Zeitlimit für den Absicht-Klassifikator",
+ "How long a routing group's classifier is given to say which intent a turn is. The turn waits for it before it goes anywhere, and past it goes on without its answer. A slow classifier may need longer": "Wie lange der Klassifikator einer Routing-Gruppe Zeit hat zu sagen, welche Absicht eine Runde hat. Die Runde wartet darauf, bevor sie irgendwohin geht, und danach geht sie ohne seine Antwort weiter. Ein langsamer Klassifikator braucht vielleicht länger",
"Image generation timeout": "Zeitlimit für Bilderzeugung",
"How long a provider is given to draw an image and send it, before the request is given up. A slow image endpoint may need longer": "Wie lange ein Anbieter Zeit hat, ein Bild zu zeichnen und zu senden, bevor die Anfrage aufgegeben wird. Ein langsamer Bild-Endpunkt braucht unter Umständen länger",
"The model Magpie Image draws with, for the agents given the Magpie Image tool; images are saved in their project": "Das Modell, mit dem Magpie Image für Agenten mit dem Magpie-Image-Tool zeichnet; Bilder werden in ihrem Projekt gespeichert",
diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.go
index d53502151..1cc138c03 100644
--- a/internal/gui/core_budget_test.go
+++ b/internal/gui/core_budget_test.go
@@ -15,8 +15,8 @@ import (
// so a page can't quietly grow back into the core; a change that needs more
// raises them and says why in its commit.
const (
- appScriptBudget = 1_337_000 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397); 1,269,083 with Free first's option in the provider editor's ROUTINGS, which the Routing page reads too, plus 1.5%; 1,272,726 with the Providers page drawing its last list at once (#1519), the core's page, and the Routing trace's account names read without Object.entries (#1481), plus 1.5%; a dialog growing out of the row that opened it and folding back into it, the core's own since every page's dialogs open through it (10-20); Codex's and Claude Code's own settings moved from Settings into the agent's row on the Agents page, the core's own since the tray panel and the window both draw them (10-20); 1,314,432 with Settings › Privacy's record of what was masked (its summary, the records view and the local model's controls), which belongs to Settings, the core's own, plus 1.5%; 1,336,481 with a provider's Names & levels saying Provider in model names is Settings' and opening it there (joe), and Settings' Image recognition saying where a custom provider's model is marked (nexnull), both in the core's own pages, with no room added (10-23)
- coreScriptBudget = 1_528_800 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%
+ appScriptBudget = 1_337_633 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397); 1,269,083 with Free first's option in the provider editor's ROUTINGS, which the Routing page reads too, plus 1.5%; 1,272,726 with the Providers page drawing its last list at once (#1519), the core's page, and the Routing trace's account names read without Object.entries (#1481), plus 1.5%; a dialog growing out of the row that opened it and folding back into it, the core's own since every page's dialogs open through it (10-20); Codex's and Claude Code's own settings moved from Settings into the agent's row on the Agents page, the core's own since the tray panel and the window both draw them (10-20); 1,314,432 with Settings › Privacy's record of what was masked (its summary, the records view and the local model's controls), which belongs to Settings, the core's own, plus 1.5%; 1,336,481 with a provider's Names & levels saying Provider in model names is Settings' and opening it there (joe), and Settings' Image recognition saying where a custom provider's model is marked (nexnull), both in the core's own pages, with no room added (10-23); 1,337,633 with Settings › Models › Replies' Intent classifier timeout (#2934, reyoung), Settings' own row, drawn by waitRow, which the Image generation timeout's row now shares, with no room added
+ coreScriptBudget = 1_529_393 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added
)
func TestCoreScriptBudget(t *testing.T) {
diff --git a/internal/gui/tests/classify-timeout-setting.test.cjs b/internal/gui/tests/classify-timeout-setting.test.cjs
new file mode 100644
index 000000000..faa4b3f8f
--- /dev/null
+++ b/internal/gui/tests/classify-timeout-setting.test.cjs
@@ -0,0 +1,137 @@
+// Settings > Models > Replies: #2934 gives every routing classifier the
+// selected timeout. Checks saving, other preferences, custom values,
+// translations, narrow layouts and scroll position in both engines.
+const assert = require("node:assert/strict");
+const fs = require("node:fs/promises");
+const path = require("node:path");
+const { test } = require("node:test");
+const { chromium, webkit } = require("playwright");
+const { reach, watchSettingsReads, settingsDrawn } = require("./reader.cjs");
+
+const assets = path.resolve(__dirname, "../assets");
+const words = {
+ en: { name: "Intent classifier timeout", head: "Replies", sec: (n) => `${n} s`, sub: "A slow classifier may need longer" },
+ zh: { name: "意图判断超时", head: "回复", sec: (n) => `${n} 秒`, sub: "较慢的判断模型可能需要更长时间" },
+ "zh-TW": { name: "意圖判斷逾時", head: "回覆", sec: (n) => `${n} 秒`, sub: "較慢的判斷模型可能需要更長時間" },
+ ja: { name: "インテント判定のタイムアウト", head: "応答", sec: (n) => `${n} 秒`, sub: "遅い分類モデル" },
+ de: { name: "Zeitlimit für den Absicht-Klassifikator", head: "Antworten", sec: (n) => `${n} s`, sub: "Ein langsamer Klassifikator" },
+};
+
+function serve(lang, saved, own) {
+ const settings = { lang, theme: "light", redact: true, imageGen: "off", ...own };
+ const state = { agents: [], profiles: [], settings };
+ return async (r) => {
+ const url = new URL(r.request().url());
+ const json = (data) => r.fulfill({ json: data });
+ if (url.pathname === "/boot.js") return r.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
+ if (url.pathname === "/wails/runtime.js") return r.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
+ if (url.pathname === "/api/state") return json(state);
+ if (url.pathname === "/api/settings") {
+ if (r.request().method() === "POST") {
+ saved.push(JSON.parse(r.request().postData()));
+ Object.assign(settings, saved.at(-1));
+ }
+ return json(settings);
+ }
+ if (url.pathname === "/api/groups") return json({ models: [], groups: [], pools: [] });
+ if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true, url: "http://127.0.0.1:3999" } });
+ if (url.pathname.startsWith("/api/")) return json({});
+ const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
+ const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
+ await r.fulfill({ body: await fs.readFile(file), contentType });
+ };
+}
+
+async function open(engine, lang, width, saved, own, t) {
+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
+ t.after(() => browser.close());
+ const page = await (await browser.newContext({ viewport: { width, height: 900 } })).newPage();
+ page.setDefaultTimeout(5000);
+ const errors = [];
+ page.on("pageerror", (e) => errors.push(e.message));
+ await page.route("**/*", serve(lang, saved, own));
+ await watchSettingsReads(page);
+ await page.goto("http://magpie.test/?view=settings&tab=models");
+ await settingsDrawn(page); // rows found are the ones that stay (#1659)
+ const row = page.locator("#replyList #classifyTimeoutRow");
+ await row.waitFor();
+ return { page, row, errors };
+}
+
+for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
+ for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) for (const width of [1100, 420]) {
+ const w = words[lang];
+ test(`${engine} ${lang} ${width}: how long a classifier is given to answer`, async (t) => {
+ const saved = [];
+ const { page, row, errors } = await open(engine, lang, width, saved, {}, t);
+ // scrolled to as a reader does, with the wheel
+ await page.mouse.move(width / 2, 450);
+ for (let i = 0; i < 40; i++) {
+ const box = await row.boundingBox();
+ if (box && box.y >= 0 && box.y + box.height <= 900) break;
+ await page.mouse.wheel(0, 120);
+ await page.waitForTimeout(50);
+ }
+ assert.equal(await row.locator(".name").textContent(), w.name);
+ assert((await row.locator(".sub").textContent()).includes(w.sub));
+ for (const part of [".name", ".sub", ".segs"]) {
+ const fit = await row.locator(part).first().evaluate((e) => {
+ const r = e.getBoundingClientRect();
+ return e.scrollWidth <= e.clientWidth + 1 && r.width > 0 && r.right <= innerWidth + 1;
+ });
+ assert(fit, `${part} fits at ${width}`);
+ }
+ assert.equal(await page.locator("#replyList").evaluate((l) => l.previousElementSibling.textContent.trim()), w.head);
+ assert.deepEqual(await row.locator(".segs button").allTextContents(), [8, 15, 30, 60].map(w.sec));
+ assert.equal(await row.locator(".segs button[aria-pressed=true]").textContent(), w.sec(8), "8 s at first");
+
+ const at = () => page.evaluate(() => [scrollX, scrollY, document.querySelector("#classifyTimeoutRow").closest(".view").scrollTop]);
+ const moved = [];
+ const click = async (name) => {
+ const button = row.locator(".segs button", { hasText: new RegExp(`^${name}$`) });
+ await reach(page, button);
+ let before = await at();
+ for (let i = 0; i < 40; i++) {
+ await page.waitForTimeout(100);
+ const now = await at();
+ if (JSON.stringify(now) === JSON.stringify(before)) break;
+ before = now;
+ }
+ const b = await button.boundingBox();
+ await page.mouse.click(b.x + b.width / 2, b.y + b.height / 2);
+ await page.waitForTimeout(100);
+ const after = await at();
+ if (JSON.stringify(after) !== JSON.stringify(before)) moved.push(`${name}: ${before} → ${after}`);
+ };
+ await row.evaluate((e) => { e.dataset.before = "1"; });
+ await click(w.sec(30));
+ for (let i = 0; i < 200 && !saved.length; i++) await page.waitForTimeout(50);
+ assert.equal(saved.length, 1, "saved once");
+ assert.equal(saved[0].classifyTimeout, 30);
+ assert.equal(saved[0].imageGen, "off", "image preferences kept");
+ assert.equal(saved[0].redact, true, "the rest kept");
+ assert.equal(saved[0].lang, lang);
+ await page.waitForFunction((m) => {
+ const r = document.querySelector("#classifyTimeoutRow");
+ return r && !r.dataset.before && r.querySelector(".segs button[aria-pressed=true]")?.textContent === m;
+ }, w.sec(30), { timeout: 10000 });
+ await click(w.sec(8));
+ for (let i = 0; i < 200 && saved.length < 2; i++) await page.waitForTimeout(50);
+ assert.equal(saved.length, 2, `saved again: ${JSON.stringify(saved)}`);
+ assert.equal(saved[1].classifyTimeout, 8);
+ assert.deepEqual(moved, [], "the click moved nothing");
+ assert.deepEqual(errors, []);
+ });
+ }
+ test(`${engine}: seconds set by hand show as their own choice, and are sent on with other saves`, async (t) => {
+ const saved = [];
+ const { page, row, errors } = await open(engine, "en", 1100, saved, { classifyTimeout: 45 }, t);
+ assert.deepEqual(await row.locator(".segs button").allTextContents(), ["8 s", "15 s", "30 s", "60 s", "45 s"]);
+ assert.equal(await row.locator(".segs button[aria-pressed=true]").textContent(), "45 s");
+ // another row's save keeps the seconds
+ await page.evaluate(() => savePrefs({ ...prefsKeep(prefs), redact: false }));
+ for (let i = 0; i < 200 && !saved.length; i++) await page.waitForTimeout(50);
+ assert.equal(saved[0].classifyTimeout, 45, JSON.stringify(saved));
+ assert.deepEqual(errors, []);
+ });
+}
diff --git a/internal/settings/classify_timeout_test.go b/internal/settings/classify_timeout_test.go
new file mode 100644
index 000000000..025041e65
--- /dev/null
+++ b/internal/settings/classify_timeout_test.go
@@ -0,0 +1,40 @@
+package settings
+
+import (
+ "testing"
+ "time"
+)
+
+// Settings' Classifier timeout (#2934: a Kiro subscription's haiku needed
+// more than 8 seconds) is kept from 1 to 60 seconds, and 0, which is what
+// a settings.json without it reads as, is the 8 a classifier was always
+// given.
+func TestClassifyTimeoutKeptAndBounded(t *testing.T) {
+ t.Setenv("XDG_CONFIG_HOME", t.TempDir())
+ if w := Load().ClassifyWait(); w != 8*time.Second {
+ t.Fatalf("unset: %v", w)
+ }
+ for _, n := range []int{1, 30, 60} {
+ if err := Save(Settings{ClassifyTimeout: n}); err != nil {
+ t.Fatalf("%d: %v", n, err)
+ }
+ if s := Load(); s.ClassifyTimeout != n || s.ClassifyWait() != time.Duration(n)*time.Second {
+ t.Fatalf("%d read back as %d, %v", n, s.ClassifyTimeout, s.ClassifyWait())
+ }
+ }
+ for _, n := range []int{-1, 61, 600} {
+ if Save(Settings{ClassifyTimeout: n}) == nil {
+ t.Fatalf("%d seconds accepted", n)
+ }
+ }
+ if Load().ClassifyTimeout != 60 {
+ t.Fatal("a refused value overwrote the saved one")
+ }
+ // a settings.json written by hand past the bounds still waits within them
+ if w := (Settings{ClassifyTimeout: 600}).ClassifyWait(); w != time.Minute {
+ t.Fatalf("600 waits %v", w)
+ }
+ if w := (Settings{ClassifyTimeout: -3}).ClassifyWait(); w != 8*time.Second {
+ t.Fatalf("-3 waits %v", w)
+ }
+}
diff --git a/internal/settings/settings.go b/internal/settings/settings.go
index c0a716840..89456f1e7 100644
--- a/internal/settings/settings.go
+++ b/internal/settings/settings.go
@@ -340,6 +340,11 @@ type Settings struct {
// than 5): from 1 to ImageTimeoutMost, 0 for ImageTimeoutDefault.
// ImageWait reads it.
ImageTimeout int `json:"imageTimeout,omitempty"`
+ // ClassifyTimeout is how long, in seconds, a routing group's classifier
+ // is given to say which intent a turn is (#2934: a Kiro subscription's
+ // haiku needed more than 8): from 1 to ClassifyTimeoutMost, 0 for
+ // ClassifyTimeoutDefault. ClassifyWait reads it.
+ ClassifyTimeout int `json:"classifyTimeout,omitempty"`
// Searcher is the provider that searches the web for a model that
// can't: "<provider>" with the small model magpie picks of it,
// "<provider>/<model>", or empty for the one magpie picks
@@ -876,6 +881,27 @@ func (s Settings) ImageWait() time.Duration {
return time.Duration(min(m, ImageTimeoutMost)) * time.Minute
}
+// ClassifyTimeoutDefault is the seconds a classifier is given when
+// ClassifyTimeout is 0, and ClassifyTimeoutMost the most it can be set to:
+// the turn waits on it before it goes anywhere, with nothing sent to its
+// agent meanwhile.
+const (
+ ClassifyTimeoutDefault = 8
+ ClassifyTimeoutMost = 60
+)
+
+// ClassifyWait is how long a classifier is given to answer:
+// ClassifyTimeout's seconds, ClassifyTimeoutDefault's when it is 0 (or
+// below), and no more than ClassifyTimeoutMost's when settings.json was
+// written by hand past it.
+func (s Settings) ClassifyWait() time.Duration {
+ n := s.ClassifyTimeout
+ if n < 1 {
+ n = ClassifyTimeoutDefault
+ }
+ return time.Duration(min(n, ClassifyTimeoutMost)) * time.Second
+}
+
// Themes and Langs are the accepted values, in the order the UI offers them.
var (
Themes = []string{"system", "light", "dark"}
@@ -1392,6 +1418,9 @@ func save(s Settings, recording bool) error {
if s.ImageTimeout < 0 || s.ImageTimeout > ImageTimeoutMost {
return fmt.Errorf("image generation is given from 1 to %d minutes, or 0 for %d, not %d", ImageTimeoutMost, ImageTimeoutDefault, s.ImageTimeout)
}
+ if s.ClassifyTimeout < 0 || s.ClassifyTimeout > ClassifyTimeoutMost {
+ return fmt.Errorf("a routing group's classifier is given from 1 to %d seconds, or 0 for %d, not %d", ClassifyTimeoutMost, ClassifyTimeoutDefault, s.ClassifyTimeout)
+ }
if s.UsageAlert < 0 || s.UsageAlert > 100 {
return fmt.Errorf("a usage alert is at a percentage from 1 to 100, or 0 for off, not %d", s.UsageAlert)
}
diff --git a/site/public/docs/intent.html b/site/public/docs/intent.html
index 225b37f0a..b8ffaee48 100644
--- a/site/public/docs/intent.html
+++ b/site/public/docs/intent.html
@@ -106,6 +106,7 @@
<li><b>Pick the classifier</b><span class="ui">Intent told by</span> appears once a rule has an intent, set to Jev when you have a TypeSafe provider. Otherwise choose a small, fast model without reasoning. A group whose effort Jev already picks offers the same under its classifier: <span class="ui">It can pick the model too</span>. A group can’t be saved with an intent and no classifier.</li>
<li><b>Save, and send a message</b>Changes apply from the next turn, with no restart. The <span class="ui">Routing</span> tab shows what the classifier said and where the turn went.</li>
</ol>
+ <p id="timeout">The timeout is global: in <span class="ui">Settings → Models → Replies → Intent classifier timeout</span>, choose 8, 15, 30 or 60 seconds. It defaults to 8 seconds and applies to the next classifier call, including Jev, with no restart. A slow classifier may need longer, but the turn waits for it before routing. In <code>~/.config/magpie/settings.json</code>, <code>"classifyTimeout"</code> accepts whole seconds from 1 to 60; 0 or a missing field uses 8. A custom value in that range appears as its own choice in Settings.</p>
<p>The same from a terminal:</p>
<div class="code">
<span class="lang">Terminal</span>
@@ -127,7 +128,7 @@ magpie group rule rm coder 2</pre>
<ol class="steps">
<li><b>Is this a new turn?</b>magpie looks at the request’s last user message. If it carries text or an image and no tool result, you just spoke, so a new turn begins. If it carries tool results, the agent is continuing a turn already under way (see <a href="#turn">The rest of the turn</a>). Turns are counted per conversation. A subagent is its own conversation: it shares its agent’s session but starts with different words.</li>
<li><b>Which intents could decide?</b>magpie walks the rules top first and ignores intent for now: a rule is a candidate if its other conditions (tokens, images, reasoning, agents) hold for this request. Each candidate’s intent is collected, and duplicates spelled the same apart from case count once. The walk stops at the first candidate <em>without</em> an intent, because that rule matches outright and nothing below it could come first. If no intents were collected, the classifier isn’t asked and costs nothing.</li>
- <li><b>Ask the classifier</b>magpie sends the classifier the collected intents and the text of your message. The exact prompt is shown <a href="#prompt">below</a>. The call goes through magpie’s own gateway, like a request from an agent, so it uses that model’s provider with its keys or accounts and their failover. It has 8 seconds to answer.</li>
+ <li><b>Ask the classifier</b>magpie sends the classifier the collected intents and the text of your message. The exact prompt is shown <a href="#prompt">below</a>. The call goes through magpie’s own gateway, like a request from an agent, so it uses that model’s provider with its keys or accounts and their failover. It has the <a href="#timeout">configured timeout</a> to answer (8 seconds by default).</li>
<li><b>Read the answer</b>magpie takes the first whole number in the reply. <code>1</code> to <code>n</code> names that intent, and <code>0</code> means none of them. Anything else, such as no number or one out of range, counts as a failure. The answer is kept for 10 minutes for the same message and intents.</li>
<li><b>Match the rules</b>The rules are checked top first with the answer. A rule with an intent matches only when the classifier named its intent, compared without case, and all its other conditions hold. The first rule that matches wins. If none matches, the group routes the turn as it always does.</li>
<li><b>Order the models</b>The winning rule’s model goes first, and the group’s other models follow in their usual order as failover. This holds even if another model answered the conversation’s last turn: a rule outranks the <span class="ui">Stays</span> setting as a turn begins. If the rule’s model has nothing ready right now (every key resting, the provider off), the group’s usual order stands and the trace says so.</li>
@@ -188,10 +189,10 @@ The number of its kind (0 for none):</pre>
<div class="table-wrap"><table class="loose">
<tr><th>What happens</th><th>What magpie does</th></tr>
<tr><td>It answers <code>0</code></td><td>No intent matches. Rules without an intent and the group’s usual order decide.</td></tr>
- <tr><td>No answer within 8 s</td><td>Treated as a failure: no intent matches, and the turn goes on at once.</td></tr>
- <tr><td>An error (quota, 5xx, bad key)</td><td>Its provider’s own failover is tried first, within the 8 s. If it still fails, no intent matches.</td></tr>
+ <tr><td>No answer within the configured timeout</td><td>Treated as a failure: no intent matches, and the turn goes on at once.</td></tr>
+ <tr><td>An error (quota, 5xx, bad key)</td><td>Its provider’s own failover is tried first, within the configured timeout. If it still fails, no intent matches.</td></tr>
<tr><td>An answer that isn’t a number from 0 to n</td><td>No intent matches this turn. The classifier did answer, so it isn’t rested: the next turn asks it again.</td></tr>
- <tr><td>An error or the 8 s timeout</td><td>That classifier model is left alone for 30 s: turns in that time don’t wait on it, and the trace says it wasn’t asked. The first good answer clears this.</td></tr>
+ <tr><td>An error or a timeout</td><td>That classifier model is left alone for 30 s: turns in that time don’t wait on it, and the trace says it wasn’t asked. The first good answer clears this.</td></tr>
<tr><td>The message has no words</td><td>Not asked. No intent matches.</td></tr>
</table></div>
<p>Each case is written in the turn’s trace with the reason. An intent rule can therefore make a turn go to a different model than you hoped, but it can’t make it fail.</p>
@@ -230,7 +231,7 @@ The number of its kind (0 for none):</pre>
<h2 id="cost"><a class="anchor" href="#cost">Latency, cost, privacy</a></h2>
<ul>
- <li><b>Latency.</b> Only the first request of a turn waits for the classifier, typically a few hundred milliseconds on a fast provider (323 ms in the screenshot) and never more than 8 seconds. Tool rounds within the turn, turns where no intent could decide, and cached answers add nothing.</li>
+ <li><b>Latency.</b> Only the first request of a turn waits for the classifier, typically a few hundred milliseconds on a fast provider (323 ms in the screenshot) with a configured timeout of 8 seconds by default. Tool rounds within the turn, turns where no intent could decide, and cached answers add nothing.</li>
<li><b>Cost.</b> One short call per turn: roughly the size of your message plus the intents in, and one or two tokens out. In the example above that was 212 tokens in and 1 out. With a subscription model as the classifier, these calls count against that subscription’s limits.</li>
<li><b>Privacy.</b> The text of your message (up to about 4,000 characters) goes to the classifier’s provider. To keep it on your machine, use a local model from Ollama or LM Studio as the classifier. magpie keeps only a hash of the message and the answer, in memory, for 10 minutes. The message itself isn’t stored or logged.</li>
</ul>
@@ -243,13 +244,13 @@ The number of its kind (0 for none):</pre>
<li><b>Order still matters.</b> Only the first matching rule counts, so put a rule that must win (such as a long-context rule) above the intent rules. The classifier is then skipped whenever that rule holds.</li>
<li><b>“None” is a real answer.</b> A turn that fits no intent goes to the group’s usual order, so let that order be your default choice.</li>
<li><b>Any language.</b> Intents and messages can be in any language the classifier understands. The fixed prompt is in English, and small models read mixed languages well.</li>
- <li><b>Choosing a classifier.</b> Pick a small, fast model without reasoning: Llama 3.1 8B on Groq, a Flash-Lite, nano or mini model, Claude Haiku, DeepSeek’s non-reasoning chat model, or a local model. A reasoning model is slower; magpie asks it for its least reasoning and leaves it 2048 tokens, but a slow one can still miss the 8 s. Check the trace for a few turns: if it guesses wrong, rewrite the intents before switching models.</li>
+ <li><b>Choosing a classifier.</b> Pick a small, fast model without reasoning: Llama 3.1 8B on Groq, a Flash-Lite, nano or mini model, Claude Haiku, DeepSeek’s non-reasoning chat model, or a local model. A reasoning model is slower; magpie asks it for its least reasoning and leaves it 2048 tokens, but a slow one can still miss the configured timeout. Check the trace for a few turns: if it guesses wrong, rewrite the intents before switching models.</li>
</ul>
<h2 id="limits"><a class="anchor" href="#limits">Numbers</a></h2>
<div class="table-wrap"><table class="loose">
<tr><th>What</th><th>Value</th></tr>
- <tr><td>Classifier timeout</td><td>8 s, including its provider’s failover</td></tr>
+ <tr><td>Classifier timeout</td><td>8 s by default; configurable from 1 to 60 s, including its provider’s failover</td></tr>
<tr><td>Rest after a failure</td><td>30 s, per classifier model</td></tr>
<tr><td>Answer cache</td><td>10 min, per classifier + intents + message; in memory</td></tr>
<tr><td>Turn decisions kept</td><td>24 h after the conversation’s last request; in memory</td></tr>
@@ -274,7 +275,7 @@ The number of its kind (0 for none):</pre>
<p>Only in two cases: the model it is on fails and another member takes over, or the conversation outgrows the model’s context and a rule sends it to one with more room. Intent is never re-asked mid-turn.</p>
<h3>What if the classifier is down or slow?</h3>
- <p>The turn still goes through. After up to 8 s, no intent matches and the group’s other rules and order decide. For the next 30 s magpie doesn’t ask that classifier again, so turns don’t each wait out the timeout. The trace gives the reason.</p>
+ <p>The turn still goes through. After waiting up to the configured timeout (8 s by default), no intent matches and the group’s other rules and order decide. For the next 30 s magpie doesn’t ask that classifier again, so turns don’t each wait out the timeout. The trace gives the reason.</p>
<h3>Why did the turn not go to the rule’s model when the classifier named its intent?</h3>
<p>Check the trace. The usual causes are:</p>
@@ -296,9 +297,9 @@ The number of its kind (0 for none):</pre>
<p>It can’t be a group: it must be one model, <code>provider/model</code>, which magpie checks when you save. It can be any model magpie has, including one of the group’s members, a subscription model or a local model.</p>
<h3>Can I use a reasoning model?</h3>
- <p>Yes, if it answers within 8 s. magpie asks it for the least reasoning it has (<code>none</code>, else its lowest level) and leaves 2048 tokens, so thinking doesn’t crowd out the answer. A small, fast model is still the better choice: cheaper, and every turn waits for it.</p>
+ <p>Yes, if it answers within the configured timeout (8 s by default). magpie asks it for the least reasoning it has (<code>none</code>, else its lowest level) and leaves 2048 tokens, so thinking doesn’t crowd out the answer. A small, fast model is still the better choice: cheaper, and every turn waits for it.</p>
<h3>How well does it work with real models?</h3>
- <p>We ran 20 real coding messages (English and Chinese: quick questions, test work, and ordinary coding tasks, including “Fix the bug in parseTokens and add a test for it”) through a group with two intent rules. DeepSeek V4 Flash, GLM-5.3 Flash and MiMo v2.6 Flash each classified all 20 correctly; the median classifier time was 0.75 s, 1.3 s and 1.9 s. Gemini 3.8 Flash through one reseller took 11 s even at <code>low</code> reasoning, so every turn timed out and routed as if there were no intents — the trace said so each time. That is the pattern to expect: a wrong classifier costs you the routing, never the turn.</p>
+ <p>We ran 20 real coding messages (English and Chinese: quick questions, test work, and ordinary coding tasks, including “Fix the bug in parseTokens and add a test for it”) through a group with two intent rules. DeepSeek V4 Flash, GLM-5.3 Flash and MiMo v2.6 Flash each classified all 20 correctly; the median classifier time was 0.75 s, 1.3 s and 1.9 s. Gemini 3.8 Flash through one reseller took 11 s even at <code>low</code> reasoning, so with the default 8 s timeout every turn timed out and routed as if there were no intents — the trace said so each time. That is the pattern to expect: a wrong classifier costs you the routing, never the turn.</p>
<h3>Does retrying the same message ask again?</h3>
<p>Not within 10 minutes: the same message with the same intents and the same classifier is answered from the cache, and the trace says “said before”. Changing an intent or the classifier makes it ask again.</p>
diff --git a/site/public/docs/ja/intent.html b/site/public/docs/ja/intent.html
index 35e7e8565..de4fa710e 100644
--- a/site/public/docs/ja/intent.html
+++ b/site/public/docs/ja/intent.html
@@ -106,6 +106,7 @@
<li><b>判定モデルを選ぶ</b>ルールにインテントが付くと <span class="ui">Intent told by</span> が表示されます。TypeSafe プロバイダーがあれば Jev が選ばれ、なければ推理なしの、小さく速いモデルを選んでください。推論の強さをすでに Jev が選んでいるグループでは、判定モデルの下に同じ入口(<span class="ui">It can pick the model too</span>)があります。インテントがあって判定モデルがないグループは保存できません。</li>
<li><b>保存して、メッセージを送る</b>変更は次のターンから反映され、再起動は不要です。<span class="ui">Routing</span> タブに、判定モデルの答えとターンの行き先が表示されます。</li>
</ol>
+ <p id="timeout">タイムアウトは全体で共通です。<span class="ui">設定 → モデル → 応答 → インテント判定のタイムアウト</span> で 8・15・30・60 秒から選べます。既定は 8 秒で、Jev を含め次の判定呼び出しから反映され、再起動は不要です。遅い判定モデルには長めの時間が必要なこともありますが、ターンは判定を待ってからルーティングされます。<code>~/.config/magpie/settings.json</code> の <code>"classifyTimeout"</code> には 1〜60 の整数秒を指定でき、0 または未設定なら 8 秒です。範囲内の独自の値は、設定に専用の選択肢として表示されます。</p>
<p>ターミナルからも同じことができます。</p>
<div class="code">
<span class="lang">Terminal</span>
@@ -127,7 +128,7 @@ magpie group rule rm coder 2</pre>
<ol class="steps">
<li><b>新しいターンか?</b>magpie はリクエストの最後のユーザーメッセージを見ます。テキストか画像があり、ツール結果がなければ、あなたが発言したばかりなので新しいターンが始まります。ツール結果があれば、エージェントが進行中のターンを続けています(<a href="#turn">ターンの残り</a>を参照)。ターンは会話ごとに数えます。サブエージェントは独立した会話です。エージェントとセッションを共有しますが、最初の言葉が異なります。</li>
<li><b>どのインテントが決め手になりうるか?</b>magpie はインテントをいったん無視して、ルールを上から順にたどります。インテント以外の条件(トークン数・画像・推理・エージェント)がこのリクエストで満たされるルールが候補です。各候補のインテントを集め、大文字小文字の違いだけの重複は 1 つとして数えます。インテントの<em>ない</em>候補に当たった時点でたどるのをやめます。そのルールは無条件で一致し、それより下のルールが先に来ることはないからです。インテントが 1 つも集まらなければ、判定モデルには問い合わせず、費用もかかりません。</li>
- <li><b>判定モデルに問い合わせる</b>集めたインテントとあなたのメッセージのテキストを判定モデルに送ります。正確なプロンプトは<a href="#prompt">後述</a>します。この呼び出しはエージェントからのリクエストと同じく magpie のゲートウェイを通るので、そのモデルのプロバイダのキーやアカウント、そのフェイルオーバーが使われます。回答の制限時間は 8 秒です。</li>
+ <li><b>判定モデルに問い合わせる</b>集めたインテントとあなたのメッセージのテキストを判定モデルに送ります。正確なプロンプトは<a href="#prompt">後述</a>します。この呼び出しはエージェントからのリクエストと同じく magpie のゲートウェイを通るので、そのモデルのプロバイダのキーやアカウント、そのフェイルオーバーが使われます。回答には<a href="#timeout">設定したタイムアウト</a>が適用されます(既定は 8 秒)。</li>
<li><b>答えを読む</b>magpie は返答の中で最初に出てくる整数を取ります。<code>1</code> から <code>n</code> はそのインテントを、<code>0</code> はどれでもないことを表します。数字がない、範囲外など、それ以外はすべて失敗として扱います。答えは同じメッセージとインテントに対して 10 分間保持されます。</li>
<li><b>ルールを照合する</b>その答えでルールを上から順に照合します。インテント付きのルールは、判定モデルがそのインテントを(大文字小文字を区別せず)挙げ、かつほかの条件もすべて満たすときだけ一致します。最初に一致したルールが採用されます。どれも一致しなければ、グループはいつもどおりにターンをルーティングします。</li>
<li><b>モデルを並べる</b>採用されたルールのモデルが先頭になり、グループのほかのモデルはいつもの順でフェイルオーバーとして続きます。会話の前のターンに別のモデルが答えていても同じです。ターンの始まりでは、ルールが <span class="ui">Stays</span> 設定より優先されます。ルールのモデルにいま使えるものがない場合(キーがすべて休止中、プロバイダがオフなど)は、グループのいつもの順のままとなり、トレースにそう記録されます。</li>
@@ -188,10 +189,10 @@ The number of its kind (0 for none):</pre>
<div class="table-wrap"><table class="loose">
<tr><th>起きたこと</th><th>magpie の動き</th></tr>
<tr><td><code>0</code> と答えた</td><td>どのインテントも一致しません。インテントのないルールとグループのいつもの順で決まります。</td></tr>
- <tr><td>8 秒以内に答えがない</td><td>失敗として扱います。どのインテントも一致せず、ターンはすぐに進みます。</td></tr>
- <tr><td>エラー(クォータ、5xx、無効なキー)</td><td>まず 8 秒の範囲内で、そのプロバイダ自身のフェイルオーバーを試します。それでも失敗すれば、どのインテントも一致しません。</td></tr>
+ <tr><td>設定したタイムアウト内に答えがない</td><td>失敗として扱います。どのインテントも一致せず、ターンはすぐに進みます。</td></tr>
+ <tr><td>エラー(クォータ、5xx、無効なキー)</td><td>まず設定したタイムアウトの範囲内で、そのプロバイダ自身のフェイルオーバーを試します。それでも失敗すれば、どのインテントも一致しません。</td></tr>
<tr><td>0 から n の番号ではない答え</td><td>このターンではどのインテントも一致しません。判定モデルは答えてはいるので休止させず、次のターンでまた問い合わせます。</td></tr>
- <tr><td>エラーまたは 8 秒のタイムアウト</td><td>その判定モデルは 30 秒間使いません。その間のターンは判定モデルを待たず、トレースには問い合わせなかったと記録されます。正しい答えが 1 回返れば解除されます。</td></tr>
+ <tr><td>エラーまたはタイムアウト</td><td>その判定モデルは 30 秒間使いません。その間のターンは判定モデルを待たず、トレースには問い合わせなかったと記録されます。正しい答えが 1 回返れば解除されます。</td></tr>
<tr><td>メッセージに言葉がない</td><td>問い合わせません。どのインテントも一致しません。</td></tr>
</table></div>
<p>どの場合も、理由とともにターンのトレースに記録されます。つまりインテントルールのせいで、ターンが期待と違うモデルに送られることはあっても、ターンが失敗することはありません。</p>
@@ -230,7 +231,7 @@ The number of its kind (0 for none):</pre>
<h2 id="cost"><a class="anchor" href="#cost">レイテンシ・費用・プライバシー</a></h2>
<ul>
- <li><b>レイテンシ。</b>判定モデルを待つのはターンの最初のリクエストだけで、速いプロバイダなら通常数百ミリ秒(スクリーンショットでは 323 ms)、長くても 8 秒です。ターン内のツールのやり取り、インテントが決め手にならないターン、キャッシュされた答えでは、待ち時間は増えません。</li>
+ <li><b>レイテンシ。</b>判定モデルを待つのはターンの最初のリクエストだけで、速いプロバイダなら通常数百ミリ秒(スクリーンショットでは 323 ms)、タイムアウトは設定でき、既定は 8 秒です。ターン内のツールのやり取り、インテントが決め手にならないターン、キャッシュされた答えでは、待ち時間は増えません。</li>
<li><b>費用。</b>ターンごとに短い呼び出しが 1 回です。入力はメッセージとインテントを合わせた程度、出力は 1〜2 トークンです。上の例では入力 212 トークン、出力 1 トークンでした。サブスクリプションのモデルを判定モデルにすると、これらの呼び出しはそのサブスクリプションの上限に数えられます。</li>
<li><b>プライバシー。</b>メッセージのテキスト(最大約 4,000 文字)は判定モデルのプロバイダに送られます。手元のマシンから出したくなければ、Ollama や LM Studio のローカルモデルを判定モデルにしてください。magpie が保持するのはメッセージのハッシュと答えだけで、メモリ上に 10 分間です。メッセージそのものは保存もログ記録もしません。</li>
</ul>
@@ -243,13 +244,13 @@ The number of its kind (0 for none):</pre>
<li><b>順番は今も重要。</b>数えられるのは最初に一致したルールだけなので、必ず勝たせたいルール(長いコンテキスト用のルールなど)はインテントルールより上に置きます。そうすれば、そのルールが満たされるときは判定モデルを飛ばします。</li>
<li><b>「どれでもない」も立派な答え。</b>どのインテントにも当てはまらないターンはグループのいつもの順に送られるので、その順をデフォルトの選択にしておきましょう。</li>
<li><b>言語は問いません。</b>インテントもメッセージも、判定モデルが理解できる言語なら何語でもかまいません。固定のプロンプトは英語ですが、小さなモデルでも複数言語の混在はよく読めます。</li>
- <li><b>判定モデルの選び方。</b>推理なしの、小さく速いモデルを選びます。Groq の Llama 3.1 8B、Flash-Lite・nano・mini 系のモデル、Claude Haiku、DeepSeek の推理なしチャットモデル、ローカルモデルなどです。推理モデルは遅くなります。magpie は最も低い推理レベルを指定し 2048 トークンの余裕を残しますが、遅いモデルだと 8 秒に間に合わないことがあります。何ターンかトレースを確認し、判定が外れるようなら、モデルを替える前にインテントを書き直してみてください。</li>
+ <li><b>判定モデルの選び方。</b>推理なしの、小さく速いモデルを選びます。Groq の Llama 3.1 8B、Flash-Lite・nano・mini 系のモデル、Claude Haiku、DeepSeek の推理なしチャットモデル、ローカルモデルなどです。推理モデルは遅くなります。magpie は最も低い推理レベルを指定し 2048 トークンの余裕を残しますが、遅いモデルだと設定したタイムアウトに間に合わないことがあります。何ターンかトレースを確認し、判定が外れるようなら、モデルを替える前にインテントを書き直してみてください。</li>
</ul>
<h2 id="limits"><a class="anchor" href="#limits">数値一覧</a></h2>
<div class="table-wrap"><table class="loose">
<tr><th>項目</th><th>値</th></tr>
- <tr><td>判定モデルのタイムアウト</td><td>8 秒(プロバイダのフェイルオーバーを含む)</td></tr>
+ <tr><td>判定モデルのタイムアウト</td><td>既定は 8 秒。1〜60 秒に設定可能(プロバイダのフェイルオーバーを含む)</td></tr>
<tr><td>失敗後の休止</td><td>30 秒、判定モデルごと</td></tr>
<tr><td>答えのキャッシュ</td><td>10 分、判定モデル+インテント+メッセージごと。メモリ上</td></tr>
<tr><td>ターンの判断の保持</td><td>会話の最後のリクエストから 24 時間。メモリ上</td></tr>
@@ -274,7 +275,7 @@ The number of its kind (0 for none):</pre>
<p>2 つの場合だけです。いまのモデルが失敗して別のメンバーが引き継いだときと、会話がモデルのコンテキストを超えそうになり、ルールがより大きいモデルに送ったときです。ターンの途中でインテントを問い合わせ直すことはありません。</p>
<h3>判定モデルが落ちている、または遅いときは?</h3>
- <p>ターンはそのまま進みます。最大 8 秒後、どのインテントも一致せず、グループのほかのルールと順番で決まります。その後 30 秒間はその判定モデルに問い合わせないので、ターンごとにタイムアウトを待つことはありません。理由はトレースに出ます。</p>
+ <p>ターンはそのまま進みます。設定したタイムアウト(既定は 8 秒)まで待った後、どのインテントも一致せず、グループのほかのルールと順番で決まります。その後 30 秒間はその判定モデルに問い合わせないので、ターンごとにタイムアウトを待つことはありません。理由はトレースに出ます。</p>
<h3>判定モデルがインテントを挙げたのに、ルールのモデルに送られなかったのはなぜ?</h3>
<p>トレースを確認してください。よくある原因は次のとおりです。</p>
@@ -296,9 +297,9 @@ The number of its kind (0 for none):</pre>
<p>グループは使えません。<code>provider/model</code> 形式の単一のモデルである必要があり、保存時に magpie がチェックします。モデルなら magpie にあるものは何でも使えます。グループのメンバー、サブスクリプションのモデル、ローカルモデルも含みます。</p>
<h3>推理モデルは使えますか?</h3>
- <p>8 秒以内に答えるなら使えます。magpie は最も低い推理レベル(<code>none</code>、なければ最低のレベル)を指定し、2048 トークンの余裕を残すので、思考に押されて答えが出ないことはありません。それでも、小さく速いモデルのほうがよい選択です。安いですし、すべてのターンがそれを待つからです。</p>
+ <p>設定したタイムアウト(既定は 8 秒)内に答えるなら使えます。magpie は最も低い推理レベル(<code>none</code>、なければ最低のレベル)を指定し、2048 トークンの余裕を残すので、思考に押されて答えが出ないことはありません。それでも、小さく速いモデルのほうがよい選択です。安いですし、すべてのターンがそれを待つからです。</p>
<h3>実際のモデルでどのくらいうまく動きますか?</h3>
- <p>インテントルールが 2 つあるグループに、実際のコーディング用メッセージを 20 件(英語と中国語。ちょっとした質問、テスト作業、「Fix the bug in parseTokens and add a test for it」を含む普通のコーディングタスク)送りました。DeepSeek V4 Flash、GLM-5.3 Flash、MiMo v2.6 Flash はいずれも 20 件すべてを正しく判定し、判定時間の中央値はそれぞれ 0.75 秒、1.3 秒、1.9 秒でした。ある再販業者経由の Gemini 3.8 Flash は <code>low</code> の推理でも 11 秒かかり、すべてのターンがタイムアウトして、インテントがないものとしてルーティングされました。トレースには毎回そのとおり記録されています。これが想定すべきパターンです。判定モデルがうまく動かなくても失うのはルーティングだけで、ターンは失いません。</p>
+ <p>インテントルールが 2 つあるグループに、実際のコーディング用メッセージを 20 件(英語と中国語。ちょっとした質問、テスト作業、「Fix the bug in parseTokens and add a test for it」を含む普通のコーディングタスク)送りました。DeepSeek V4 Flash、GLM-5.3 Flash、MiMo v2.6 Flash はいずれも 20 件すべてを正しく判定し、判定時間の中央値はそれぞれ 0.75 秒、1.3 秒、1.9 秒でした。ある再販業者経由の Gemini 3.8 Flash は <code>low</code> の推理でも 11 秒かかり、既定の 8 秒のタイムアウトではすべてのターンがタイムアウトして、インテントがないものとしてルーティングされました。トレースには毎回そのとおり記録されています。これが想定すべきパターンです。判定モデルがうまく動かなくても失うのはルーティングだけで、ターンは失いません。</p>
<h3>同じメッセージを再送すると、また問い合わせますか?</h3>
<p>10 分以内なら問い合わせません。同じメッセージ・同じインテント・同じ判定モデルならキャッシュから答え、トレースには “said before” と出ます。インテントか判定モデルを変えると、改めて問い合わせます。</p>
diff --git a/site/public/docs/ja/start.html b/site/public/docs/ja/start.html
index 3819f7be1..dc90a4793 100644
--- a/site/public/docs/ja/start.html
+++ b/site/public/docs/ja/start.html
@@ -192,7 +192,7 @@
<li>ルールはターンの開始時に決まり、エージェントがツールの結果を返している間もそのターンは同じモデルに留まるため、ベンダーのキャッシュが途中で失われません。唯一の例外として、ターンがモデルのコンテキストを超えて大きくなった場合は、それを受け付けられるメンバーに移ります。</li>
<li>トークン数は、リクエストのサイズから推定した値と、会話の直前のリクエストでベンダーが数えた値のうち、大きいほうを使います。余裕を持たせてください。200k のモデルなら、ルールは 199k ではなく 150k にします。</li>
<li>サブエージェントはそれ自体が独立した会話なので、親のエージェントはそのままに、ルールでサブエージェントだけを別の送り先に送れます。</li>
- <li>インテントは、ユーザーが求めていることを数語で表したものです(「テストを書く・直す」「ちょっとした質問」など)。ターンの開始時に、グループの分類モデル(magpie にある任意のモデル。小さく高速で推論なしのものが最適です)に、一致しうるインテントのうちユーザーのメッセージがどれに当たるかを一度だけ尋ねます。送られるのはそのメッセージだけで、会話全体ではありません。分類モデルが失敗した、遅すぎた(8 秒)、または判断できなかった場合は、どのインテントも一致せず、そのターンは他のルールに従います。インテントのないルールでいずれにせよ決まる場合は問い合わせず、同じメッセージについて二度尋ねることもありません。その呼び出しは使用量に magpie 自身の呼び出しとして表示されます。何を尋ねるのか、回答がどう使われるのか、失敗したらどうなるのかの詳細は<a href="/docs/ja/intent">インテントルーティング</a>を参照してください。</li>
+ <li>インテントは、ユーザーが求めていることを数語で表したものです(「テストを書く・直す」「ちょっとした質問」など)。ターンの開始時に、グループの分類モデル(magpie にある任意のモデル。小さく高速で推論なしのものが最適です)に、一致しうるインテントのうちユーザーのメッセージがどれに当たるかを一度だけ尋ねます。送られるのはそのメッセージだけで、会話全体ではありません。分類モデルが失敗した、設定したタイムアウトを超えた(既定は 8 秒。「設定 → モデル → 応答 → インテント判定のタイムアウト」で変更可能)、または判断できなかった場合は、どのインテントも一致せず、そのターンは他のルールに従います。インテントのないルールでいずれにせよ決まる場合は問い合わせず、同じメッセージについて二度尋ねることもありません。その呼び出しは使用量に magpie 自身の呼び出しとして表示されます。何を尋ねるのか、回答がどう使われるのか、失敗したらどうなるのかの詳細は<a href="/docs/ja/intent">インテントルーティング</a>を参照してください。</li>
<li><span class="ui">compacting</span> は、エージェントが会話を圧縮するとき(Claude Code の <code>/compact</code> と自動圧縮、Codex、OpenCode、Pi、Gemini CLI、Qwen Code、Kimi Code)に一致します。これにより、会話は元のモデルのまま、要約だけをより安く速いモデルに書かせられます。圧縮は単独で判断されます。圧縮が起きたターンとそのキャッシュは元の送り先に留まります。会話がルールのモデルが受け付けられる長さを超えている場合は、次に一致するルール、またはグループの順序で決まります。</li>
<li><b>時間帯と曜日。</b>ルールは、このコンピューターの時計で、特定の時間帯や曜日だけ有効にできます(ベンダーのピーク時間など)。その間のターンを別のモデルに送るルールでは、ベンダーのモデルはフォールバックとして後ろに残ります。完全に外すには、ルールの <span class="ui">⋯</span> メニューから <span class="ui">代わりにモデルを一時停止</span> を選びます。ルールが有効な間(時間帯、曜日、エージェント)、そのモデルはグループから外れ、先頭にもフォールバックにもならず、会話の継続でも使われません。時間帯が終われば戻ります。一時停止は時間帯、曜日、エージェントだけで判断し、グループのモデルがすべて一時停止中ならエージェントにそう伝えます。</li>
<li><b>フォルダ。</b><span class="ui">フォルダ</span> は、エージェントの作業フォルダが指定したフォルダのどれか、またはその中にあるときに一致します。<code>~/work/acme</code> は <code>~/work/acme/web</code> を含み、<code>~/work/acme-old</code> は含みません。フォルダはエージェントがリクエストでモデルに伝えるもの(Claude Code、Codex、OpenCode、Pi が伝えます)なので、伝えないエージェントはフォルダのルールに一致しません。<code>~</code> はホームフォルダ、<code>C:\work</code> は WSL の <code>/mnt/c/work</code> と同じで、macOS と Windows では大文字小文字を区別しません。</li>
diff --git a/site/public/docs/start.html b/site/public/docs/start.html
index 2a1bfff0d..6c1d1b4ae 100644
--- a/site/public/docs/start.html
+++ b/site/public/docs/start.html
@@ -192,7 +192,7 @@
<li>A rule decides as a turn begins, and the turn stays on that model while the agent sends tool results back, so what the vendor cached isn’t lost halfway. The one exception: a turn that grows past its model’s context moves to a member that takes it.</li>
<li>Tokens are estimated from the request’s size, or what the vendor counted for the conversation’s last request, whichever is more. Leave some margin: a rule at 150k for a 200k model, not 199k.</li>
<li>A subagent is a conversation of its own, so a rule can send it elsewhere while its agent keeps where it is.</li>
- <li>An intent is a few words for what the user asks for — “writing or fixing tests”, “a quick question”. As a turn begins, the group’s classifier — any model magpie has; a small, fast one without reasoning is best — is asked once which of the intents that could match the user’s message is. Only the message is sent, not the conversation. If it fails, is slow (8 s) or can’t say, no intent matches and the turn goes by the other rules. It isn’t asked when a rule without an intent would decide anyway, and the same message isn’t asked about twice. Its calls show in Usage as magpie’s own. Exactly what it is asked, how its answer is used and what happens when it fails: <a href="/docs/intent">Intent routing</a>.</li>
+ <li>An intent is a few words for what the user asks for — “writing or fixing tests”, “a quick question”. As a turn begins, the group’s classifier — any model magpie has; a small, fast one without reasoning is best — is asked once which of the intents that could match the user’s message is. Only the message is sent, not the conversation. If it fails, exceeds the configured timeout (8 s by default; set in Settings → Models → Replies → Intent classifier timeout) or can’t say, no intent matches and the turn goes by the other rules. It isn’t asked when a rule without an intent would decide anyway, and the same message isn’t asked about twice. Its calls show in Usage as magpie’s own. Exactly what it is asked, how its answer is used and what happens when it fails: <a href="/docs/intent">Intent routing</a>.</li>
<li><span class="ui">compacting</span> matches an agent compacting its conversation — Claude Code’s <code>/compact</code> and auto-compact, Codex, OpenCode, Pi, Gemini CLI, Qwen Code, Kimi Code — so a cheaper, faster model writes the summary while the conversation stays on its own. A compaction is decided on its own: the turn it happens in, and its cache, stay where they were. When the conversation is longer than the rule’s model takes, the next rule that matches, or the group’s order, decides instead.</li>
<li><b>Hours and days.</b> A rule can hold only at some hours, on some days, by this computer’s clock — a vendor’s peak hours, say. A rule that sends those turns elsewhere still leaves the vendor’s model behind it for failover. To keep a model out entirely, choose <span class="ui">Pause the model instead</span> from the rule’s <span class="ui">⋯</span> menu: while it holds (its hours and days, its agents), that model is left out of the group — never first, never a fallback, not kept for the conversation it was in — and it is back once they end. A pause holds by hours, days and agents only; if every model of the group is paused, the agent is told so.</li>
<li><b>Folders.</b> <span class="ui">in folder</span> matches a turn from an agent working in one of the folders you list, or a folder inside one: <code>~/work/acme</code> takes <code>~/work/acme/web</code>, not <code>~/work/acme-old</code>. The folder is the one the agent tells its model in the request — Claude Code, Codex, OpenCode and Pi say it — so an agent that doesn’t say its folder matches no folder rule. <code>~</code> is your home folder, <code>C:\work</code> is also WSL’s <code>/mnt/c/work</code>, and on macOS and Windows case doesn’t count.</li>
diff --git a/site/public/docs/zh/intent.html b/site/public/docs/zh/intent.html
index 55b00948c..0ddeb2753 100644
--- a/site/public/docs/zh/intent.html
+++ b/site/public/docs/zh/intent.html
@@ -106,6 +106,7 @@
<li><b>选择意图判断模型</b>有规则带意图后,下方会出现<span class="ui">意图判断模型</span>;有 TypeSafe provider 时默认就是 Jev,否则建议选小而快、不带推理的模型。已经让 Jev 选推理强度的分组,判断模型下方也有同一个入口:<span class="ui">它也能挑模型</span>。有意图却没有判断模型时,分组无法保存。</li>
<li><b>保存,然后发条消息</b>从下一轮起生效,不用重启。<span class="ui">路由</span>页会显示判断模型说了什么、这一轮去了哪里。</li>
</ol>
+ <p id="timeout">超时是全局设置:在<span class="ui">设置 → 模型 → 回复 → 意图判断超时</span>中可选 8、15、30 或 60 秒。默认 8 秒,从下一次判断调用起生效,Jev 也适用,无需重启。慢的判断模型可能需要更长时间,但这一轮会先等它再路由。在 <code>~/.config/magpie/settings.json</code> 中,<code>"classifyTimeout"</code> 接受 1 到 60 的整数秒数;0 或未设置时使用 8 秒。范围内的自定义值会在设置里显示为单独的选项。</p>
<p>命令行里也可以设置:</p>
<div class="code">
<span class="lang">终端</span>
@@ -127,7 +128,7 @@ magpie group rule rm coder 2</pre>
<ol class="steps">
<li><b>是不是新的一轮?</b>magpie 看请求里最后一条用户消息:带文字或图片、不带工具结果,说明是你刚刚发言,新的一轮开始;带工具结果,说明是 Agent 在继续进行中的一轮(见<a href="#turn">这一轮的后续请求</a>)。轮次按会话分别计数。子代理是单独的会话:它和主代理共用一个 session,但第一句话不同。</li>
<li><b>哪些意图可能起作用?</b>magpie 从上往下看规则,先不管意图:一条规则的其他条件(tokens、图片、推理、Agent)对这个请求都成立,它就是候选,把它的意图收集起来。只有大小写不同的意图算同一个。遇到第一条<em>不带</em>意图的候选规则就停止,因为它会直接命中,排在它下面的规则都轮不到。一个意图也没收集到时,不会询问意图判断模型,也不会产生费用。</li>
- <li><b>询问意图判断模型</b>把收集到的意图和你这条消息的文字发给它,完整提示词见<a href="#prompt">下文</a>。这个调用和 Agent 的请求一样,走 magpie 自己的网关,所以用的是该模型所属供应商的 Key 或账号,以及它们的故障转移。它有 8 秒时间作答。</li>
+ <li><b>询问意图判断模型</b>把收集到的意图和你这条消息的文字发给它,完整提示词见<a href="#prompt">下文</a>。这个调用和 Agent 的请求一样,走 magpie 自己的网关,所以用的是该模型所属供应商的 Key 或账号,以及它们的故障转移。它需要在<a href="#timeout">设定的超时时间</a>内作答(默认 8 秒)。</li>
<li><b>读取回答</b>取回答里出现的第一个整数:<code>1</code> 到 <code>n</code> 表示对应的意图,<code>0</code> 表示都不是。其他情况(没有数字、数字超出范围)这一轮都不命中意图。同一条消息、同一组意图的回答会缓存 10 分钟。</li>
<li><b>匹配规则</b>带着这个回答从上往下检查规则。带意图的规则,只有判断模型说的正是它的意图(不区分大小写),并且其他条件也都满足时才命中。第一条命中的规则生效;一条都不命中时,分组按平常的方式路由这一轮。</li>
<li><b>给模型排序</b>命中规则指定的模型排第一,组里其他模型按平常的顺序排在后面做故障转移。即使上一轮是别的模型回答的,也是这样:新一轮开始时,规则优先于<span class="ui">会话保持</span>。如果规则指定的模型此刻没有可用的 Key 或账号(都在冷却、供应商已关闭),就按分组原本的顺序,路由记录里会写明原因。</li>
@@ -188,10 +189,10 @@ The number of its kind (0 for none):</pre>
<div class="table-wrap"><table class="loose">
<tr><th>情况</th><th>magpie 的处理</th></tr>
<tr><td>回答 <code>0</code></td><td>所有意图都不命中,由不带意图的规则和分组平常的顺序决定</td></tr>
- <tr><td>8 秒内没有回答</td><td>算失败:意图都不命中,这一轮立即继续</td></tr>
- <tr><td>报错(额度用完、5xx、Key 无效)</td><td>先在 8 秒内尝试它所属供应商自己的故障转移,仍然失败则意图都不命中</td></tr>
+ <tr><td>设定的超时时间内没有回答</td><td>算失败:意图都不命中,这一轮立即继续</td></tr>
+ <tr><td>报错(额度用完、5xx、Key 无效)</td><td>先在设定的超时时间内尝试它所属供应商自己的故障转移,仍然失败则意图都不命中</td></tr>
<tr><td>回答不是 0 到 n 之间的数字</td><td>这一轮意图都不命中。判断模型确实回答了,所以不冷却,下一轮照常询问</td></tr>
- <tr><td>报错或 8 秒超时</td><td>这个判断模型会冷却 30 秒:这段时间里的轮次不再等它,路由记录里会写 “not asked again for now”。之后第一次答对就解除</td></tr>
+ <tr><td>报错或超时</td><td>这个判断模型会冷却 30 秒:这段时间里的轮次不再等它,路由记录里会写 “not asked again for now”。之后第一次答对就解除</td></tr>
<tr><td>消息里没有文字</td><td>不询问,意图都不命中</td></tr>
</table></div>
<p>每种情况都会连同原因写进这一轮的路由记录。所以带意图的规则可能让这一轮去了你没想到的模型,但不会让它失败。</p>
@@ -230,7 +231,7 @@ The number of its kind (0 for none):</pre>
<h2 id="cost"><a class="anchor" href="#cost">延迟、费用、隐私</a></h2>
<ul>
- <li><b>延迟。</b>只有每一轮的第一个请求需要等判断模型,在快的供应商上通常是几百毫秒(截图里是 323 毫秒),最长 8 秒。这一轮后面的工具往返、没有意图需要判断的轮次、命中缓存的回答,都不增加延迟。</li>
+ <li><b>延迟。</b>只有每一轮的第一个请求需要等判断模型,在快的供应商上通常是几百毫秒(截图里是 323 毫秒),超时时间可设定,默认 8 秒。这一轮后面的工具往返、没有意图需要判断的轮次、命中缓存的回答,都不增加延迟。</li>
<li><b>费用。</b>每轮一次很短的调用:输入大约是你的消息加上意图列表,输出一两个 token。上面的例子是输入 212、输出 1。用订阅里的模型做判断模型时,这些调用会占用该订阅的额度。</li>
<li><b>隐私。</b>你这条消息的文字(最多约 4000 个字符)会发给判断模型所属的供应商。想让它不离开本机,可以用 Ollama 或 LM Studio 里的本地模型来判断。magpie 只在内存里保存消息的哈希值和判断结果,保留 10 分钟;消息原文不存储,也不写日志。</li>
</ul>
@@ -243,13 +244,13 @@ The number of its kind (0 for none):</pre>
<li><b>顺序依然重要。</b>只有第一条命中的规则生效,所以必须优先的规则(例如长上下文规则)要放在带意图的规则上面。它成立时,连判断模型都不用问。</li>
<li><b>“都不是”也是有效回答。</b>不属于任何意图的轮次按分组平常的顺序走,所以把你的默认模型放在这个顺序的第一位。</li>
<li><b>中文英文都行。</b>意图和消息可以用判断模型能理解的任何语言书写。固定的提示词是英文的,小模型处理中英混合没有问题。</li>
- <li><b>怎么选判断模型。</b>选小而快、不带推理的模型:Groq 上的 Llama 3.1 8B、各家的 Flash-Lite / nano / mini 系列、Claude Haiku、DeepSeek 的非推理对话模型,或者本地模型。推理模型更慢;magpie 会要它最低的推理档位并留 2048 个 token,但慢的模型仍可能超过 8 秒。先观察几轮路由记录,判断不准时,先改意图的措辞,再考虑换模型。</li>
+ <li><b>怎么选判断模型。</b>选小而快、不带推理的模型:Groq 上的 Llama 3.1 8B、各家的 Flash-Lite / nano / mini 系列、Claude Haiku、DeepSeek 的非推理对话模型,或者本地模型。推理模型更慢;magpie 会要它最低的推理档位并留 2048 个 token,但慢的模型仍可能超过设定的超时时间。先观察几轮路由记录,判断不准时,先改意图的措辞,再考虑换模型。</li>
</ul>
<h2 id="limits"><a class="anchor" href="#limits">数值一览</a></h2>
<div class="table-wrap"><table class="loose">
<tr><th>项目</th><th>数值</th></tr>
- <tr><td>判断超时</td><td>8 秒,包含其供应商的故障转移</td></tr>
+ <tr><td>判断超时</td><td>默认 8 秒,可设为 1 到 60 秒,包含其供应商的故障转移</td></tr>
<tr><td>失败后冷却</td><td>30 秒,按判断模型计</td></tr>
<tr><td>回答缓存</td><td>10 分钟,按判断模型 + 意图 + 消息;仅内存</td></tr>
<tr><td>轮次决定保留</td><td>会话最后一个请求之后 24 小时;仅内存</td></tr>
@@ -274,7 +275,7 @@ The number of its kind (0 for none):</pre>
<p>只有两种情况:当前模型失败、由组里另一个成员接手;或者会话超出当前模型的上下文,有规则把它发往上下文更大的模型。一轮之中不会重新判断意图。</p>
<h3>判断模型挂了或者很慢怎么办?</h3>
- <p>这一轮照常进行。最多等 8 秒后,意图都不命中,由分组的其他规则和顺序决定。接下来 30 秒内 magpie 不再询问这个判断模型,免得每一轮都要等满超时。路由记录里会写明原因。</p>
+ <p>这一轮照常进行。最多等到设定的超时时间(默认 8 秒)后,意图都不命中,由分组的其他规则和顺序决定。接下来 30 秒内 magpie 不再询问这个判断模型,免得每一轮都要等满超时。路由记录里会写明原因。</p>
<h3>判断模型说的就是这条规则的意图,为什么没有发给规则指定的模型?</h3>
<p>看路由记录。常见原因有:</p>
@@ -296,7 +297,7 @@ The number of its kind (0 for none):</pre>
<p>不能是路由组:它必须是单个模型(<code>provider/model</code>),保存时 magpie 会校验。它可以是 magpie 里的任何模型,包括组里的成员、订阅里的模型或本地模型。</p>
<h3>可以用推理模型吗?</h3>
- <p>可以,只要它能在 8 秒内回答。magpie 会要它最低的推理档位(有 <code>none</code> 用 <code>none</code>,否则用最低一档),并留 2048 个 token,思考不会挤掉答案。不过小而快的模型仍是更好的选择:更便宜,而且每一轮都要等它。</p>
+ <p>可以,只要它能在设定的超时时间内回答(默认 8 秒)。magpie 会要它最低的推理档位(有 <code>none</code> 用 <code>none</code>,否则用最低一档),并留 2048 个 token,思考不会挤掉答案。不过小而快的模型仍是更好的选择:更便宜,而且每一轮都要等它。</p>
<h3>重试同一条消息,会再问一次吗?</h3>
<p>10 分钟内不会:同一条消息、同一组意图、同一个判断模型,直接用缓存的回答,路由记录里写「同一条消息之前已判断过」。改了意图或者换了判断模型,就会重新询问。</p>
diff --git a/site/public/docs/zh/start.html b/site/public/docs/zh/start.html
index 8a9b8b8d1..69e788aef 100644
--- a/site/public/docs/zh/start.html
+++ b/site/public/docs/zh/start.html
@@ -192,7 +192,7 @@
<li>规则只在一轮开始时决定;Agent 回传工具结果的过程中一直留在那个模型上,不会半途换掉而丢掉厂商的缓存。唯一例外:这一轮涨到超过所在模型的上下文,会换到装得下的成员。</li>
<li>token 数取请求大小的估算与厂商对这个会话上一个请求的计数中较大的一个。请留出余量:给 200k 的模型设 150k,而不是 199k。</li>
<li>子代理是单独的会话,规则可以把它发到别处,主代理仍留在原处。</li>
- <li>意图是用几个词描述用户想做什么,例如“写或修测试”“一个简单问题”。每一轮开始时,magpie 会问一次组里指定的意图判断模型:用户这条消息属于哪个可能命中的意图。这个模型可以是 magpie 里的任意模型,建议选小而快、不带推理的。发过去的只有这条消息,不包括整段对话。它出错、超时(8 秒)或给不出答案时,意图条件都不命中,这一轮按其他规则走。如果前面有不带意图的规则已经能决定,就不会去问;同一条消息也不会问两次。它的调用在用量里显示为 magpie 自己的调用。它具体被问了什么、回答怎么用、失败时怎么办,详见<a href="/docs/zh/intent">意图路由</a>。</li>
+ <li>意图是用几个词描述用户想做什么,例如“写或修测试”“一个简单问题”。每一轮开始时,magpie 会问一次组里指定的意图判断模型:用户这条消息属于哪个可能命中的意图。这个模型可以是 magpie 里的任意模型,建议选小而快、不带推理的。发过去的只有这条消息,不包括整段对话。它出错、超过设定的超时时间(默认 8 秒,在「设置 → 模型 → 回复 → 意图判断超时」中调整)或给不出答案时,意图条件都不命中,这一轮按其他规则走。如果前面有不带意图的规则已经能决定,就不会去问;同一条消息也不会问两次。它的调用在用量里显示为 magpie 自己的调用。它具体被问了什么、回答怎么用、失败时怎么办,详见<a href="/docs/zh/intent">意图路由</a>。</li>
<li><span class="ui">压缩上下文时</span>:Agent 压缩对话上下文时命中——Claude Code 的 <code>/compact</code> 和自动压缩、Codex、OpenCode、Pi、Gemini CLI、Qwen Code、Kimi Code——让更便宜、更快的模型来写总结,对话本身仍留在原来的模型上。压缩请求单独决定:它所在的这一轮和缓存都留在原处。对话比规则里的模型能装下的还长时,改由下一条命中的规则或组本来的顺序决定。</li>
<li><b>时段和星期。</b>规则可以只在某些时段、某几天生效,按这台电脑的时钟——比如厂商的高峰期。把这段时间的对话“先发给”别的模型,厂商那个模型仍排在后面做故障转移。要把它完全拿掉,在规则的 <span class="ui">⋯</span> 菜单里选 <span class="ui">改为暂停该模型</span>:规则生效期间(它的时段、星期和 Agent),这个模型移出分组——不排第一、不做备用、也不会因为会话粘性被留住——时段过了自动回来。暂停只按时段、星期和 Agent 判断;组里所有模型都被暂停时,会告诉 Agent。</li>
<li><b>文件夹。</b><span class="ui">项目文件夹</span>:Agent 的工作目录是你列出的文件夹之一或其子文件夹时命中:<code>~/work/acme</code> 包括 <code>~/work/acme/web</code>,不包括 <code>~/work/acme-old</code>。文件夹以 Agent 在请求里告诉模型的为准——Claude Code、Codex、OpenCode 和 Pi 都会说——不说明工作目录的 Agent 不会命中任何按文件夹的规则。<code>~</code> 是你的主目录,<code>C:\work</code> 也就是 WSL 里的 <code>/mnt/c/work</code>,macOS 和 Windows 上不区分大小写。</li>