382c8c0bdfdcedadbfa35ce1df7bd34f583ec17b
6
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
82962db79a |
routing: a rule can match the system prompt or the last user message, by words or a regex, with no model asked (SucroseMoE on X)
SucroseMoE asked for routing on plain string and regex matches instead
of an intent model: `system[0] matches /^你是对话标题命名/` → model A,
`user[-1] matches /^正在上下文压缩/` → model B, so any harness's title
and compaction calls can be routed without a classifier.
Two new rule condition fields, beside message/effort/subagent/agent:
- system: any block of the system prompt as the agent sent it (Anthropic
system blocks, Chat system/developer messages, Responses instructions
and system/developer items, Gemini systemInstruction). Any block, not
only the first, because Claude Code's first block is its billing
header.
- last: any text of the request's last user message as sent, reminders
the agent adds included, so an anchored ^ still meets a compaction ask.
Ops for both: contains, doesn't contain, starts with, matches (regex,
case-insensitive; a value written /…/ has its slashes dropped). The
gateway reads system and last only when a rule asks (RulesRead), and
decodes raw system JSON lazily then. Like every rule, the decision is
made as a turn starts and its tool rounds keep it.
GUI: Routing → group → Rules, "+" on a rule row offers "System prompt text"
and "Last user message" pills (no modal), with tooltips, placeholders
and the bad-regex mark; zh, zh-TW, ja, de. CLI: `--when "system matches
^You are"`, with aliases system[0], user[-1], last-user. TUI hint, docs
(gateway-routing.md, site start pages) say the same.
Ran, on mote (macOS) until its sshd began refusing connections: gofmt
-l internal/ clean, go vet of provider/gateway/cli/tui, the rule tests;
the routing GUI files (routing-rule*, routing-rules-line,
routing-pause*, group-*, i18n-*, routing-compact, routing-intent-*,
routing-smart-intent) in chromium and webkit: 751 of 781, the 30 reds
being "System prompt" taken by a core word (now "System prompt text"),
routing-rules-line's + menu count (now with system and last), and
routing-intent-entry, red on main since
|
||
|
|
a79d16c684 |
routing: a rule can match on conditions: effort, subagent, message content, agent (aipha2025 on X)
A routing rule takes field/op/value conditions (Rule.Where) beside its
existing match. Fields: reasoning effort, whether the request comes from
a subagent, the user's own message that opened the turn (content), and
the agent. Ops: is, is not, contains, starts with, regex, greater/less
than. Only Claude Code and Codex say when a request is a subagent's.
- provider: rulecond.go parses and evaluates conditions; grouprule.go
and ruleparse.go carry them in a rule.
- gateway: the request's effort, subagent flag and opening user text
reach the rule check (ir.go, rules.go); the trace names a rule's where.
- CLI: `when="..."` on a rule; TUI shows it.
- GUI: the conditions are edited inside the existing rule row (no
dialog), in every language (routing i18n).
- Docs: gateway-routing.md, site start pages (en, zh, ja).
Run:
- GUI: 124/124 on the touched files (routing-rule-ops, routing-rules-line,
i18n-keys and the routing files), chromium and webkit.
- A wider 236-file GUI run is red only where the old code is red too:
menu-input-scroll (#3402), webkit context-fold, intent-entry, row-swap.
- gofmt; go vet darwin, linux (nogui) and windows.
- go test ./internal/provider ./internal/cli ./internal/tui
./internal/gateway pass.
- After the rebase on origin/main
|
||
|
|
c888ef2725 |
routing: a rule's hours are kept in the zone they were set in (gaubeebangeel on X)
magpie on a cloud server in UTC read a routing group's rule hours on the
server's clock, so a Beijing user's 09:00-18:00 held at 17:00-02:00
Beijing time, with nothing saying so.
- provider.TimeWindow carries the IANA zone its hours were set in
("zone": "Asia/Shanghai", omitempty). Holds reads From, To and Days in
that zone (time.LoadLocation, cached; Go's embedded tzdata, so Windows
knows them too). A window with no zone, every one saved before this,
stays on magpie's own clock (time.Local) as before. A zone magpie
doesn't know is refused on save (clean); one in a file edited by hand
makes the window never hold, so the rule is as if absent, never always
on and never hours off. Text() adds " (Zone)"; Line() writes tz=.
- GUI: changing a rule's hours or days in the editor saves the browser's
zone (Intl resolvedOptions().timeZone); hours left alone keep theirs.
/api/groups gives magpie's clock (clock: zone, offset in seconds), and
when its offset differs from the hours' zone the Routing page tells the
zone beside them, on the group's rules and in the editor: "Asia/Shanghai
time" (zh "Asia/Shanghai 时间"), or "server time, UTC+0" (zh "服务器时间
UTC+0") for hours with no zone. Nothing is added when the clocks agree.
zh, zh-TW, ja, de.
- CLI and TUI: time=09:00-18:00@Asia/Shanghai or tz=Asia/Shanghai; with
none, this computer's zone ($TZ, time.Local, the /etc/localtime link)
when it has an IANA name, otherwise none (magpie's clock). An unknown
zone is refused with what one looks like; tz= alone needs time= or
days=. Usage text updated.
- docs/subsystems/gateway-routing.md: the zone rules.
Older magpie reading a shared or synced group ignores zone and reads the
hours on its own clock, as before.
Run in a sandbox HOME with pinned Go caches, first at base
|
||
|
|
f99d27abc2 |
routing: a rule names several models, tried in order
monkeyin_92 on X: "can a rule take several models? Otherwise one rule
with several models is several rules." A rule now takes more than one
model (Rule.More after Rule.Use; `more` in the group's JSON, use=a,b
typed). They go first in that order: when the first fails or rests the
rule's next takes the request, ahead of the models the later matching
rules name and the group's others.
Every reader of Rule.Use goes through Uses/SetUses/MapUses/Without/Names
in grouprule.go:
- cleanRules: each must be the group's, each named once; a pause names one.
- gateway: ruleFor's turn hold, tool rounds and outgrown turns, compaction
(the rule's first that takes the summary, the others in Small),
ruleMembers/ruleOver/applyRule, nestedRules and ruleLed (the one a
nested group's turn stays on), modelRuled, ruleEffort (useEffort asked
of each), ThenUses (leaves out all of the rule's own). RuleHit.More is
in the trace; Instead from More has Unready false, one from a later
rule Unready true, as before.
- ruledEntry: what the group takes is what every one of them takes.
- provider rename, auto/ refs, groupfast, a member's removal (a rule
goes with its last), ShareGroup and its import (one this magpie hasn't
is left out of the rule).
- CLI `group rule add use=a,b` and its listing; `group models-=` keeps a
rule's other models. The TUI shows them joined and keeps the rule when
one is deleted.
- GUI (plugins/routing): a chip per model, a + for the next one, an ×
on each while there is more than one, a chip picks another in its place
(app menu, no native select); the card's tooltip and the trace's why
("…so c/mini, which the rule names after it, goes first"), nested too;
en, zh, zh-TW, ja, de.
Old data: a rule of one model writes no `more`, so groups saved before
read and save unchanged (TestRuleMoreOnDisk). An older magpie reads `use`
alone: its requests go to the first model, the others are plain group
members in group order; if it saves the group, `more` is dropped.
Tests: TestRuleSeveralModelsInOrder, TestRuleEffortReachesTheRulesNextModel,
TestRuleCompactPassesOverTheRulesSmallModel (gateway); TestCleanRulesSeveralModels,
TestRuleMoreOnDisk, TestRuleWithout, TestParseRuleSeveralModels,
TestThenUsesLeavesOutTheRulesOwn, TestRuledEntrySeveralModels,
TestSharedGroupRuleSeveralModels, TestRuleMoreRenamedAndKept (provider);
TestGroupRuleSeveralModelsCmd (cli); TestGroupTakeOutKeepsARulesOtherModels
(tui); routing-rule-models.test.cjs. Broken by hand: ruleMembers on Use
alone turns the first two gateway tests red.
Run at this head:
- gofmt -l clean; go vet -tags nogui clean with GOOS=linux and GOOS=windows
for provider, gateway, cli, tui.
- go test -tags nogui -timeout 45m: internal/provider, internal/cli,
internal/tui ok; internal/gateway ok (384s); the new gateway tests
again after; internal/gui budgets ok.
- GUI: every routing-*.test.cjs plus i18n-keys, click-scroll and
group-member-drag, chromium and webkit (en, zh, zh-TW, ja, de where the
file has them): 1319 pass, 57 red. routing-rule-models passes in both.
The reds are in files that are red the same on origin/main
|
||
|
|
333c167575 |
routing: a rule can set the reasoning its model is asked for (#2633)
dengtongcai asked for a routing rule that picks both the model and the reasoning it is asked for (a quick question goes to a cheap model at low). A rule now has an output field, useEffort (low|medium|high|xhigh|max). When the rule matches, its member is asked for that effort. A member's own fixed effort still wins. Otherwise the rule beats the model's suffix, the turn's pick and the agent's pick. The existing effort condition is unchanged. - The value is fitted to the model's levels (max -> high on a model that tops out at high). A model with no Efforts is sent what the agent asked, untouched. Unset changes nothing. Failover members are not affected. - The trace records it: Rule.UseEffort and the try's RuleEffort (the second Try construction in the candidate loop was missing it). - Saving a group rejects an unknown value or one on a pause (cleanRules). The CLI takes use-effort=; the TUI and CLI lists show " at <effort>". - GUI: a chip after the rule's model, picked from the app menu (pickFrom, no native select), set/changed from the rule's menu. A pause clears it. Strings in zh, zh-TW, ja, de. - A Gemini-protocol client is left unchanged, as with every effort magpie sets. - Docs: docs/subsystems/gateway-routing.md; site docs intent and start (en, zh, ja). What was run, at d4c03a2c5 (rebased on |
||
|
|
23e764d0e0 |
cli: magpie's commands move from the root into internal/cli; the root keeps only main.go
The root held 89 .go files (30 commands, 59 tests). They move as they are to internal/cli (package cli), with git mv so history follows them. The only code change is main() becoming cli.Main(version): the root's new main.go keeps `var version` in package main, so -ldflags "-X main.version=…" in the Makefile, the Dockerfile and magpie-releases, and every workflow, work unchanged. go-winres's rsrc_windows_*.syso still land next to package main in the root. Tests that read testdata by a root-relative path now go up one level (../plugin/testdata/fake, ../sessions/testdata). Five subsystem doc links point at internal/cli/. Run: - go build ./..., gofmt -l, go vet on darwin, linux and windows (nogui) - builds with tags production, dev, "production nogui"; windows -H windowsgui; linux CGO_ENABLED=0 - make release-cli TARGETS="darwin/arm64 linux/amd64 windows/amd64 android/arm64" VERSION=9.9.9-tidy: all four built, binary prints "magpie 9.9.9-tidy" - docker build --build-arg VERSION=7.7.7-tidy: container prints "magpie 7.7.7-tidy" - go test ./internal/cli (default and nogui): 152 tests, the same count as the root on main - go test ./...: all packages pass (agent, gateway, library, provider timed out at 10m under other sessions' load and passed rerun alone with -timeout 40m; none of them changed) - the built binary in a sandbox HOME: version, help, ls, providers, claude, and an unknown command's error |