Commit Graph
15 Commits
Author SHA1 Message Date
yetone 43fef06978 gateway: a rule's group keeps its own order only for models it plans itself, not ones shared with a group ahead (#2407, #2361)
66e9c014d ranked a rule's named group as one block in the order the
group's own routing planned. A model the group shares with a group
ahead of it is planned in that earlier group's order, so the block
kept First's order and TestRuleNamesAGroupSharingModelsWithOneAhead
went red (alpha answered instead of beta). Member.In hands back the
shared place with ID == the named group, so the check is now on the
model's first place: homeAt keeps the At of the members whose own ID
is the named group, and only those rank as the block.

Run:
- With the block check forced off, TestRuleNamingARotateGroupKeepsItsTurns
  is red; with it, it and TestRuleNamesAGroupSharingModelsWithOneAhead
  are green.
- go test -run 'Desktop|Rule|Rotate|Nested|Shar' ./internal/gateway ok.
- go test -count=1 -timeout 45m ./internal/gateway ./internal/provider ok.
- gofmt clean; go vet -tags nogui darwin, linux, windows ok on gateway.
Full suite: gateway and provider only here; the release head runs ./... before its tag.
2026-10-16 00:46:27 +08:00
ggbdpq abc9006819 gateway: a rule naming a group in the group keeps the group's own routing's order (#2407)
What changed
ruleFirst ranked the candidates of a rule's member by the group's flattened
member order, so a rule that names a group in the group erased whatever that
group's own routing had planned: a rotate group's turn advanced underneath,
but every request the rule put first was served by its first member again.
The rule's own member that is a group in the group is one member now — its
models rank as the group's block, in the order the group's routing planned
them; the members the rules after it name keep their own ranks, so a model
the rule names that the group has too still leads over them (#625,
TestRuleNamesAModelAGroupInItHasToo). TestRuleNamingARotateGroupKeepsItsTurns.

Run
HOME=$(mktemp -d) GOTOOLCHAIN=auto go test -tags nogui -count=1 -p 2 -run 'Rule|Rotate|Nested' ./internal/gateway/ — ok
HOME=$(mktemp -d) GOTOOLCHAIN=auto go test -tags nogui -count=1 -p 2 -timeout 45m ./internal/gateway/ — ok 304s
TestRuleNamingARotateGroupKeepsItsTurns on rules.go at 2e2c8903 (fix stashed): red, "modelA modelA modelA modelA modelA modelA"
gofmt -l clean; go vet -tags nogui (darwin), GOOS=linux -tags nogui, GOOS=windows on ./internal/gateway — clean
go build -o /dev/null . (darwin, known ld warnings only), GOOS=linux -tags nogui, GOOS=windows — ok

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-16 00:46:26 +08:00
yetone b415c0a570 group: a routing group takes images when one of its members sees them, and an image goes to the members that do (#756, HuHong-Tao on v0.1.813: group/auto-deepseek-v4-1-flash turned 1198 image requests away with 400 "model does not support image input" in a day, where commandcode's deepseek-v4.1-flash of the group took them) — groupEntries said a group took images only when every member did (Images ANDed, ImageInput through sharedImageInput, where one explicit text-only answer wins), and the gateway's membersImageInput said the same of a request, so one text-only member turned away every image before any member was tried, and /v1/models gave the group input ["text"]. Since a rule for images can send one past a text-only member, the gateway already dropped text-only members for a request with a new image; it now does so for every group without a model to describe images: a new image goes to the members that see it (an explicit answer, or models.dev's estimate as blindTo reads it for a model of its own), to members magpie knows nothing of when none is known to see, and is turned away (400) only when every member is text-only. With a describer the members keep their order, a text-only one given the image described, as before. groupEntries ORs Images and takes ImageInput through anyImageInput (true when a member's is, false when all are, else unknown); membersImageInput drops the rule's members (the rule's member first changes nothing: one that can't see is passed over). With the owner's real accounts (a copy of the config, Vision off): an image to group/auto-deepseek-v4-1-flash was 400 on origin/main and is answered by the Devin account's deepseek-v4-1-flash ("White"); group/auto-kimi-k3, whose only member that sees is an OpenCode Go key without a subscription, went from 400 to that member's 403. TestGroupImages (a group with one member that sees takes images, all text-only doesn't), TestGroupImagesFromAMemberThatSees, TestKnownTextOnlyModelRejectsImagesBeforeUpstream (an ordered group with its text-only member first sends the image to the one that sees), TestRuleImages and TestRuleImagesUnlistedMember now expect the image answered by the member that sees; they fail on the old code. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. 2026-10-04 15:01:11 +08:00
yetone a11b74883e group: a routing group tells agents its largest member's context window, not its shortest's (#712, Moody-Sin on v0.1.779: Pi on group/deepseek showed 82.4%/200k, where the group's DeepSeek V4.1 Flash members hold 1M) — groupEntries took the smallest window any member had (since 09c635cf/c83e03d5, "otherwise its shortest model's"), and the group 腾讯DeepSeek has OpenCode Zen's deepseek-v4-flash-free among its ten members, which models.dev gives 200000 (the rest: deepseek-v4.1-flash 1000000 at WorkBuddy and OpenCode Go, muse-spark-1.3-contributor 1048576), so /v1/models, Pi's models.json and every agent's config said 200k and Pi compacted there. No commit changed this code lately; what brought the window down is that member: added to the group, or its figure on models.dev — which of the two is not known. The shortest made sense while a too-long conversation was never sent past the member it overflowed; since b5cfca54 (v0.1.771, #700) an overflow goes on to the members left not known to be too small for it (withRoom), and the agent is told to compact only when none has room, so the group's window is its largest member's. A context set on the group (magpie group set … context=) still wins, below the members' too; a length rule (ruledEntry) never lifts past the largest, so its comment says so. The CLI's and TUI's help say "largest model's". TestGroupToldItsLargestWindow (the reporter's members, one window unknown: old code 200000, new 1048576) and TestContextSetByUser (largest by default, a lower set one wins) fail on the old code and pass; TestRuleImages now expects the group's 1M. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried with the reporter's accounts: a conversation past 200k reaching the free member first costs it one refused request before the next member answers. The model tooltip in the Gateway page says so too: "Context: n tokens (the largest of its models')" / 上下文(组内模型中最大的), where it said the least. 2026-10-04 02:44:59 +08:00
Comic Chang 49f40b463f Configure per-model context windows and output limits (#279)
A provider that serves a model the catalogue does not list, or lists at the
wrong size, has a window and a reply limit magpie cannot know: both fall
back to whatever the catalogue says about the model's maker, which for such
a provider is nothing at all.

  magpie model context relay-a/gpt-5.5 262144
  magpie model output  relay-a/gpt-5.5 131072
  magpie model context 'relay-a/*' 200000
  magpie model output  relay-a/gpt-5.5 --reset

Both are looked for in the same order as each other: this model, then
`<provider id>/*`, then the provider's own list, then the catalogue. A
model's own value wins over its provider's. The reply limit is new; the
window is not — `Provider.Contexts` has been there, with a `"*"` of its own,
settable through `magpie provider set <id> context.<model>=`, and this
reuses it rather than shadowing it.

That reuse is the point rather than a detail. A context is a routing input
and not only a number agents are shown: at 95% of a held member's window a
request moves to a member that takes more, so two sources of truth would
mean the gateway routing on one number while agents are told another.
`magpie model context` is a second way to set the same field, not a second
field.

Both reach the agents. Pi keeps a model's window and reply limit in its own
models.json, OpenCode keeps its limit, and Crush, Droid, Cline, Qoder and
Zcode keep their own; an agent reads those files when it starts, so a limit
set here that never reaches them is a limit that does not take effect.
`magpie provider set` has always told the agents, and this behaves the same
way rather than introducing a second, quieter path. The test asserts each
setter reaches them exactly once — the two paths differ (one saves the
provider file, the other settings and then says so) and that difference is
worth pinning. An end-to-end pass confirms it: with a Pi models.json in
place, `magpie model context relay-a/sol 999999` writes `contextWindow:
999999` into `providers.magpie.models`.

A `0` is refused rather than read as a reset, naming `--reset`; a mistyped
model id is refused the way `magpie model name` refuses the same id; a reset
says what is actually in force instead of claiming to be back to the
vendor's list while a provider-wide value still applies; and
`magpie model context <provider>/*` reports that value rather than saying
the provider serves no such model. Validation happens where the entry is
written, so one hand-edited bad key cannot stop a theme or a window size
from saving, and #288's walk moves these on a provider rename without a
line here.
2026-10-01 02:14:22 +08:00
yetone d00d9ffe6f gateway: a model that can't see images is given what a model that can says of them (让Magpie支持配置图像识别模型) — until now an image sent to a model the catalog knows takes text only was turned away in the latest turn and left out of older turns and tool results, so an agent on DeepSeek, GLM or any text-only model couldn't be shown a screenshot at all. Now each image in such a request is described once by the vision model and the description goes in its place, in every protocol (Chat, Responses, Anthropic, Gemini), current turn, older turns and tool results alike: "[Image, as <model> describes it for this model, which can't see images:] … [End of the image's description]". The describer is asked through the gateway itself (User-Agent magpie-vision/1, recorded as agent magpie), with a system prompt to transcribe text, code, errors and UI state exactly and not to answer or guess; images are described four at a time, and a description is kept (256, by model+image) since an agent sends a conversation's images again every turn, a failure not kept. An image of the latest turn that can't be described is a 502 saying why; one in an older turn is left out as before. Settings → Images → Image recognition picks the model: Automatic (a small model that sees — a Claude account's, a Codex account's, the cheapest of an API key's, another account's), Off (images turned away as before), or any model or group that sees; an id that doesn't resolve is refused. In a routing group the description is made only when a text-only member is actually tried, so a rule that routes images to a member that sees costs nothing; a member whose image can't be described is skipped for the next, the last one answers 502. The describer's own request is never described again, so a Vision set to a text-only model is turned away, not looped. Checked in a sandbox HOME against a local vendor: an image sent over Chat and over Anthropic to a text-only model reached it as the description, the describer was asked once per image, and the Settings row and its picker in light and dark. 2026-09-29 01:20:31 +08:00
yetone 73b650b281 routing: a request a group's rule sent to a member that can't take it fails over to the members the rules after it that match too name, in their order, before the group's others (#112) — two rules for images, the first's model out of quota, now go on to the second's vision model rather than the group's text-only first; and while the first's rests, the second's goes first. The trace names who comes next, and says a turn stays with whoever took it, not the model the rule named 2026-09-27 20:28:38 +08:00
yetone 0f59ca2fc0 routing: a turn a rule sent to one of a group's models stays on it for its tool rounds when another member is on the same account — the conversation was kept to the account that answered, so its next request went to that account's first member: Claude Code's turn Jev sent to codex/gpt-5.5 had its tool results answered by claude/claude-sonnet-5, both served by one provider (as Opus and Sonnet on one Claude sign-in are). And a group whose intents are levels has every turn at one of them however torn Jev is: 继续,再加一个基准测试 after a 复杂任务 came out 0.54 to 0.46, below the confidence counted, and went to the group's first member; a torn turn now stays at the level of the one before, or takes the likelier. Tested with Claude Code through Jev and the real Claude and ChatGPT subscriptions 2026-09-27 02:25:24 +08:00
yetone 6fd85894ea routing: Jev (TypeSafe's System One) as a group's classifier — asked once as a turn begins which of the rules' intents the message is, with how sure it is, and, for a group with effort auto, how hard the turn is to think about; the turn's requests then ask their model for that reasoning, where the agent asked for any. TypeSafe is a decision provider: it serves no conversation and is no group's member 2026-09-27 01:53:04 +08:00
yetone a77f7c1fcc gateway: a test that when a rule's vision model fails, the text-only member that answers is sent the conversation without its older images (#87) 2026-09-26 18:25:16 +08:00
Charan RathoreandCharan Rathore d583acaf46 fix: avoid sending group images to text-only fallbacks (#87)
Co-authored-by: Charan Rathore <charan-rathore@users.noreply.github.com>
2026-09-26 18:25:34 +08:00
yetone d2da93ef11 group: an unlisted text-only model still keeps images out of its group — whether a group takes images was asked of the listed models only, so an image went to a member kept out of the pickers that can't see it; now every member counts, as for the context since #86 2026-09-26 17:52:54 +08:00
Charan RathoreandCharan Rathore 70a37c63f1 fix: count unlisted group members when routing long turns (#86)
Co-authored-by: Charan Rathore <charan-rathore@users.noreply.github.com>
2026-09-26 17:52:49 +08:00
yetone d4135b55e1 group: a routing group's models can be another group — group/<id> as a member, routed in its place by its own routing and rules, so Coder can be deepseek-v4-pro then Fast, a Coder rule can send a turn to group/fast and Fast's own rules pick within it; a group can't be in itself directly or through another (refused on save, left out of the picker), groups go at most 8 deep, and one can't be removed while another has it. The Routing tab shows a group in a group as a heading with its models under it, the packet going through it, and the log says what each group's rules and classifier decided 2026-09-26 13:41:17 +08:00
yetone 696c8e70e7 group: rules send a kind of turn to a chosen model — a group's Rules (Routing view, or magpie group rule add|rm|mv) put one of its models first for a turn that is long (tokens ≥ N), carries an image, asks for reasoning (on or at least a level) or comes from certain agents; the first that matches decides as the turn begins and the turn stays there through its tool rounds, moving only if it outgrows its model's context, the others staying behind it for failover; a subagent keeps a place of its own so a rule can send it elsewhere while its agent stays; the trace says which rule sent a turn where. Turn affinity also now sees past the system message Claude Code puts after tool results, which made each of its tool rounds look like a new turn 2026-09-26 03:53:33 +08:00