What: in ruleFor, when the classifier errs (an error, no answer within
classifyTimeout, an answer that isn't a number, or resting classifyRest
after a failure) and the conversation's turn before had an intent that
is still one of this turn's (Classified.After), the turn keeps it:
Classified.Intent is that intent, the new Classified.Fallback
(json "fallback") is "previous", and Error is kept. With no intent
before, nothing changes: no rule with an intent matches. The Routing
page's classWhy says "… but couldn't — {err} — so the turn keeps
“{intent}”, as turn {prev} was.", in zh, zh-TW, ja and de too.
Why: #1826 section 3: two timeouts in a row (20:54:43, 20:55:20) sent
turns of a known 复杂 conversation to the group's cheap first member.
Not done: persisting turnRules beside the sticks (the issue's idea 3).
After a restart a turn under way still waits for the next turn, with the
stick holding it meanwhile; with the previous commit the stick's key no
longer changes mid-conversation, which was how the reporter lost both.
Run: TestIntentClassifierFailsKeepsThePreviousIntent (down, then resting,
then a conversation with nothing to keep) fails with the fallback line
taken out and passes now; routing-intent-fallback.test.cjs (Chromium and
WebKit, en/zh/zh-TW/ja/de, 1100px and 390px with no sideways scroll)
30/30, and 10 of 15 red on Chromium with the old routing.js;
routing-intent-entry, routing-effort, panel-routing, routing-folder,
i18n-keys and gui-de pass; go test ./internal/gateway -count=1 green
(295s); go test -tags nogui ./internal/gui green; gofmt -l clean; go vet
on darwin (gateway), GOOS=linux -tags nogui ./... and GOOS=windows ./...
clean.
Not tried: a real classifier timing out in a live session.
What: one helper, userWords/userSaid in prompt.go, says what the user
said in a text: it drops <system-reminder …> blocks (now with a source=
attribute too, as ZCode sends) and any text that begins as an agent
writes for the model alone, and keeps only what follows the Codex app's
"## My request (for Codex):". The leads, beside agentsFor: Codex's
<environment_context>, <user_instructions>, <turn_aborted>,
<user_shell_command>, <subagent_notification>; 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, rewind notices; ZCode's
<plugin_reference>; the Codex app's <in-app-browser-context …>. Each
was taken from the clients' own code or a real transcript (Claude Code
2.1.296, ZCode.app's zcode.cjs, Codex CLI 0.162.1, ChatGPT.app).
Everything that asks "did the user say something" now goes by it:
- turnIn: a user message with nothing of the user's (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 own message it leaves that turn as
it began.
- userText: the classifier is asked about the last user message with
words of the user's, only those words (it was the last user message,
ZCode's agent list after the user's plugin question).
- firstWords (ruleKey and the affinity scope): the words of the first
user message that has any, so an instruction file or notice the agent
changes beside them no longer moves a conversation to a new key
mid-turn. A conversation with no words yet keys on its first message
as before.
- lastUserText (Copilot's Auto, a sibling): the same.
- userSays (the prompt breakdown's turns) is userWords != "".
Why: #1826 (ZCode) and @321sssrt-bit's comment (Codex): a TodoWrite
nudge was classified as a new, harder turn and sent a 常规 turn to the
复杂 member; a task notification or agent list re-classified the turn;
one ZCode session had three firstWords keys, and the turn that lost its
key fell to the group's first member.
Upgrade: a conversation whose first user message held injected text
gets a new key once (its words only), so its stick and turn rule are
looked up afresh on the first request after the upgrade.
Run: user_said_test.go (TestTurnInSkipsWhatTheAgentPutIn,
TestUserTextSkipsWhatTheAgentPutIn, TestFirstWordsAreWhatTheUserSaid,
TestLastUserTextSkipsWhatTheAgentPutIn,
TestIntentHoldsPastWhatTheAgentPutIn end to end through the server,
TestUserSaysPastAReminderWithASource) fails on the old code (all six
red with the five source files put back) and passes now; go test
./internal/gateway -count=1 green (323s); gofmt -l clean; go vet ./...
on darwin, GOOS=linux -tags nogui and GOOS=windows clean.
Not tried: a live ZCode, Claude Code or Codex session against a
group with intent rules; fixtures are the clients' literal strings.
Not done here: persisting turnRules beside the sticks (the issue's
idea 3); the classifier-failure fallback is the next commit.
Ti800 keeps a subscription's quota for one long task in one folder and
wants every other request kept off it (their option A). A pause rule
held by hours, days and agents only; it now holds by folder too.
What changed
- provider.Rule gains ExceptFolders (json exceptFolders, CLI
except-folders=, aliases except-folder/not-in/outside): the folder the
agent works in is in none of them. An agent that says no folder isn't
known to be in one, so except-folders holds for it; folders= still
never matches an unknown folder. Both conditions are allowed on send-to
and pause rules (Rule.ByFolder, inFolders); cleanRules cleans and
dedupes both and lets a pause hold by time, days, agents and folders.
- PausedOut takes the request's folder. The gateway reads it (workDir)
only when a pause by folder is on the way (PausesByFolder); embeddings
and System One's decision calls pass none. Paused carries Folder and
ByFolder for the trace. ruleFor reads the folder for except-folders
rules too.
- Group sharing drops every rule by folder, except-folders included.
- CLI usage, TUI hint, ParseRule/Line round-trip except-folders.
- GUI: the rule editor has a "not in folder" condition beside "in
folder", both shown on a pause and kept when a rule turns into one; a
folder that isn't a whole path and a pause with no condition are
refused; the group's rule and the trace say "not in …", and a paused
reason says the folder read or that the agent said none. Strings in
zh, zh-TW, ja, de.
- Docs: gateway-routing.md, site start.html (en, zh, ja).
What was run
- go test -tags nogui ./internal/provider ./internal/gateway (folder,
pause, share, rule tests); full go test ./... before pushing.
- Broke it by hand: with the gateway's folder read replaced by nothing,
TestPauseByFolder fails (in-task requests went to the other member).
- GUI: routing-pause-folder.test.cjs (new), routing-pause,
routing-folder, i18n-keys and 10 other rule-editor tests in Chromium
and WebKit, en/zh/zh-TW/ja/de, at 1100px and 390px.
- gofmt -l; GOOS=linux and GOOS=windows go vet of the touched packages.
Not tried: a real Claude Code subagent's request against a live group;
by the documented rule a request without a folder is paused off the
kept member, which is what the reporter asked for.
Cario0x on X asked to route by the project being worked on. A group's rule now has a
"folders" condition: it matches when the request's working folder is one of the listed
folders or inside one. It combines (AND) with the existing conditions: tokens, images,
intent, time, agents and quota.
- gateway/workdir.go reads the folder each agent states in its own request:
- Claude Code: "Primary working directory", including "(was …)" after a move.
- Codex: <environment_context><cwd>.
- Pi: <cwd>.
- OpenCode: <env> "Working directory".
The last one stated wins. Assistant text and tool results are ignored. A request
that states no folder matches no folder rule: unknown, never empty.
- provider/rulefolder.go matches a folder only at a path boundary.
- ~ is the home folder.
- C:\x is the same folder as /mnt/c/x, and \\wsl$\Distro\x as /x.
- Case is ignored on macOS and Windows, and always for a drive.
- A rule's folder must be a whole path. Pause rules can't have folders.
- The trace's RuleHit.Folder makes the Routing page say "The agent works in …".
- GUI: an "in folder" condition in the group editor, hidden on pause rules. Strings in
zh, zh-TW, ja and de.
- CLI: `magpie group rule add … folders=~/oss,"~/My Project"`. The TUI shows the
condition.
- Docs: docs/subsystems/gateway-routing.md and site start.html (en, zh, ja).
Fixtures are real requests from Claude Code 2.1.296, Codex 0.162.0 and Pi 1.1.0, run in
a sandbox from a folder named "a&b <c> 中文" or "My Proj", with the sandbox path
replaced.
Run at this head:
- go test ./... green.
- gofmt -l clean.
- go vet green for darwin, GOOS=linux -tags nogui and GOOS=windows.
- GUI routing-folder.test.cjs: chromium and webkit, en, zh, zh-TW, ja and de, 1100px
and 390px (no horizontal scroll). It fails on the old routing.js.
- Related routing, group and i18n GUI tests: 85/85.
- Full GUI suite: 5611/5631 under --test-concurrency=6. Rerun alone, every failure
passes except:
- skill-install-agents-all (chromium, 420px), which is red on origin/main too: #1554.
- The menu-scroll track flake, which flakes on main as well: #1550.
- e2e: a sandbox HOME, a dev build and fake upstreams, with real Claude Code 2.1.296
(`claude -p --model group/fd`).
- From proj/acme/web, rule 1 matched and the request went to kb.
- From proj/acme-old, no rule matched and the request went to ka. The trace and UI
showed the folder.
John asked for a pause in a group's Rules, e.g. a model paused in its
vendor's peak hours. A time rule could only send those turns to another
member first: the paused-for model stayed behind it for failover, went
first when the other was unready, and was kept by affinity mid-turn.
What changed:
- provider: Rule.Pause (`"pause": true`, typed `pause=<model>`). It holds
by time/days and agents only; cleanRules and ParseRule refuse any other
condition, and refuse a pause with none. Pause rules are not send-to rules:
MatchesBesidesIntent, ruledEntry and Ruled() leave them out.
PausedOut(g, ms, agent, at) drops members a pause holds for, from the
group's own rules and each nested group's (a group named = all its
models; a model named = wherever a nested group has it, #625).
- gateway: serve and embeddings run PausedOut on ruleClock before planning,
on every request. Every member paused -> 503 naming each rule
(pausedError). The trace's GroupRef carries Paused.
- GUI: the rule editor's "send to" is now an app-menu action button (send
to / pause); a pause hides the request conditions (clearing them),
keeps hours, days and agents, and isn't saved without one. The group
card's rule reads "→ pause <model>", and the Routing trace says which
model was paused by which rule. Strings in zh, zh-TW, ja, de.
- CLI/TUI: `magpie group rule add <g> pause=<model> time=… days=…`.
- docs: gateway-routing.md step 2; start.html en/zh/ja "Hours and days".
Run:
- gofmt -l clean; go vet -tags nogui ./...; GOOS=linux and GOOS=windows
go vet -tags nogui on gateway, provider, tui, root; go build ./...
- go test -tags nogui ./... under a temp HOME with pinned caches: all ok.
- rules_pause_test.go (3 tests) fails with the PausedOut call in serve
removed (the paused model answers mid-turn, as a fallback, and the
all-paused case returns 200). grouprule_pause_test.go covers clean,
parse/Line, Ruled, Pauses and nested PausedOut.
- GUI: routing-pause.test.cjs in Chromium and WebKit, en/zh at 1100px
and en/zh/zh-TW/ja/de at 420px: 14/14; all 7 Chromium cases fail on
the old routing.js. routing-*, group-*, i18n-keys, gui-ja, gui-de,
click-scroll: 618 pass, 4 fail under --test-concurrency=4
(routing-blocked, -idle-frame, -side-calls, -wb-refused), all of which
pass run alone; routing-side-calls failed 1 of 6 alone and passes
with the old routing.js too, so it is a load flake not touched here.
A group with effort "auto" asks its decision model (Jev or a model asked in words) how hard each user turn is as it begins, and the turn's requests ask for that level. Within a turn it holds, but from one turn to the next it moved freely (xhigh → high → xhigh …), and the reasoning effort is part of what the vendor caches a conversation under: a turn asking for another level reads none of the cache back. Kenoia's production data shows it: 237,632 uncached input tokens on a 26 s xhigh → high switch that had just read 230,912 from cache. The agent kept its own effort fixed; magpie changed it.
Now a new turn keeps the conversation's level when the decision model picks a lower one while the cache is warm (keepsEffort): a higher pick is still taken at once, so a hard turn gets the reasoning it needs and a conversation pays for at most one miss per level. A lower pick is taken on a turn whose cache is lost anyway: one after cacheCold (5 min) with neither a request nor an answer (ruleAnswered now keeps when the vendor last answered), or one after the agent compacted the conversation (under half as long as its last request). Tool-result rounds keep their turn's level as before. The trace's rule shows the level kept (pick) and the one the decision model wanted (wanted, beside classified.effort). Where the change would go as a configuration_update that keeps the cache (the MAGPIE_EFFORT_UPDATES preview: Responses, a GPT-6 model, a ChatGPT account or an OpenAI key), the wanted level is sent and the update carries it, so with the preview on auto still follows every pick.
TestAutoEffortKeepsTheCache (high, xhigh up at once, high held at xhigh on the turn and its tool rounds, medium taken after the cache went cold) fails on the old code (the held turn sent high); TestKeepsEffort covers warm, cold, answered since, compacted, up, same and no pick; TestAutoEffortGoesAsUpdate (a group/core of codex/gpt-6-luna, MAGPIE_EFFORT_UPDATES=on, Responses) sends xhigh at the top and u:high before the next user message. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried against a real account.