Skip to content

fix: count unlisted group members when routing long turns - #86

Merged
yetone merged 1 commit into
yetone:mainfrom
charan-rathore:fix/unlisted-group-context
Sep 26, 2026
Merged

yetone merged 1 commit into
yetone:mainfrom
charan-rathore:fix/unlisted-group-context

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

A provider can be unlisted from model pickers and still be served through a routing group. The rule that moves a growing turn to a larger model looks up member contexts in the visible catalog, which omits that provider. When the turn nears its limit, Magpie can keep sending it to the smaller model instead of using the group's bigger one.

Use the served catalog for this context lookup. It includes group members even when their provider is unlisted; it does not change what agents see in their model lists. The regression test uses two local fake providers and confirms the original main stays on the small model at 61k/64k tokens, while this fix moves to the big one. No model, account or network is needed.

Tested: go test -tags nogui $(go list -tags nogui ./... | grep -v '/internal/gui$') (all included packages pass); git diff --check. Linux GUI build remains unavailable here due to missing GTK/WebKit/libsoup/GIO system libraries.

@yetone
yetone merged commit 70a37c6 into yetone:main Sep 26, 2026
4 checks passed
yetone added a commit that referenced this pull request Sep 26, 2026
…p — 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
@yetone

yetone commented Sep 26, 2026

Copy link
Copy Markdown
Owner

Thanks @charan-rathore — verified: your new test fails on main (the turn stays on a/small at 61k/64k) and passes with the fix; the gateway and provider suites pass too. Merged, and it ships in v0.1.115.

The same lookup was also in membersImageInput: an unlisted text-only member was left out of whether the group takes images, so an image could go to a model that can't see it. That's fixed in d2da93e (with a test, same approach), also in v0.1.115.

@charan-rathore
charan-rathore deleted the fix/unlisted-group-context branch October 1, 2026 09:12
yetone added a commit that referenced this pull request Oct 11, 2026
…hether it is a git repository, never seeing magpie's own (plugins #86, Hipple)

A plugin runs in magpie's plugin host, so its process.cwd() is magpie's
folder. The ZCode plugin's Start Plan request said that folder
(C:\Users\<user>\.config\magpie) as the agent's "Primary working
directory", with "Is a git repository: no", and the model looked there.

forwardOnce now calls tellWorkPlace on every request to a plugin's
provider. It reads the request as sent to the plugin with workPlace (the
same reading rules by folder use) and sets two headers on the plugin's
fetch:
- x-magpie-work-dir (provider.WorkDirHeader): the folder, percent-encoded
  (url.PathEscape; decodeURIComponent reads it);
- x-magpie-work-git (provider.WorkGitHeader): yes/no. The agent's own word
  beside the folder (Claude Code's "Is a git repository: true/false",
  OpenCode's "Is directory a git repo: yes/no") wins. Otherwise it is a
  .git in the folder or above it, when the folder is on this computer
  (provider.GitSaid, provider.GitOnDisk in the new workplace.go).
Each is left off when unknown; a folder that isn't on this computer and
that the agent didn't call a repository has no git value, never "no".
host.js's fetch (unsaid) takes both headers off every request a plugin
sends, so a plugin that forwards the headers it was given sends them to
no vendor. Documented in docs/subsystems/provider-plugins.md.

Run: TestPluginToldWhereTheAgentWorks (new) sends the captured Claude Code
and Codex requests, and Pi-style ones from a temp repo subfolder and a
plain folder, through the fake plugin to fake-claude and fake-1. It checks
what the plugin read and that the vendor got neither header. Broken by
hand: without the tellWorkPlace call every case fails; without unsaid in
host.js it fails with "the vendor got X-Magpie-Work-Dir". go test
internal/gateway (-timeout 40m), internal/provider, internal/plugin;
gofmt -l; go vet on darwin, GOOS=linux and GOOS=windows for the three
packages.
yetone added a commit that referenced this pull request Oct 11, 2026
…ay the agent's git repository as it is, not a home or shell they don't know (plugins #86)

The siblings of plugins #86 in the built-ins, for accounts not moved onto
the plugins.

ZCode (zcode_client.go): the Start Plan's environment section already took
the agent's folder from its prompt, but fell back to the user's home when
the prompt named none, said "Is a git repository: no" whatever the folder,
and said magpie's $SHELL/%ComSpec% as the shell. zcodePlace now gives the
folder and the git state: the agent's word, else this disk's
(GitSaid/GitOnDisk). Each line is left out when unknown, and the Shell line
is gone, as in plugin 0.1.15.

Command Code (gateway/commandcode.go): a Go request's config said
workingDir: home and isGitRepo: false always. It now says the agent's
folder (workPlace) and its git state the same way. A request with no
folder keeps the CLI's config in the home, as plugin 0.1.10 does.

Run: TestZCodeEnvironmentSaysOnlyWhatIsKnown and
TestCommandCodeGoSaysTheAgentsFolder (new), TestZCodeStartSentAsTheApp
updated (its /work/proj isn't on this disk, so no git line, and no
shell). Broken by hand: with git always "no" both ZCode tests fail; with
the old commandcode.go 5 of the 6 cases fail. go test internal/gateway,
internal/provider; gofmt -l; go vet darwin/linux/windows.
yetone added a commit that referenced this pull request Oct 11, 2026
…0.1.15 / 0.1.10, which say the agent's folder (plugins #86, Hipple)

Raises the movers' min so keepMovedCurrent updates every moved user:
- @magpie-community/opencode-zcode-auth 0.1.15 (plugins baa788b): the
  Start Plan's environment section says the folder and git repository
  magpie tells it, never magpie's own folder, and leaves out what it
  isn't told and the shell.
- @magpie-community/opencode-commandcode-auth 0.1.10 (plugins 7e67b98): a
  Go request's workingDir and isGitRepo are the agent's.
Both were published by the plugins repo's publish workflow and are the
registry's latest. Run: go test internal/provider.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants