classify: 15 seconds unset for a classifier that reasons, and its cut call is magpie's wait (ESern29751 on X)

ESern29751 on X (v0.1.4341): in a routing group with intent recognition,
magpie often 499-cancels the intent classifier's request, with MiniMax,
GPT-6 Luna and Grok 4.6 as the classifier.

Cause: those models reason before they answer. The classifier asks for
reasoning_effort none, but MiniMax thinks anyway and Grok 4.6 and Luna go
no lower than low. Through the live gateway with the classify prompt over
a real routing prompt (~5k tokens of context): grok-4.6 took 4.7-8.1s
(288-462 reasoning tokens), minimax-m2.5 3.7-10.3s (439-1012 output
tokens), gpt-6-luna 1.2-7.2s; cold calls reached 12-29s. The unset
classifier timeout was 8 seconds, so most turns were cut off, fell back to
the group's order and lost their intent routing. Each cut call was then
logged 499 "the agent canceled the request", which usage counts as no
failure, though no agent had canceled anything: askChat's own
context.WithTimeout had no cause, the mislabel #2318 fixed for an image's
description but never for the classifier.

Fix:
- settings.ClassifyTimeoutDefault 8 -> 15 (an existing Settings segment).
  A user who saved 8 keeps 8; only the unset value moves. The GUI's
  fallback segment follows (app.js), and the docs (en/zh/ja intent and
  start, gateway-routing.md) say 15.
- askChat's wait is context.WithTimeoutCause(..., sideTimedOut{"decision
  model", wait}): the usage row says "magpie stopped waiting: its
  decision model had no answer in Ns", a failure.
- Siblings checked: the advisor and Codex titles use the client's
  context, compaction and vision already carry sideTimedOut; askJev
  (decision providers) logs no 499 row of its own.
- Tests that assumed the 8-second unset wait now use 15 (classify,
  decide, decide_group, nested_classify_wait, settings).
- app.js grows by the one byte of the fallback's second digit: both
  core budgets +1 with the reason (TestCoreScriptBudget was red at
  exactly 1 over without it). A shorter `|| 15` would show a hand-edited
  negative value as its own segment, so it wasn't taken.
- site: llms-full.txt and the search indexes regenerated for the docs
  pages (node llms-full.mjs, node search-index.mjs).

Test: TestReasoningClassifierAnswersInTheWaitUnset - a classifier
answering in 10 units routes the turn with the timeout unset, and one
slower than 60 units gives no answer with one 499 usage row that says
magpie stopped waiting for its decision model and counts as a failure.

