routing: a group with no rules says how it routes (@canlee886 on X)
The editor said nothing of what a group does with no rules. Without rules the group goes by its Routing (Smart unless set): the member whose allowance renews soonest first, ties in the listed order, the next taking over when one fails. One line under Rules now says so (and names the routing when another is set); with one model or Manual the existing line stays. Added in zh, zh-TW, ja, de. Layout unchanged. Run on mote at the change: routing-rule-example (extended: the line in every language, Smart and In order, gone once a rule is added; Chromium and WebKit, 1100 and 390 wide), routing-advanced, routing-rule-ops/ remove/drag/columns/models/effort, routing-entry, routing-intent-entry, group-editor-fits/align, group-template, i18n-keys: all pass. Not run: the whole GUI suite, Go (no Go changed), the real app.
This commit is contained in:
@@ -275,6 +275,7 @@ the key's leaves the call as asked, with a log line (`compactRefused`).
|
||||
- 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`.
|
||||
- A group with no rules routes by its Routing (Smart unless set otherwise: the member whose allowance renews soonest first, ties in the listed order, the next taking over on a failure), and the editor says so in a line under Rules (`rHint2` in [`plugins/routing/client.js`](../../internal/gui/assets/plugins/routing/client.js), @canlee886 on X: it said nothing of it); with one model or routed Manual it says what holds the rules back instead. `routing-rule-example.test.cjs`.
|
||||
- A rule may name several members (`Rule.More` after `Rule.Use`, `more` in the group's JSON, `use=a,b` typed; monkeyin_92 on X: one rule, several models, not a rule each). They go first in that order, ahead of the later matching rules' members (`ThenUses` leaves out every one the rule names) and the group's others: when the first fails or rests the rule's next takes the request, and the hit says so (`RuleHit.More`; `Instead` is that next one with `Unready` false, where an `Instead` from a later rule comes with `Unready` true). `Uses`, `SetUses`, `MapUses`, `Without` and `Names` in [`grouprule.go`](../../internal/provider/grouprule.go) are how every reader goes through them: `cleanRules` (each must be the group's, each named once, a pause names one), the turn's hold, the tool rounds and compaction (`ruleFor`, the rule's first that takes the summary), `nestedRules` and `ruleLed` (the one of them a nested group's turn stays on), `ruleEffort` (the rule's `useEffort` asked of each), `ruledEntry` (what a group takes is what every one of them takes), a model's rename and removal (a rule goes with its last), `ShareGroup` and its import (one this magpie hasn't is left out of the rule), the CLI's `groups rules` and the TUI. The editor draws a chip per member with a + for the next and an × on each while there is more than one (`rUses`/`setUses` in [`plugins/routing/client.js`](../../internal/gui/assets/plugins/routing/client.js)). A rule of one member writes no `more`, so a group saved before it reads and saves as it was. A magpie from before it reads `use` alone: its requests go to the first, and the others are plain members in the group's order; if it saves the group, `more` is dropped. `TestRuleSeveralModelsInOrder`, `TestCleanRulesSeveralModels`, `routing-rule-models.test.cjs`.
|
||||
- The editor's rules are checked top first, so their order is theirs to set: a rule's number is its handle (`ruleHandle`, `.rt-rhandle`), dragged (`dragRows`, as the members are) or moved a place with Alt+↑/↓, the rules renumbered at once; the grip beside it shows on hover only, and Move up and down stay under its ⋯ (`moveRule`). Saved as the group's `rules` in their new order. `routing-rule-drag.test.cjs`.
|
||||
- A rule can set the reasoning its member is asked for (`Rule.UseEffort`, `useEffort` in the group's JSON, `use-effort=low` typed; #2633, dengtongcai: an intent picks the model and the effort as a pair). It is an output like `Use`, not a condition like `Effort`. `ruleFor` copies it onto the hit (`RuleHit.UseEffort`) from the rule that put a member first, outer or nested; `ruleOver` keeps that rule's members, and `ruleEffort` gives each candidate of them the level fitted to its model's own (`fitLevel`), which `withFixedEffort` writes into the request's field for its protocol (Chat's `reasoning_effort`, Responses' `reasoning.effort`, Anthropic's thinking budget or `output_config.effort`) even when the agent asked none. A member fixed at an effort keeps its own; otherwise the rule's beats the model's suffix, the turn's pick and the agent's pick, and isn't bounded by the group's levels. A model whose levels aren't known (`Efforts` empty) is asked as the agent asked, as with the auto verdict. The members the group fails over to are asked it too (#3664): the effort is the turn's decision, so when the rule's own member is turned away the member that takes the request over is asked the same level, fitted to its model, rather than the agent's. A rule that names the candidate goes before one it only fails over from, and a nested group's rule decides for that group's members only: when the whole nested group fails, the outer group's member outside it is asked as the agent asked, or by the outer group's rule (`TestIntentEffortSurvivesTheGroupsFailover`, `TestNestedRuleEffortStaysInItsGroup`). A Gemini-protocol client's request is left as it came, as for every effort magpie sets. `cleanRules` refuses a value outside `provider.Efforts` and a pause with one. The try records it (`Try.RuleEffort`), and the Routing page says the rule set it. `rule_effort_test.go`, `grouprule_useeffort_test.go`, `routing-rule-effort.test.cjs`.
|
||||
|
||||
@@ -8734,7 +8734,9 @@ function routingPage(part) {
|
||||
// only what holds the rules back is said in a line: how they work is
|
||||
// under the ⓘ beside Add a rule
|
||||
rHint2.textContent = d.members.length < 2 ? t("With two models or more, a rule can send some turns to one of them first.")
|
||||
: d.routing === "manual" ? t("The rules wait while you pick the model by hand.") : "";
|
||||
: d.routing === "manual" ? t("The rules wait while you pick the model by hand.")
|
||||
: none ? (d.routing ? t("No rules: the members go by the routing set under Advanced, {mode}; if one fails, the next takes over.", { mode: t((GROUP_ROUTE_OPTS.find((o) => o[0] === d.routing) || ["", d.routing])[1]) })
|
||||
: t("No rules: Smart routing. The member whose allowance renews soonest goes first, ties in the listed order; if it fails, the next takes over.")) : "";
|
||||
rHint2.hidden = !rHint2.textContent;
|
||||
let focus = null;
|
||||
d.rules.forEach((r, i) => {
|
||||
|
||||
@@ -403,6 +403,8 @@ magpie.strings({
|
||||
"As a turn begins, Jev is asked once which of the intents the message is, and how hard the turn is when it picks the effort. An intent it isn't sure of matches no rule. Its calls show in the usage as magpie’s own.": "每轮开始时问 Jev 一次消息意图;若由它选推理强度,同时问本轮难度。没把握的意图不命中任何规则。其调用在用量中记为 magpie 自身的。",
|
||||
"It was told turn {prev} reasoned at {level}, which a message that only carries on from it needs too.": "并告知它第 {prev} 轮按 {level} 推理,仅承接上一轮的消息也需同等强度。",
|
||||
"Add an example rule": "添加示例规则",
|
||||
"No rules: Smart routing. The member whose allowance renews soonest goes first, ties in the listed order; if it fails, the next takes over.": "没有规则:按智能路由。额度最先重置的成员优先,相同则按列表顺序;失败时由下一个接手。",
|
||||
"No rules: the members go by the routing set under Advanced, {mode}; if one fails, the next takes over.": "没有规则:成员按高级里设置的路由({mode})排序;失败时由下一个接手。",
|
||||
"planning, design, or a hard problem to think through": "规划、设计,或需要深入思考的难题",
|
||||
"With two models or more, a rule can send some turns to one of them first.": "组内有两个及以上模型时,可用规则将某些轮次先发给其中一个。",
|
||||
"Checked top first when you send a message: the first that matches sends that turn to its model first; the rest stay behind it if it fails. A turn under way is never moved.": "发送消息时从上往下检查:第一条命中的规则将本轮先发给其指定的模型,其余成员作为故障转移。进行中的一轮不会换模型。",
|
||||
@@ -1171,6 +1173,8 @@ magpie.strings({
|
||||
"As a turn begins, Jev is asked once which of the intents the message is, and how hard the turn is when it picks the effort. An intent it isn't sure of matches no rule. Its calls show in the usage as magpie’s own.": "每輪開始時問 Jev 一次訊息意圖;若由它選推理強度,同時問本輪難度。沒把握的意圖不命中任何規則。其呼叫在用量中記為 magpie 自身的。",
|
||||
"It was told turn {prev} reasoned at {level}, which a message that only carries on from it needs too.": "並告知它第 {prev} 輪按 {level} 推理,僅承接上一輪的訊息也需同等強度。",
|
||||
"Add an example rule": "新增範例規則",
|
||||
"No rules: Smart routing. The member whose allowance renews soonest goes first, ties in the listed order; if it fails, the next takes over.": "沒有規則:依智慧路由。額度最先重置的成員優先,相同則依清單順序;失敗時由下一個接手。",
|
||||
"No rules: the members go by the routing set under Advanced, {mode}; if one fails, the next takes over.": "沒有規則:成員依進階中設定的路由({mode})排序;失敗時由下一個接手。",
|
||||
"planning, design, or a hard problem to think through": "規劃、設計,或需要深入思考的難題",
|
||||
"With two models or more, a rule can send some turns to one of them first.": "組內有兩個及以上模型時,可用規則將某些輪次先發給其中一個。",
|
||||
"Checked top first when you send a message: the first that matches sends that turn to its model first; the rest stay behind it if it fails. A turn under way is never moved.": "傳送訊息時從上往下檢查:第一條命中的規則將本輪先發給其指定的模型,其餘成員作為故障轉移。進行中的一輪不會換模型。",
|
||||
@@ -1937,6 +1941,8 @@ magpie.strings({
|
||||
"As a turn begins, Jev is asked once which of the intents the message is, and how hard the turn is when it picks the effort. An intent it isn't sure of matches no rule. Its calls show in the usage as magpie’s own.": "ターンの開始時に、メッセージがどのインテントに当たるかと、推論レベルを選ぶ場合はターンの難しさを、Jev に 1 回尋ねます。確信のないインテントはどのルールにも一致しません。その呼び出しは使用量に magpie 自身のものとして表示されます。",
|
||||
"It was told turn {prev} reasoned at {level}, which a message that only carries on from it needs too.": "ターン {prev} が {level} で推論したことも伝えています。それを続けるだけのメッセージも同じだけ必要です。",
|
||||
"Add an example rule": "例のルールを追加",
|
||||
"No rules: Smart routing. The member whose allowance renews soonest goes first, ties in the listed order; if it fails, the next takes over.": "ルールなし:スマートルーティング。枠が最も早くリセットされるメンバーが先、同じなら一覧の順。失敗すると次が引き継ぎます。",
|
||||
"No rules: the members go by the routing set under Advanced, {mode}; if one fails, the next takes over.": "ルールなし:メンバーは詳細設定のルーティング({mode})の順に使われます。失敗すると次が引き継ぎます。",
|
||||
"planning, design, or a hard problem to think through": "計画、設計、またはじっくり考える必要がある難問",
|
||||
"With two models or more, a rule can send some turns to one of them first.": "2 つ以上のモデルがあれば、ルールで一部のターンをそのうちの 1 つへ優先して送れます。",
|
||||
"Checked top first when you send a message: the first that matches sends that turn to its model first; the rest stay behind it if it fails. A turn under way is never moved.": "メッセージを送るたびに上から確認します。最初に一致したルールがそのターンを指定モデルへ優先して送り、失敗した場合は残りが後に控えます。進行中のターンが移されることはありません。",
|
||||
@@ -2705,6 +2711,8 @@ magpie.strings({
|
||||
"As a turn begins, Jev is asked once which of the intents the message is, and how hard the turn is when it picks the effort. An intent it isn't sure of matches no rule. Its calls show in the usage as magpie’s own.": "Zu Beginn einer Runde wird Jev einmal gefragt, welcher Absicht die Nachricht entspricht und, wenn es den Effort wählt, wie schwer die Runde ist. Eine Absicht, bei der es unsicher ist, trifft auf keine Regel zu. Seine Aufrufe erscheinen in der Nutzung als eigene von magpie.",
|
||||
"It was told turn {prev} reasoned at {level}, which a message that only carries on from it needs too.": "Ihm wurde mitgeteilt, dass Runde {prev} {level} Reasoning nutzte; eine Nachricht, die nur daran anknüpft, braucht das ebenso.",
|
||||
"Add an example rule": "Beispielregel hinzufügen",
|
||||
"No rules: Smart routing. The member whose allowance renews soonest goes first, ties in the listed order; if it fails, the next takes over.": "Keine Regeln: Smart-Routing. Das Mitglied, dessen Kontingent am frühesten erneuert wird, kommt zuerst, bei Gleichstand die Reihenfolge der Liste; fällt es aus, übernimmt das nächste.",
|
||||
"No rules: the members go by the routing set under Advanced, {mode}; if one fails, the next takes over.": "Keine Regeln: Die Mitglieder gehen nach dem unter Erweitert gesetzten Routing ({mode}); fällt eines aus, übernimmt das nächste.",
|
||||
"planning, design, or a hard problem to think through": "Planung, Entwurf oder ein schwieriges Problem zum Durchdenken",
|
||||
"With two models or more, a rule can send some turns to one of them first.": "Ab zwei Modellen kann eine Regel bestimmte Runden zuerst an eines davon senden.",
|
||||
"Checked top first when you send a message: the first that matches sends that turn to its model first; the rest stay behind it if it fails. A turn under way is never moved.": "Beim Senden einer Nachricht von oben geprüft: Die erste zutreffende Regel sendet diese Runde zuerst an ihr Modell; die übrigen folgen dahinter, falls es fehlschlägt. Eine laufende Runde wird nie verschoben.",
|
||||
|
||||
@@ -32,11 +32,11 @@ const groups = () => ({
|
||||
});
|
||||
|
||||
const words = {
|
||||
en: { edit: "Edit", save: "Save", intent: "planning, design, or a hard problem to think through" },
|
||||
zh: { edit: "编辑", save: "保存", intent: "规划、设计,或需要深入思考的难题" },
|
||||
"zh-TW": { edit: "編輯", save: "儲存", intent: "規劃、設計,或需要深入思考的難題" },
|
||||
ja: { edit: "編集", save: "保存", intent: "計画、設計、またはじっくり考える必要がある難問" },
|
||||
de: { edit: "Bearbeiten", save: "Speichern", intent: "Planung, Entwurf oder ein schwieriges Problem zum Durchdenken" },
|
||||
en: { smart: "No rules: Smart routing", order: "No rules: the members go by the routing set under Advanced, In order", edit: "Edit", save: "Save", intent: "planning, design, or a hard problem to think through" },
|
||||
zh: { smart: "没有规则:按智能路由", order: "没有规则:成员按高级里设置的路由(按顺序)", edit: "编辑", save: "保存", intent: "规划、设计,或需要深入思考的难题" },
|
||||
"zh-TW": { smart: "沒有規則:依智慧路由", order: "沒有規則:成員依進階中設定的路由(按順序)", edit: "編輯", save: "儲存", intent: "規劃、設計,或需要深入思考的難題" },
|
||||
ja: { smart: "ルールなし:スマートルーティング", order: "ルールなし:メンバーは詳細設定のルーティング(順番)", edit: "編集", save: "保存", intent: "計画、設計、またはじっくり考える必要がある難問" },
|
||||
de: { smart: "Keine Regeln: Smart-Routing", order: "Keine Regeln: Die Mitglieder gehen nach dem unter Erweitert gesetzten Routing (Der Reihe nach)", edit: "Bearbeiten", save: "Speichern", intent: "Planung, Entwurf oder ein schwieriges Problem zum Durchdenken" },
|
||||
};
|
||||
|
||||
function serve(lang, posts) {
|
||||
@@ -107,7 +107,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
for (const lang of Object.keys(words)) {
|
||||
const w = words[lang];
|
||||
for (const width of [1100, 390]) {
|
||||
test(`${engine} ${lang} ${width}: a group with no rule offers an example rule`, async (t) => {
|
||||
test(`${engine} ${lang} ${width}: a group with no rule says how it routes and offers an example rule`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 1400 }, reducedMotion: "reduce" })).newPage();
|
||||
@@ -123,11 +123,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const tryIt = ed.locator("button.rt-try");
|
||||
await ed.locator(".rt-rules").waitFor({ state: "attached" });
|
||||
assert(await tryIt.isVisible(), "the example's button shows");
|
||||
// the button alone: no line of text added under Rules
|
||||
assert(await page.evaluate(() => {
|
||||
// the default said in one line under Rules (@canlee886 on X: a group
|
||||
// with no rules said nothing of how it routes)
|
||||
const line = async () => page.evaluate(() => {
|
||||
const h = document.querySelector(".rt-gedit .rt-rules").previousElementSibling;
|
||||
return h.classList.contains("hint") && h.hidden;
|
||||
}), "no line under Rules");
|
||||
return h.classList.contains("hint") && !h.hidden ? h.textContent : "";
|
||||
});
|
||||
assert((await line()).startsWith(w.smart), `Smart's line: ${await line()}`);
|
||||
assert.equal((await line()).split("\n").length, 1);
|
||||
// nothing past the editor's side, nor a sideways scroll
|
||||
const past = await page.evaluate(() => {
|
||||
const e = document.querySelector(".rt-gedit").getBoundingClientRect();
|
||||
@@ -143,11 +146,19 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await rows.first().locator(".rt-cond.in textarea").inputValue(), w.intent);
|
||||
assert.match(await rows.first().locator(".rt-model").textContent(), /opus/, "to the last member");
|
||||
assert(!(await tryIt.isVisible()), "gone once a rule is there");
|
||||
assert.equal(await line(), "", "no line once a rule is there");
|
||||
const body = await saved(page, ed, w, posts);
|
||||
assert.deepEqual(body.rules, [rule("a/opus", { useEffort: "", intent: w.intent })]);
|
||||
assert.equal(body.classifier, "typesafe/jev-latest");
|
||||
assert.deepEqual(errors, []);
|
||||
|
||||
// routed In order, the line names that
|
||||
shape = { routing: "order" };
|
||||
await page.reload();
|
||||
ed = await openEditor(page, w);
|
||||
await ed.locator(".rt-rules").waitFor({ state: "attached" });
|
||||
assert((await line()).startsWith(w.order), `In order's line: ${await line()}`);
|
||||
|
||||
// one model, or routed by hand: no example
|
||||
for (const s of [{ members: ["a/opus"], memberInfo: [member("a/opus")] }, { routing: "manual" }]) {
|
||||
shape = s;
|
||||
|
||||
Reference in New Issue
Block a user