magpie icon indicating copy to clipboard operation
magpie copied to clipboard

Routing 页上,模型窗口装不下的成员整行不显示(trace 里没有任何记录)

Open MYCF711 opened this issue 1 month ago • 4 comments

(这个 issue 我先误开成了空标题的探针,现在改写成本来的内容,抱歉。)

现象

Routing 页上,一个路由组里开启了的成员,有时整行都不出现 —— 不是灰的、不是淡的,是没有。

我这边稳定复现的是一个 6 个成员的组:页面上只列出 13 个座位,opencode-zen-free 的免费 DeepSeek(200K 窗口)在超过 ~200K token 的请求里完全消失,刚好低于 200K 的请求又能看见它。所以一开始看起来像「GUI 时好时坏」。

原因

roomy(internal/gateway/fallback.go)会把「模型窗口已知小于本次请求」的候选从 cs 里拿掉,放进 small,留作最后兜底。这是对的 —— 留着它也只会被拒。

问题是这些座位既不在 pl.order,也不在 pl.left,而 trace.beginFor 只写 Order: pl.order, Left: pl.left。于是 trace 里对它们没有任何记录,GUI 拿不到数据,自然画不出一行。

它们不是限流、不是被禁用、不是额度用尽 —— 只是这次请求比它的窗口长。

修复

分支:MYCF711/magpie 的 pr/small-seats(基于 main 的 de54b4ff,与下面的新路由分支互相独立)

  • Route 加 Small []Weighed,跟 Left 一起在 saveRoute、traceState、sessionRoute 三处复制
  • 页面把这类座位画在组内本来的位置,写明「这个请求比它的窗口长,本轮跳过了它」
  • 一个坑值得记一下:行表 wOf/rOf 只从 Order 和 Left 建。只从 Small 画出来的座位拿不到 Weighed、也没有 route id,makeRow(undefined) 会让整块舞台画不出来 —— 我第一版就是这样,结果一行都没有。Small 也要登记进去。

同一页上另外两处(同一批反馈,一起改了):

  • pools/服务商那一行的 title 盖住按钮:账号名挂在整行的 title 上。行上的 title 是行内每个控件最近的 title,鼠标停在 Routing 选项上时账号名正好盖住要点的按钮(开着「账号打码」就是一整块黑点)。现在挂在名字上。
  • gHint 回落错:先读 MODES[v] || !v,于是所有在 MODES 里登记过的路由(网关插件提供的)都落到智能的说明上:选了它,下面解释的却是智能。

验证

gofmt -l 干净;go vet 的 linux / windows / nogui 三种;go build 三种;internal/gateway 的 trace/session/sink/group/roomy/plan/route/nested/weighted/affinity 相关测试、internal/routes 全包、GUI 脚本预算都过。

Chromium 里对着这份资产跑了一个夹具(含「被落下的成员 / 429 座位 / 两个免费座位」):被落下的那行显示「这个请求比它的窗口长,本轮跳过了它」,用行本身的颜色;限流那行保持红色;组里每个成员都在舞台上。

没跑 Playwright 套件(这台机器没装),所以新增的 i18n 词条是读页面确认的,不是 make test-ui 过的。

关于 PR

这个仓库的 PR 策略是 collaborators_only,我的账号开不了 PR,所以只能发成 issue。分支已经在 fork 上推好:

git fetch https://github.com/MYCF711/magpie.git pr/small-seats

如果你愿意看,放开一档 PR 策略我就开正式 PR;或者你觉得哪条不该进,直接说,我改。

MYCF711 avatar Oct 26 '26 13:10 MYCF711

另一个独立的东西:新路由 frugal/expiring

和上面的 bug 无关,属于产品决策,我单独说。

分支:MYCF711/magpie 的 pr/frugal-expiring(基于 1bb8143b,与 pr/small-seats 互相独立,两个分支都只含自己那一笔,可以只合一个)

它做什么

四层,给「同一批座位在不同时间价值不同」的池子:

  1. 免费 —— 厂商对这个模型不占订阅额度/积分(Seat.Free,网关因为 ByFree 会填)
  2. 会过期 —— 手上的东西在某个已知时刻用完,越早的越早花(Allowance.Renewal,本来就把「积分先耗尽、再重置」折成同一个时刻)
  3. 永不过期 —— 没有窗口,或窗口永不到期
  4. 未知 —— 额度不知道

免费排第一,因为免费座位不会因为用完而损失什么;然后是会过期的、最快的先花 —— 因为只有它会真正作废。所以每日签到额度排在「一个月后到期的包」之前,永不过期的等别人都答不上来再动。

同一小时内到期的两个窗口,在选择上算同一时刻,保持服务商列出的顺序(和 free 一样)。

为什么不做成插件

JS 网关路由现在能表达第 2~4 层,但表达不了第 1 层:seatJSON 里没有 Free,沙箱里也没有 fetch/fs 去算出来,插件只能靠静态表猜。这个把层级放在 Free 真正已知的地方。

没有改动任何上游代码

routes.Register 本来就是路由的接入点,frugal.go 在自己的 init() 里按 RouteID 自己注册,核心和内置的 rotation 插件都没动。

如果更希望它作为内置 rotation 插件里 FreeFirst 的邻居 —— 那只是一行位置的移动。我放在 internal/routes 只因为 Free 是在那里填的,这个由你定。

两行 GUI 是把它列进组和服务商的编辑器:magpie 提供、但页面不认识的路由,用户选不到。

验证