Broken by hand (mica-run): with askChat back on a plain WithTimeout the
test is red ("the classifier's cut call: 499 "the agent canceled the
request""); with the default back at 8 it is red ("gave no answer in
400ms").

Run at 0479372b8, this commit's tree (mica, through ~/suite.lock; mote was over its cores):
- gofmt -l: clean. go vet (darwin), GOOS=linux go vet -tags nogui,
  GOOS=windows go vet: rc 0 (darwin vet rc 0 at the first try on mote).
- go test -tags nogui -count=1 -timeout 45m ./...: rc 0, 103 ok.
  (The first run, on mote before the budget raise and the rebase onto
  adfa196db, was red on TestCoreScriptBudget alone.)
- node --test site/*.test.mjs: 132 of 132.
- GUI (node --test, Chromium and WebKit, five languages, 1100 and 420):
  classify-timeout-setting, settings-places, i18n-en-no-cjk green;
  i18n-keys red only on "a plugin's words are its own" over
  claude_image_budget_test.go's ", with an image", already #6877 from
  2896e82cc, untouched here.

Not tried: the real reporter's group in the GUI with these models after
the change (the timings above were measured through the live gateway
before it); the whole GUI suite (only a fallback value changed in app.js).
This commit is contained in:
yetone
2026-11-17 13:31:08 +08:00
parent adfa196db0
commit 873b1f7d5e
21 changed files with 120 additions and 60 deletions
+1 -1
View File
@@ -250,7 +250,7 @@ the key's leaves the call as asked, with a log line (`compactRefused`).
- 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), the conversation's id where no session header names it (`userOpens`, in `conversationID`), 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 …>`; Reasonix's `<session-context …>`, its snapshot of the workspace (keeyangyy, #3938). 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 members it names, in order, 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`.
- How sure a decision model (Jev) must be of an intent for it to count is the group's own (`provider.Group.IntentSure`, JSON `intentSure`, 0 to 1; missing keeps `jevSure`, 0.4; `magpie group set <group> intent-sure=0.25`, empty to unset; SaveGroup and the CLI refuse a value outside 0 to 1, NaN too; `cloneGroups` copies it). `readJev` keeps Jev's likeliest intent with its sure and marks a topic answer (`verdict.Topic`); `ruleFor` applies the group's sure (`intentOf`), so two groups sharing one classifier and its cached answer each judge it at their own. "none of these" is never an intent, at 0 too, and levels keep the turn before's level when torn, as before. A chat model asked in words answers with no sure and is taken as it answers. The Routing groups page carries the value through every save of a group but has no field for it yet (#5101). `TestGroupIntentSure*`.
- 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. A request shares one such wait across every routing group it goes through (`Server.askWaited`, from the first classifier asked): a nested ruled group asked with less left gets only that, one asked once it is spent goes by its order at once (`waitSpent`, "spent by the routing group above"), and a classifier or decision key cut short that way is not rested (`cutShort`). Each nested level had a whole wait of its own before, so three ruled levels whose classifiers didn't answer held a request past the unrouted watch's 2 minutes, a 504 (heatonz on Discord, v0.1.2215; `TestNestedGroupsShareTheClassifierWait`, `TestDecisionKeyCutShortIsNotRested`). 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's timeout is global (`Settings.ClassifyTimeout`, JSON `classifyTimeout`, seconds, in [`settings.go`](../../internal/settings/settings.go)). Missing or 0 keeps the 15-second default (8 before ESern29751 on X: a classifier that reasons, MiniMax thinking even asked for none, Grok 4.6 and GPT-6 Luna going no lower than low, took 4 to 10 seconds over a real routing prompt and was cut off on most turns; `TestReasoningClassifierAnswersInTheWaitUnset`); 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. A request shares one such wait across every routing group it goes through (`Server.askWaited`, from the first classifier asked): a nested ruled group asked with less left gets only that, one asked once it is spent goes by its order at once (`waitSpent`, "spent by the routing group above"), and a classifier or decision key cut short that way is not rested (`cutShort`). Each nested level had a whole wait of its own before, so three ruled levels whose classifiers didn't answer held a request past the unrouted watch's 2 minutes, a 504 (heatonz on Discord, v0.1.2215; `TestNestedGroupsShareTheClassifierWait`, `TestDecisionKeyCutShortIsNotRested`). 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 chat classifier's call the wait ends is magpie's own limit (`askChat`'s context has a `sideTimedOut` cause, as an image's description's does, #2318): its usage row is a 499 that says "magpie stopped waiting: its decision model had no answer in …", a failure, not "the agent canceled the request".
- 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 group's classifier is asked only for that group's own turns: a request whose model is the group (`group/<id>`, its bare name, or a stand-in an agent's config names it by: Claude Code's tiers, Codex's bare name), or a group in it that its rules or order put first (`nestedRules`). A request for another model or group asks it nothing. The Routing groups page's card says why the classifier couldn't say the last time *that group* asked it (`GroupClassifierFailure`, kept by `classifiedFor` in `ruleFor`): the classifier's own words and time, resting or not, until it answers that group, and nothing once the group's classifier changed. Keyed by the classifier model alone, a group nothing reached showed another group's failure on a classifier they share (jjt on Discord). A classifier on a subscription out of its quota is not asked of the vendor again until the reset: out of quota, its account rests until the quota comes back (`restAfter`: the time the refusal names, else when the account's window renews), and the classifier's call meanwhile gets that refusal back from magpie, at most once each `classifyRest`. `TestClassifierFailureIsTheGroupsOwn`.
- 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`). Its questions are the group's spend, so they are held to the accounts the turn is (`classifierHeld` in [`rules.go`](../../internal/gateway/rules.go), carried by `askWaited` to `askChat`, `askDecider` and `askDecisionGroup`; AWilsonPeng on X: a group held to one of two ChatGPT accounts whose classifier was its own member asked on both): the group's `Accounts`, the account its member names when the classifier is that member (each one's, for a model in it once per account), and the caller's (a gateway key's, a group above), never a key's models. A failure rests the classifier for those accounts alone (`classify`'s `rest`). `TestClassifierModelHeldToItsGroupsAccount`, `TestClassifierModelHeldToTheKeysAccount`, `TestIntentRoutesATurn`, `TestJevPicksTheIntent`, `TestSummaryCountsMagpiesOwnCallsApart`, `TestByMagpie`, `TestServedRefSaysASubscription`, `own-requests.test.cjs`.
+6 -1
View File
@@ -626,8 +626,13 @@ func readEffort(answer string) (string, float64, error) {
// answer's text, if it comes in wait.
// held, when it names accounts, holds it to them, as heldByGroup does a
// request through a group.
//
// A call the wait ends is magpie's own limit running out, as an image's
// description's is (sideTimedOut, #2318): the usage log said "the agent
// canceled the request", a 499 no failure, though no agent had
// (ESern29751 on X).
func (s *Server) askChat(wait time.Duration, held access.Identity, model string, body []byte) (string, error) {
ctx, cancel := context.WithTimeout(context.Background(), wait)
ctx, cancel := context.WithTimeoutCause(context.Background(), wait, sideTimedOut{"decision model", wait})
defer cancel()
r, err := http.NewRequestWithContext(ctx, http.MethodPost, "http://magpie/v1/chat/completions", nil)
if err != nil {
+57 -6
View File
@@ -285,7 +285,7 @@ func TestIntentClassifierFails(t *testing.T) {
}
// slow: past the timeout it's no answer
was := classifyUnit
classifyUnit = 25 * time.Millisecond // the 8 seconds unset are 200ms
classifyUnit = 20 * time.Millisecond // the 15 seconds unset are 300ms
t.Cleanup(func() { classifyUnit = was })
c.mu.Lock()
c.wait = 2 * time.Second
@@ -299,12 +299,12 @@ 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
// Classifier timeout gives it longer: a classifier slower than the 15
// seconds unset routes the turn by its answer once it is given 60, and
// one given 8 again is no answer.
// one given 8 is no answer.
func TestClassifierTimeoutSetting(t *testing.T) {
was := classifyUnit
classifyUnit = 100 * time.Millisecond // 8 seconds are 800ms, 60 are 6s
classifyUnit = 100 * time.Millisecond // 15 seconds unset are 1.5s, 8 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)
@@ -314,7 +314,8 @@ func TestClassifierTimeoutSetting(t *testing.T) {
for i, x := range []struct {
seconds int
answers bool
}{{0, false}, {60, true}, {8, false}} {
wait string
}{{0, false, "1.5s"}, {60, true, ""}, {8, false, "800ms"}} {
st := settings.Load()
st.ClassifyTimeout = x.seconds
if err := settings.Save(st); err != nil {
@@ -329,12 +330,62 @@ func TestClassifierTimeoutSetting(t *testing.T) {
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")) {
if !x.answers && (!strings.Contains(out, "from ka") || r.Rule.N != 0 || !strings.Contains(cl.Error, "no answer in "+x.wait)) {
t.Fatalf("given %ds: %s %+v %+v", x.seconds, out, r.Rule, cl)
}
}
}
// ESern29751 on X: a routing group whose classifier reasons before it
// answers (MiniMax, which thinks even asked for none; Grok 4.6 and GPT-6
// Luna, which go no lower than low) lost its intent routing on most turns.
// Asked with a real routing prompt they answered in 4 to 10 seconds, past
// the 8 a classifier was given unset, and every such call was logged 499
// "the agent canceled the request", though no agent had. Unset, a
// classifier that answers in 10 seconds now routes the turn, and one past
// the wait is logged as magpie stopping, a failure.
func TestReasoningClassifierAnswersInTheWaitUnset(t *testing.T) {
was := classifyUnit
classifyUnit = 50 * time.Millisecond // 10 seconds are 500ms
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 = 10 * classifyUnit
c.mu.Unlock()
out, r := postOK(t, s, "rs1", chat("rename the parser package and move its tests", nil, 0, ""))
if cl := r.Rule.Classified; !strings.Contains(out, "from kb") || r.Rule.N != 1 || cl.Intent != "refactoring" || cl.Error != "" {
t.Fatalf("a classifier answering in 10s, unset: %s %+v %+v", out, r.Rule, cl)
}
// past the whole wait it is no answer, and the call magpie stopped is
// its failure, not an agent canceling
c.mu.Lock()
c.wait = time.Duration(settings.ClassifyTimeoutMost) * classifyUnit
c.mu.Unlock()
out, r = postOK(t, s, "rs2", chat("rename everything under internal", nil, 0, ""))
if cl := r.Rule.Classified; !strings.Contains(out, "from ka") || !strings.Contains(cl.Error, "no answer") {
t.Fatalf("a classifier past its wait: %s %+v %+v", out, r.Rule, cl)
}
var cut []usage.Record
for i := 0; i < 100 && len(cut) == 0; i++ {
for _, rec := range usage.Load(time.Time{}) {
if rec.Model == "cls" && rec.Status == usage.StatusCanceled {
cut = append(cut, rec)
}
}
if len(cut) == 0 {
time.Sleep(20 * time.Millisecond)
}
}
if len(cut) != 1 {
t.Fatalf("the classifier's cut call in the usage log: %+v", cut)
}
rec := cut[0]
if !strings.Contains(rec.Error, "magpie stopped waiting") || !strings.Contains(rec.Error, "decision model") || usage.CanceledBy(rec.Status, rec.Error) || !rec.Failed() {
t.Fatalf("the classifier's cut call: %d %q", rec.Status, rec.Error)
}
}
// 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
+2 -2
View File
@@ -257,7 +257,7 @@ func TestDecisionProviderKeysFailOver(t *testing.T) {
func TestDecisionTriesShareTheClassifierWait(t *testing.T) {
fresh(t)
was := classifyUnit
classifyUnit = 25 * time.Millisecond // the 8 seconds unset are 200ms
classifyUnit = 20 * time.Millisecond // the 15 seconds unset are 300ms
t.Cleanup(func() { classifyUnit = was })
var mu sync.Mutex
var asked []string
@@ -280,7 +280,7 @@ func TestDecisionTriesShareTheClassifierWait(t *testing.T) {
}
s := New()
_, err := s.askClassifier("jw/jev-latest", []string{"feature", "bug"}, before{}, false, "fix this")
if err == nil || !strings.Contains(err.Error(), "no answer in 200ms") {
if err == nil || !strings.Contains(err.Error(), "no answer in 300ms") {
t.Fatalf("a decision model that never answers: %v", err)
}
mu.Lock()
+3 -3
View File
@@ -361,11 +361,11 @@ 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
// (#2934): slower than the 15 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
classifyUnit = 100 * time.Millisecond // 15 seconds are 1.5s, 60 are 6s
t.Cleanup(func() { classifyUnit = was })
s, _, _, j := jevved(t, "", provider.Rule{Use: "b/big", Intent: "debugging"})
j.choice = "debugging"
@@ -382,7 +382,7 @@ func TestJevGivenTheClassifierTimeout(t *testing.T) {
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") {
if r.Rule.N != 0 || !strings.Contains(r.Rule.Classified.Error, "no answer in 1.5s") {
t.Fatalf("unset: %+v", r.Rule.Classified)
}
st := settings.Load()
@@ -26,7 +26,7 @@ func TestNestedGroupsShareTheClassifierWait(t *testing.T) {
fresh(t)
resetClassified(t)
was := classifyUnit
classifyUnit = 60 * time.Millisecond // the 8 seconds unset are 480ms
classifyUnit = 32 * time.Millisecond // the 15 seconds unset are 480ms
t.Cleanup(func() { classifyUnit = was })
// three waits are 1.44s, held past 1.1s; one wait routes at ~0.5s
unroutedLimits(t, 50*time.Millisecond, 1100*time.Millisecond)
@@ -107,7 +107,7 @@ func TestDecisionKeyCutShortIsNotRested(t *testing.T) {
fresh(t)
resetClassified(t)
was := classifyUnit
classifyUnit = 25 * time.Millisecond // the 8 seconds unset are 200ms
classifyUnit = 20 * time.Millisecond // the 15 seconds unset are 300ms
t.Cleanup(func() { classifyUnit = was })
var mu sync.Mutex
var asked []string
+1 -1
View File
@@ -21856,7 +21856,7 @@ function renderReplies(s, keep) {
[...waits, ["", t("No limit")]], ra, (v) => savePrefs({ ...keep, retryAfterCap: v === "" ? null : Number(v) }));
// #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 }));
[8, 15, 30, 60], s.classifyTimeout > 0 ? s.classifyTimeout : 15, "{n} s", (n) => savePrefs({ ...keep, classifyTimeout: n }));
// the agent's instructions as a Claude run's system prompt (off unless on)
const c = segRow("claudeLeanRow", t("Short Claude system prompt"),
t("A Claude subscription answers with the agent's own instructions as its system prompt, in place of Claude Code's, about 1K fewer tokens each request. Still the real Claude Code, but its requests look less like Claude Code's own, which can put the account more at risk"),
File diff suppressed because one or more lines are too long
@@ -87,7 +87,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
}
assert.equal(await page.locator("#routeList").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");
assert.equal(await row.locator(".segs button[aria-pressed=true]").textContent(), w.sec(15), "15 s at first, the default (ESern29751 on X)");
const at = () => page.evaluate(() => [scrollX, scrollY, document.querySelector("#classifyTimeoutRow").closest(".view").scrollTop]);
const moved = [];
+4 -4
View File
@@ -7,11 +7,11 @@ import (
// 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.
// a settings.json without it reads as, is the default: 15, room for a
// classifier that reasons (ESern29751 on X), where it was 8.
func TestClassifyTimeoutKeptAndBounded(t *testing.T) {
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
if w := Load().ClassifyWait(); w != 8*time.Second {
if w := Load().ClassifyWait(); w != 15*time.Second {
t.Fatalf("unset: %v", w)
}
for _, n := range []int{1, 30, 60} {
@@ -34,7 +34,7 @@ func TestClassifyTimeoutKeptAndBounded(t *testing.T) {
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 {
if w := (Settings{ClassifyTimeout: -3}).ClassifyWait(); w != 15*time.Second {
t.Fatalf("-3 waits %v", w)
}
}
+7 -3
View File
@@ -639,7 +639,7 @@ type Settings struct {
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
// haiku needed more than 8, the default then): from 1 to ClassifyTimeoutMost, 0 for
// ClassifyTimeoutDefault. ClassifyWait reads it.
ClassifyTimeout int `json:"classifyTimeout,omitempty"`
// GroupSink, GroupFirstToken and GroupPatience are what every routing
@@ -1532,9 +1532,13 @@ const BusyLoadMost = 10000
// 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.
// agent meanwhile. 15, not 8: a classifier that reasons before it answers
// (MiniMax thinks even asked for none; Grok 4.6 and GPT-6 Luna go no lower
// than low) took 4 to 10 seconds over a real routing prompt, so 8 cut it
// off on most turns and the group lost its intent routing (ESern29751 on
// X). One that doesn't reason answers in a second or two either way.
const (
ClassifyTimeoutDefault = 8
ClassifyTimeoutDefault = 15
ClassifyTimeoutMost = 60
)
+7 -7
View File
@@ -167,7 +167,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 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 15 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 15. 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>
@@ -189,7 +189,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 the <a href="#timeout">configured timeout</a> to answer (8 seconds by default).</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 (15 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>
@@ -292,7 +292,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) 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>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 15 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>
@@ -311,7 +311,7 @@ The number of its kind (0 for none):</pre>
<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 by default; configurable from 1 to 60 s, including its provider’s failover</td></tr>
<tr><td>Classifier timeout</td><td>15 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>
@@ -336,7 +336,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 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>
<p>The turn still goes through. After waiting up to the configured timeout (15 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>
@@ -358,9 +358,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 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>
<p>Yes, if it answers within the configured timeout (15 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 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>
<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 8 s timeout that was the default then 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>
+7 -7
View File
@@ -167,7 +167,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 id="timeout">タイムアウトは全体で共通です。<span class="ui">設定 → モデル → 応答 → インテント判定のタイムアウト</span> で 8・15・30・60 秒から選べます。既定は 15 秒で、Jev を含め次の判定呼び出しから反映され、再起動は不要です。遅い判定モデルには長めの時間が必要なこともありますが、ターンは判定を待ってからルーティングされます。<code>~/.config/magpie/settings.json</code> の <code>"classifyTimeout"</code> には 1〜60 の整数秒を指定でき、0 または未設定なら 15 秒です。範囲内の独自の値は、設定に専用の選択肢として表示されます。</p>
<p>ターミナルからも同じことができます。</p>
<div class="code">
<span class="lang">Terminal</span>
@@ -189,7 +189,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 のゲートウェイを通るので、そのモデルのプロバイダのキーやアカウント、そのフェイルオーバーが使われます。回答には<a href="#timeout">設定したタイムアウト</a>が適用されます(既定は 8 秒)。</li>
<li><b>判定モデルに問い合わせる</b>集めたインテントとあなたのメッセージのテキストを判定モデルに送ります。正確なプロンプトは<a href="#prompt">後述</a>します。この呼び出しはエージェントからのリクエストと同じく magpie のゲートウェイを通るので、そのモデルのプロバイダのキーやアカウント、そのフェイルオーバーが使われます。回答には<a href="#timeout">設定したタイムアウト</a>が適用されます(既定は 15 秒)。</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>
@@ -292,7 +292,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)、タイムアウトは設定でき、既定は 15 秒です。ターン内のツールのやり取り、インテントが決め手にならないターン、キャッシュされた答えでは、待ち時間は増えません。</li>
<li><b>費用。</b>ターンごとに短い呼び出しが 1 回です。入力はメッセージとインテントを合わせた程度、出力は 1〜2 トークンです。上の例では入力 212 トークン、出力 1 トークンでした。サブスクリプションのモデルを判定モデルにすると、これらの呼び出しはそのサブスクリプションの上限に数えられます。</li>
<li><b>プライバシー。</b>メッセージのテキスト(最大約 4,000 文字)は判定モデルのプロバイダに送られます。手元のマシンから出したくなければ、Ollama や LM Studio のローカルモデルを判定モデルにしてください。magpie が保持するのはメッセージのハッシュと答えだけで、メモリ上に 10 分間です。メッセージそのものは保存もログ記録もしません。</li>
</ul>
@@ -311,7 +311,7 @@ The number of its kind (0 for none):</pre>
<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 秒。1〜60 秒に設定可能(プロバイダのフェイルオーバーを含む)</td></tr>
<tr><td>判定モデルのタイムアウト</td><td>既定は 15 秒。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>
@@ -336,7 +336,7 @@ The number of its kind (0 for none):</pre>
<p>2 つの場合だけです。いまのモデルが失敗して別のメンバーが引き継いだときと、会話がモデルのコンテキストを超えそうになり、ルールがより大きいモデルに送ったときです。ターンの途中でインテントを問い合わせ直すことはありません。</p>
<h3>判定モデルが落ちている、または遅いときは?</h3>
<p>ターンはそのまま進みます。設定したタイムアウト(既定は 8 秒)まで待った後、どのインテントも一致せず、グループのほかのルールと順番で決まります。その後 30 秒間はその判定モデルに問い合わせないので、ターンごとにタイムアウトを待つことはありません。理由はトレースに出ます。</p>
<p>ターンはそのまま進みます。設定したタイムアウト(既定は 15 秒)まで待った後、どのインテントも一致せず、グループのほかのルールと順番で決まります。その後 30 秒間はその判定モデルに問い合わせないので、ターンごとにタイムアウトを待つことはありません。理由はトレースに出ます。</p>
<h3>判定モデルがインテントを挙げたのに、ルールのモデルに送られなかったのはなぜ?</h3>
<p>トレースを確認してください。よくある原因は次のとおりです。</p>
@@ -358,9 +358,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>設定したタイムアウト(既定は 15 秒)内に答えるなら使えます。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 秒かかり、既定の 8 秒のタイムアウトではすべてのターンがタイムアウトして、インテントがないものとしてルーティングされました。トレースには毎回そのとおり記録されています。これが想定すべきパターンです。判定モデルがうまく動かなくても失うのはルーティングだけで、ターンは失いません。</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>
+1 -1
View File
@@ -261,7 +261,7 @@
<li>ルールはターンの開始時に決まり、エージェントがツールの結果を返している間もそのターンは同じモデルに留まるため、ベンダーのキャッシュが途中で失われません。唯一の例外として、ターンがモデルのコンテキストを超えて大きくなった場合は、それを受け付けられるメンバーに移ります。</li>
<li>トークン数は、リクエストのサイズから推定した値と、会話の直前のリクエストでベンダーが数えた値のうち、大きいほうを使います。余裕を持たせてください。200k のモデルなら、ルールは 199k ではなく 150k にします。</li>
<li>サブエージェントはそれ自体が独立した会話なので、親のエージェントはそのままに、ルールでサブエージェントだけを別の送り先に送れます。</li>
<li>インテントは、ユーザーが求めていることを数語で表したものです(「テストを書く・直す」「ちょっとした質問」など)。ターンの開始時に、グループの分類モデル(magpie にある任意のモデル。小さく高速で推論なしのものが最適です)に、一致しうるインテントのうちユーザーのメッセージがどれに当たるかを一度だけ尋ねます。送られるのはそのメッセージだけで、会話全体ではありません。分類モデルが失敗した、設定したタイムアウトを超えた(既定は 8 秒。「設定 → モデル → 応答 → インテント判定のタイムアウト」で変更可能)、または判断できなかった場合は、どのインテントも一致せず、そのターンは他のルールに従います。インテントのないルールでいずれにせよ決まる場合は問い合わせず、同じメッセージについて二度尋ねることもありません。その呼び出しは使用量に magpie 自身の呼び出しとして表示されます。何を尋ねるのか、回答がどう使われるのか、失敗したらどうなるのかの詳細は<a href="/docs/ja/intent">インテントルーティング</a>を参照してください。</li>
<li>インテントは、ユーザーが求めていることを数語で表したものです(「テストを書く・直す」「ちょっとした質問」など)。ターンの開始時に、グループの分類モデル(magpie にある任意のモデル。小さく高速で推論なしのものが最適です)に、一致しうるインテントのうちユーザーのメッセージがどれに当たるかを一度だけ尋ねます。送られるのはそのメッセージだけで、会話全体ではありません。分類モデルが失敗した、設定したタイムアウトを超えた(既定は 15 秒。「設定 → モデル → 応答 → インテント判定のタイムアウト」で変更可能)、または判断できなかった場合は、どのインテントも一致せず、そのターンは他のルールに従います。インテントのないルールでいずれにせよ決まる場合は問い合わせず、同じメッセージについて二度尋ねることもありません。その呼び出しは使用量に 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>
+1 -1
View File
@@ -261,7 +261,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, 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>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 (15 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>
+6 -6
View File
@@ -167,7 +167,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 id="timeout">超时是全局设置:在<span class="ui">设置 → 模型 → 回复 → 意图判断超时</span>中可选 8、15、30 或 60 秒。默认 15 秒,从下一次判断调用起生效,Jev 也适用,无需重启。慢的判断模型可能需要更长时间,但这一轮会先等它再路由。在 <code>~/.config/magpie/settings.json</code> 中,<code>"classifyTimeout"</code> 接受 1 到 60 的整数秒数;0 或未设置时使用 15 秒。范围内的自定义值会在设置里显示为单独的选项。</p>
<p>命令行里也可以设置:</p>
<div class="code">
<span class="lang">终端</span>
@@ -189,7 +189,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 或账号,以及它们的故障转移。它需要在<a href="#timeout">设定的超时时间</a>内作答(默认 8 秒)。</li>
<li><b>询问意图判断模型</b>把收集到的意图和你这条消息的文字发给它,完整提示词见<a href="#prompt">下文</a>。这个调用和 Agent 的请求一样,走 magpie 自己的网关,所以用的是该模型所属供应商的 Key 或账号,以及它们的故障转移。它需要在<a href="#timeout">设定的超时时间</a>内作答(默认 15 秒)。</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>
@@ -292,7 +292,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 毫秒),超时时间可设定,默认 15 秒。这一轮后面的工具往返、没有意图需要判断的轮次、命中缓存的回答,都不增加延迟。</li>
<li><b>费用。</b>每轮一次很短的调用:输入大约是你的消息加上意图列表,输出一两个 token。上面的例子是输入 212、输出 1。用订阅里的模型做判断模型时,这些调用会占用该订阅的额度。</li>
<li><b>隐私。</b>你这条消息的文字(最多约 4000 个字符)会发给判断模型所属的供应商。想让它不离开本机,可以用 Ollama 或 LM Studio 里的本地模型来判断。magpie 只在内存里保存消息的哈希值和判断结果,保留 10 分钟;消息原文不存储,也不写日志。</li>
</ul>
@@ -311,7 +311,7 @@ The number of its kind (0 for none):</pre>
<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 秒,可设为 1 到 60 秒,包含其供应商的故障转移</td></tr>
<tr><td>判断超时</td><td>默认 15 秒,可设为 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>
@@ -336,7 +336,7 @@ The number of its kind (0 for none):</pre>
<p>只有两种情况:当前模型失败、由组里另一个成员接手;或者会话超出当前模型的上下文,有规则把它发往上下文更大的模型。一轮之中不会重新判断意图。</p>
<h3>判断模型挂了或者很慢怎么办?</h3>
<p>这一轮照常进行。最多等到设定的超时时间(默认 8 秒)后,意图都不命中,由分组的其他规则和顺序决定。接下来 30 秒内 magpie 不再询问这个判断模型,免得每一轮都要等满超时。路由记录里会写明原因。</p>
<p>这一轮照常进行。最多等到设定的超时时间(默认 15 秒)后,意图都不命中,由分组的其他规则和顺序决定。接下来 30 秒内 magpie 不再询问这个判断模型,免得每一轮都要等满超时。路由记录里会写明原因。</p>
<h3>判断模型说的就是这条规则的意图,为什么没有发给规则指定的模型?</h3>
<p>看路由记录。常见原因有:</p>
@@ -358,7 +358,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>可以,只要它能在设定的超时时间内回答(默认 15 秒)。magpie 会要它最低的推理档位(有 <code>none</code> 用 <code>none</code>,否则用最低一档),并留 2048 个 token,思考不会挤掉答案。不过小而快的模型仍是更好的选择:更便宜,而且每一轮都要等它。</p>
<h3>重试同一条消息,会再问一次吗?</h3>
<p>10 分钟内不会:同一条消息、同一组意图、同一个判断模型,直接用缓存的回答,路由记录里写「同一条消息之前已判断过」。改了意图或者换了判断模型,就会重新询问。</p>
+1 -1
View File
@@ -261,7 +261,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 里的任意模型,建议选小而快、不带推理的。发过去的只有这条消息,不包括整段对话。它出错、超过设定的超时时间(默认 15 秒,在「设置 → 模型 → 回复 → 意图判断超时」中调整)或给不出答案时,意图条件都不命中,这一轮按其他规则走。如果前面有不带意图的规则已经能决定,就不会去问;同一条消息也不会问两次。它的调用在用量里显示为 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>
+8 -8
View File
@@ -145,7 +145,7 @@ A group’s Rules send a turn to one of its models when the turn is of a kind yo
- 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.
- 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.
- A subagent is a conversation of its own, so a rule can send it elsewhere while its agent keeps where it is.
- 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: [Intent routing](https://usemagpie.ai/docs/intent).
- 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 (15 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: [Intent routing](https://usemagpie.ai/docs/intent).
- compacting matches an agent compacting its conversation — Claude Code’s `/compact` 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.
- **Hours and days..** 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 Pause the model instead from the rule’s ⋯ 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.
- **Folders..** in folder matches a turn from an agent working in one of the folders you list, or a folder inside one: `~/work/acme` takes `~/work/acme/web`, not `~/work/acme-old`. 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. `~` is your home folder, `C:\work` is also WSL’s `/mnt/c/work`, and on macOS and Windows case doesn’t count.
@@ -3482,7 +3482,7 @@ You need a [routing group](https://usemagpie.ai/docs/start#routing) with at leas
3. **Pick the classifier.** Intent told by 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: It can pick the model too. A group can’t be saved with an intent and no classifier.
4. **Save, and send a message.** Changes apply from the next turn, with no restart. The Routing tab shows what the classifier said and where the turn went.
The timeout is global: in Settings → Models → Replies → Intent classifier timeout, 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 `~/.config/magpie/settings.json`, `"classifyTimeout"` 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.
The timeout is global: in Settings → Models → Replies → Intent classifier timeout, choose 8, 15, 30 or 60 seconds. It defaults to 15 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 `~/.config/magpie/settings.json`, `"classifyTimeout"` accepts whole seconds from 1 to 60; 0 or a missing field uses 15. A custom value in that range appears as its own choice in Settings.
The same from a terminal:
@@ -3506,7 +3506,7 @@ Every request an agent sends to a group with rules goes through these steps, in
1. **Is this a new turn?.** 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 The rest of the turn). Turns are counted per conversation. A subagent is its own conversation: it shares its agent’s session but starts with different words.
2. **Which intents could decide?.** 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 *without* 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.
3. **Ask the classifier.** magpie sends the classifier the collected intents and the text of your message. The exact prompt is shown below. 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 configured timeout to answer (8 seconds by default).
3. **Ask the classifier.** magpie sends the classifier the collected intents and the text of your message. The exact prompt is shown below. 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 configured timeout to answer (15 seconds by default).
4. **Read the answer.** magpie takes the first whole number in the reply. `1` to `n` names that intent, and `0` 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.
5. **Match the rules.** 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.
6. **Order the models.** 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 Stays 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.
@@ -3605,7 +3605,7 @@ The classifier’s own calls appear in Usage under the agent *magpie*, with thei
## Latency, cost, privacy
- **Latency..** 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.
- **Latency..** 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 15 seconds by default. Tool rounds within the turn, turns where no intent could decide, and cached answers add nothing.
- **Cost..** 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.
- **Privacy..** 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.
@@ -3623,7 +3623,7 @@ The classifier’s own calls appear in Usage under the agent *magpie*, with thei
| What | Value |
| --- | --- |
| Classifier timeout | 8 s by default; configurable from 1 to 60 s, including its provider’s failover |
| Classifier timeout | 15 s by default; configurable from 1 to 60 s, including its provider’s failover |
| Rest after a failure | 30 s, per classifier model |
| Answer cache | 10 min, per classifier + intents + message; in memory |
| Turn decisions kept | 24 h after the conversation’s last request; in memory |
@@ -3652,7 +3652,7 @@ Only in two cases: the model it is on fails and another member takes over, or th
### What if the classifier is down or slow?
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.
The turn still goes through. After waiting up to the configured timeout (15 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.
### Why did the turn not go to the rule’s model when the classifier named its intent?
@@ -3678,11 +3678,11 @@ It can’t be a group: it must be one model, `provider/model`, which magpie chec
### Can I use a reasoning model?
Yes, if it answers within the configured timeout (8 s by default). magpie asks it for the least reasoning it has (`none`, 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.
Yes, if it answers within the configured timeout (15 s by default). magpie asks it for the least reasoning it has (`none`, 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.
### How well does it work with real models?
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 `low` 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.
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 `low` reasoning, so with the 8 s timeout that was the default then 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.
### Does retrying the same message ask again?
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long