infinitex233 (#4738, Discord): Claude Code -> magpie -> a Codex account, and every ToolSearch load dropped cache_read to 0. loadsInPlace sent the additional_tools item (#2660) only to OpenAI's own API, so for an account the loaded tool went into the top-level tools and the cached prefix broke at the tools. Tried on the real ChatGPT backend first (owner's account, sandbox HOME on mote with a copied auth.json whose refresh_token was replaced, so the live token was never rotated; ~/.codex untouched). A probe client sent Claude Code's shape: ToolSearch with two deferred mcp tools, then the tool_reference result, then the calls, 4 requests per run. - additional_tools item (on, and this commit's default): request 2..4 read 7680-8320 tokens from cache on gpt-5.6-terra, gpt-6-luna and gpt-6-sol; the model called read_a and read_b from the item; no "turned away additional_tools" in the log. - tools top-level (off): request 2 and 3 read 0 from cache (8044 and 8163 tokens in), as the reporter saw. So the backend takes it, and this makes it the default for a ChatGPT account (p.Account.Agent == "codex"). Copilot and other sign-ins stay off: not tried. - loadsInPlace: AdditionalToolsOff wins, then AdditionalTools, then an account is in only if it's Codex's, then OpenAI's API as before. - `magpie provider set <id> additional-tools=on|off|default`: off is new (AdditionalToolsOff, kept through an account's Save by accountSettings and through the GUI editor's save like AdditionalTools). The old "off"/"no" meant default; now they turn it off where the default is on. - The 400/422 fallback that names the item still applies, so a backend that stops taking it costs one retry and then sends tools top-level. - No prompt, instructions or identity line changed. Run (mote, at base586b59fe7, this commit and the previous together): - go test -count=1 -timeout 45m ./internal/provider ./internal/gateway ./internal/cli ./internal/gui: provider ok 248s, gateway ok 830s, cli ok 105s; gui FAIL on two filed reds that this doesn't touch: TestSettingsSaveKeepsWhatItDoesNotSend (BusyLoad, #4739) and TestMainWindowCorners/macOS_26_SDK on macOS 27 (#3949). - Rebased on origin/main9feb1024c, then again at this head: gofmt clean, vet darwin/linux/windows ok, provider ok 179s, cli ok 88s, gateway -run 'LoadsInPlace|LoadedTools|Codex|AdditionalTools|InPlace| Account' ok 99s, gui -run 'Provider|Settings|Account' red only on #4739. The whole gateway and gui packages ran at the base only. - gofmt -l clean; go vet -tags nogui ./... for darwin, linux, windows ok. - New TestCodexAccountLoadsInPlace (a fake ChatGPT backend through the gateway: the item with read_a, then tools top-level after additionalToolsOff in providers.json); TestLoadsInPlaceScope extended (Codex on, Codex off, OpenAI off, Copilot off by default and on when set); CLI test for off, on after off, default. - Broken by hand: with the Codex default taken out of loadsInPlace, TestCodexAccountLoadsInPlace and TestLoadsInPlaceScope go red. - GUI node suite not run: no JS changed; the Go editor save only keeps one more field, covered by the Go tests above. Not tried: the reporter's own setup (Windows, gpt-6.1-terra), a real Claude Code client (the probe sent its request shape), Copilot or any other signed-in vendor with the item.
31 lines
1.2 KiB
Go
31 lines
1.2 KiB
Go
package cli
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// additional-tools=on has a provider's Responses API sent a tool Claude
|
|
// Code's tool search loads where it was loaded (#2660); default takes it
|
|
// back, and another value is refused.
|
|
func TestAdditionalToolsPair(t *testing.T) {
|
|
var p provider.Provider
|
|
if err := applyPairs(&p, []string{"additional-tools=on"}); err != nil || !p.AdditionalTools {
|
|
t.Fatalf("on: %v %v", err, p.AdditionalTools)
|
|
}
|
|
// off turns magpie's own default off too (a ChatGPT account's, #4738)
|
|
if err := applyPairs(&p, []string{"additional-tools=off"}); err != nil || p.AdditionalTools || !p.AdditionalToolsOff {
|
|
t.Fatalf("off: %v %v %v", err, p.AdditionalTools, p.AdditionalToolsOff)
|
|
}
|
|
if err := applyPairs(&p, []string{"additional-tools=on"}); err != nil || !p.AdditionalTools || p.AdditionalToolsOff {
|
|
t.Fatalf("on after off: %v %v %v", err, p.AdditionalTools, p.AdditionalToolsOff)
|
|
}
|
|
if err := applyPairs(&p, []string{"additional-tools=default"}); err != nil || p.AdditionalTools || p.AdditionalToolsOff {
|
|
t.Fatalf("default: %v %v %v", err, p.AdditionalTools, p.AdditionalToolsOff)
|
|
}
|
|
if err := applyPairs(&p, []string{"additional-tools=maybe"}); err == nil {
|
|
t.Fatal("maybe taken")
|
|
}
|
|
}
|