go build ./... 三种平台;internal/routes 全包(含 13 个子用例);GUI 脚本预算。

真实 magpie 上(14 个座位、7 个服务商的组):设置该路由后,请求先到免费模型,用尽的账号排在最后,和层级一致。


关于 PR

这个仓库的 PR 策略是 collaborators_only,我的账号开不了 PR,所以只能发成 issue。两个分支都已经在 fork 上推好,且互相独立:

git fetch https://github.com/MYCF711/magpie.git pr/small-seats
git fetch https://github.com/MYCF711/magpie.git pr/frugal-expiring

放开一档 PR 策略我就开正式 PR;或者你觉得哪条不该进,直接说,我改。

MYCF711 avatar Oct 26 '26 13:10 MYCF711

再加一个小的(同一页,免费模型那种「反过来」的读法)

分支:MYCF711/magpie 的 pr/free-seat(同样基于 de54b4ff)

Weighed.Free 是网关为「按免费称重」的路由填的(Free first),但页面只在选择器的说明文字里读过它,座位那一行从来没读。于是免费座位按它自己的窗口显示,而免费模型的窗口是厂商自己的记账 —— OpenCode Zen 的免费 DeepSeek 就写着 credits 已用满 —— 结果池子里唯一永远能答的那个座位,被画成最接近用完的样子:

改前(上游原样)  mycf711  [low]  "已用 100% · 几乎用尽"   rgb(75,75,83)
改后              mycf711  [free] "免费 · 不花额度"        rgb(28,28,33)

同一批实测里,付费座位 95% 仍然照旧说「留到最后」;而正在限流的免费座位仍然说它的限流、仍然是红的 —— 红色在这页上代表「用不了」,限流正是,与模型是否免费无关。

四种语言都补了词条(en / zh / zh-TW / ja / de),并附了 Chromium 下的前后对照与一个 Playwright 测试。


分支基点已统一

上游这几天走得快,我把三个分支都 rebase 到了同一个 de54b4ff,互不依赖,可以任意顺序合并:

分支 内容 相对上游
pr/small-seats 被 roomy 落下的成员回到页面上 + pools 的 title 不再盖住按钮 + gHint 回落错 6 文件
pr/frugal-expiring 新路由 frugal/expiring 5 文件
pr/free-seat 免费座位说它不花额度,不标红 5 文件
git fetch https://github.com/MYCF711/magpie.git pr/small-seats
git fetch https://github.com/MYCF711/magpie.git pr/frugal-expiring
git fetch https://github.com/MYCF711/magpie.git pr/free-seat

三个分支我都单独检出、单独编译、单独跑过相关测试(不是只在合并状态下跑)。

仓库的 PR 策略是 collaborators_only,我开不了 PR,只能发成 issue —— 放开一档我立刻开正式 PR。

MYCF711 avatar Oct 26 '26 14:10 MYCF711

Fixed in 6afbe3f30, released as v0.1.1636 (building now). A member whose model's context window the request is longer than now keeps its row on the Routing page. The row is faded like any seat that's held out and reads "request longer than its 200K window · passed over". The why list says it's left out because the request won't fit its context window, and that it's asked only once every member with room is out of its allowance. If the last resort does ask it, the row moves into the order as usual.

Thanks @MYCF711. I took your finding but not the shape of the patch. Instead of a separate Route.Small list, the trace lists the member in the route's existing left with window set, the same way unlisted, capped and out-of-credit seats are carried, so the session copies and the last resort need no second list. The row-map bug your patch fixes doesn't exist on main. The gHint change matters only in your fork, where frugal was added to the modes. The account list tooltip covering the Routing buttons is real, and it's now #3785.

One limit: roomy records these rows only when the order has one row per candidate. When it doesn't, a member left out still shows only by its absence, as before.

I'm leaving this open until you confirm it on your setup.

yetone avatar Oct 26 '26 19:10 yetone

Verified on 0.1.1684 (which has 6afbe3f3), four shapes on the same asset. Close it.

shape what left carried
flat group, routing: free free/window=2000
routing: free over group/inner left on the default free/window=2000
routing: free over group/inner also free free/window=2000
the same, inner group with affinity: session free/window=2000

So the limit you named — "roomy records these rows only when the order has one row per candidate" — didn't fire in any shape I have. Nested members and a session affinity both still give one row per candidate, and the row comes back with the window it lacked.

All three of your calls land, and I'm not arguing any:

  1. The shape. left already carries seats not asked for three other reasons; a second list (Route.Small) was a table I didn't need. Yours is the smaller change and the one the session copies and the last resort already understand.
  2. The row-map bug. It was mine: my first cut drew rows only from Order and Left, so a seat I introduced in a third list got no Weighed and makeRow(undefined) took the stage down. On main there is no third list, so there was nothing to fix.
  3. gHint. Only reachable in my fork, where I put frugal into MODES. Upstream MODES holds the nine built-in routings and GROUP_HINT has all nine, so MODES[v] || !v never decides anything. Withdrawn.

One thing that is this issue's neighbour but not this issue, filed separately as #3847: a seat's Weighed.Free is lost inside a nested group (the inner group's p.Routing is "", so ByFree never holds and wg.free is never built), and its row reads "100% used" again — b9ab1723's fix stops at the group boundary. window is not affected; it reached every shape above.

The account-list tooltip is on the name cell now, as you named it in #3785: branch pr/pool-tooltip off 508911e4.

MYCF711 avatar Oct 27 '26 05:10 MYCF711