agent: a caller key of the gateway's own in Claude Code's and Codex's config survives a model pick (#2545)

What changed:
- writeTiers (claude.go) wrote env.ANTHROPIC_AUTH_TOKEN = wiredKey() on
  every model and tier pick, and putProvider beside the thread-provider
  tables (codex.go) wrote experimental_bearer_token = at.gwKey() the same
  way: a caller key of the gateway's own the user put in their place was
  written over, and it was never stashed, so no Disconnect brought it
  back. Both keep such a token now, as a sync keeps one (mergeKept,
  keyHolds of #2510): only a value the gateway would refuse is wired
  over. The sign-in field's own Set is unchanged, as that switch is the
  user's own.
- The sharing key magpie itself made is never one of those: access.Default
  says a secret is the default key ConfigureLAN keeps, sharing on or off,
  and the two write points ask it before keeping what they hold. With
  sharing off the key stays enabled in the store, Authenticate still took
  it, and keyHolds held it for the user's — Rekey could no longer bring
  gateway.Token back (TestRekeyGivesWSLAgentTheSharingKey, deterministic
  red on the first cut of this patch, found in review). Claude has no WSL
  twin: the sharing key reaches it by an address beyond loopback
  (MAGPIE_ADDR), and a pick kept it the same way there, so
  TestClaudeSharingOffWiresGatewayTokenBack holds a sharing on, then off,
  to gateway.Token.
- docs/subsystems/agent-wiring.md's sentence about a hand-set key said
  Check reports it; Check has taken one since #2510, and a pick keeps it
  now too, the sharing key excepted.

Patch by ggbdpq (c809f7ad), the second cut after review: the first
(835d3bf8) turned TestRekeyGivesWSLAgentTheSharingKey red, as the
sharing key stays enabled with sharing off and was kept as the user's.
Applied unchanged on e085d6e92.

Run (landing worktree, sandbox HOME, private GOCACHE):
- Broken by hand: access.Default returning false: FAIL
  TestRekeyGivesWSLAgentTheSharingKey (wsl_rekey_test.go:88, "sharing
  off: key sk-magpie-key-…") and TestClaudeSharingOffWiresGatewayTokenBack
  (claude_test.go:291). claude.go and codex.go put back to main's: FAIL
  TestClaudePickKeepsAGatewayKeyOfTheUsers and
  TestCodexPickKeepsAGatewayKeyOfTheUsers ("a model pick wrote over the
  user's caller key"). Restored: all four and TestRekey* ok.
- gofmt -l: clean. go vet darwin (gui), GOOS=linux and GOOS=windows
  -tags nogui: clean.
- Full suite, go test -tags nogui -timeout 45m ./... under pipefail at
  7380d99e4 (this on e085d6e92), load ~180: every package ok except
  internal/agent, which ran past 45m as a whole (2704s, the test at the
  deadline 5s in; #2544, this run posted there). Alone at -timeout 45m
  it ran out again (2702s, load ~210). Alone with -v -timeout 100m: ok,
  854 tests passed in 3017s, the five above among them.
- Rebased on cb05dc2d1 (#2576, #2578, #2657: no internal/agent or
  internal/access file): build and vet of both packages ok.
Not tried: a real WSL distro, or the real app's sharing toggles.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
This commit is contained in:
yetone
2026-10-17 16:12:14 +08:00
co-authored by ggbdpq
parent 84cd686afa
commit 252bc61ce9
6 changed files with 212 additions and 4 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ something else shows up as drift.
- While this machine's Claude Desktop is on magpie, Claude Code's shared settings get `CLAUDE_CODE_DISABLE_EXPLORE_INHERIT_CAP="1"` (`writeExplore` in `claudeIn`, [`claude.go`](../../internal/agent/claude.go)). Claude Code 2.1.295's Explore inherit cap can otherwise replace Desktop's `mythos-magpie` compatibility alias with Opus. This disables that cap, not the model choices of all subagents. It applies with Desktop alone or beside a connected Claude Code, including model picks and Sync; WSL twins do not get it. A user's existing value, including an empty string, stays. The stash (`claude.explore_inherit_cap`) marks only magpie's value: taking Claude Code off magpie leaves it while Desktop is on, and taking Desktop off removes it only if the user has not changed it. Since the settings file is shared, other Claude Code sessions reading it see the flag while Desktop is connected too.
- Claude Code's tier and subagent models the user had set for their own endpoint (`claudeOwnEnv`) are stashed with that endpoint and token when magpie is wired in, and come back with them when magpie steps out, by Disconnect or by Claude Code's own model (#1050). So does their main model in the env (`ANTHROPIC_MODEL`, a Bedrock model id beside `CLAUDE_CODE_USE_BEDROCK` for one), which magpie takes out while wired in because it outranks a pick in `/model`.
- Claude Code's provider switches (`agentenv.ClaudeProviders`: `CLAUDE_CODE_USE_BEDROCK`, `_VERTEX`, `_FOUNDRY`, `_ANTHROPIC_AWS`, `_ANTHROPIC_GOOGLE_CLOUD`, `_MANTLE`, Claude Code 2.1.300) send it to that cloud's own endpoint and pass `ANTHROPIC_BASE_URL` over, so with one on it never reaches magpie (jw1dev on X: Bedrock refused magpie's model, and magpie showed nothing). Claude Code reads 1, true, yes and on as on (`claudeSwitchOn`). One that is on in the settings magpie writes is taken out on every route that writes the wiring (`dropClouds` in `writeTiers` and `Sync`), its raw value stashed (`claude.cloud.<var>`, under the distro's id for a WSL twin), and put back as written when magpie steps out (`putClouds` in `unroute`), unless the user set it again since. The cloud's own variables (`AWS_*`, `ANTHROPIC_VERTEX_PROJECT_ID`, …) and a switch that is off stay. Where magpie doesn't write it, Check says so, naming the variable, the cloud and where (`claudeCloud`): the managed settings, which win over the user's; `~/.claude.json`'s env, under the user's settings; and, for this machine's Claude Code, the login shell's environment (`proc.LoginEnv`, read but never set in magpie's), under every settings file. A project's `.claude/settings.json` isn't read: magpie doesn't know which folders Claude Code runs in. T3 Code's Check says the same of the user's `~/.claude` settings, which are put over its magpie instance's environment, and a switch put on that instance goes at its next write; that Check first says when the instance's `ANTHROPIC_BASE_URL` no longer reaches the gateway (`t3EnvOf`), as every agent's Check does, so a port move rewrites it too. The drift's detail is shown in the row's line and its pill through `tNotice` (`claude-cloud-drift.test.cjs`). Claude Desktop's Code tab runs with `CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST`, under which Claude Code ignores a switch in settings files, so Desktop needs neither.
- Claude Code's sign-in (`login`) is magpie's key (`""`, the default) or claude.ai (`claudeai`). claude.ai writes `ANTHROPIC_AUTH_TOKEN` empty, which Claude Code reads as no key: it keeps its claude.ai login and sends that to magpie, which never passes it on (`claudeSignIn` in the gateway). Every later write keeps the token empty (`wiredKey`), and a key put there by hand is reported by Check, not taken for magpie's. It's offered only where the gateway takes any key (`gwKey() == gateway.Token`: loopback, a WSL distro mirrored), not from a distro under NAT while magpie is shared on the network, where only the sharing key gets in. The choice is stashed, so it survives Disconnect and a port move. An empty token counts as magpie's only beside the address magpie last wrote (`claude.wired_at` in the stash, which Rewire carries to the new port, `keyOurs`): an endpoint of the user's own with an empty token stays theirs when the model goes back to Claude Code's own.
- Claude Code's sign-in (`login`) is magpie's key (`""`, the default) or claude.ai (`claudeai`). claude.ai writes `ANTHROPIC_AUTH_TOKEN` empty, which Claude Code reads as no key: it keeps its claude.ai login and sends that to magpie, which never passes it on (`claudeSignIn` in the gateway). Every later write keeps the token empty (`wiredKey`), and a caller key of the gateway's own put there by hand is taken for magpie's, by Check and a model pick alike, kept as the user left it (`keyHolds`, #2545); a key the gateway would refuse is reported by Check and wired over, and so is the sharing key magpie itself made (`access.Default`), once sharing is off — magpie's own, however well the gateway still takes it. It's offered only where the gateway takes any key (`gwKey() == gateway.Token`: loopback, a WSL distro mirrored), not from a distro under NAT while magpie is shared on the network, where only the sharing key gets in. The choice is stashed, so it survives Disconnect and a port move. An empty token counts as magpie's only beside the address magpie last wrote (`claude.wired_at` in the stash, which Rewire carries to the new port, `keyOurs`): an endpoint of the user's own with an empty token stays theirs when the model goes back to Claude Code's own.
- Claude Code's auto mode review (`CLAUDE_CODE_AUTO_MODE_SERVER`, `claudeReviewEnv` in [`claude.go`](../../internal/agent/claude.go)) is written `"0"` while Claude Code is routed through magpie and none of the models it can reach there is one Anthropic reviews (`claudeReviewed`, by `gateway.AutoModeReviewed`): those it is shown (and Claude Desktop's while Desktop is on magpie), a shown group's members, those providers' fallbacks, and the models it is set to. Off, it classifies locally from the start, as it does anyway behind a gateway that doesn't answer, without the "isn't eligible because your requests go through 127.0.0.1:3425" notice (1EFLOPS on X). Any reviewed model leaves it unset, since `/model` can take the session there; a model hidden from Claude Code doesn't count. It is rewritten on every model set and `Sync`, so adding a Claude provider turns the review back on. magpie's value is kept apart in the stash (`claude.auto_mode_server`), a user's own is left alone, and it goes when Claude Code is taken off magpie (`desktopOnly`, `unroute`). T3 Code's magpie instance, which runs Claude Code on the gateway through its own environment, carries the same `"0"` there by the models it lists (`t3InstanceJSON` in [`t3code.go`](../../internal/agent/t3code.go)); a value in the user's `~/.claude` settings comes after it.
- Claude Code takes one window (`CLAUDE_CODE_MAX_CONTEXT_TOKENS`, `claudeContextEnv` in [`claude.go`](../../internal/agent/claude.go)) for every model it doesn't know. Claude Code alone on magpie is told its main model's (`claudeWindow`). While Claude Desktop is on magpie too, its Code tab runs Claude Code on the same `~/.claude/settings.json` with every model Desktop lists, so magpie tells it the largest window of those and of Claude Code's own models, and holds each model below it to its own with `modelSettings.<id>.autoCompactWindow` (`claudePlan` in [`claude_budget.go`](../../internal/agent/claude_budget.go), #2025: the least held a 1M model to 131K). Claude Code 2.1.296 matches that key by the id it was handed, lowercased and without `[1m]`; it comes before the top-level `autoCompactWindow`, which serves a model without one. `CLAUDE_CODE_AUTO_COMPACT_WINDOW` would take precedence over both, so in this mode magpie's working window goes in the top-level `autoCompactWindow` instead, and an entry is written only where a model's window or its own threshold differs from what it would run at without one. magpie's entries and top-level value are stashed (`claude.model_budgets`, `claude.compact_default`) and go when Desktop leaves magpie; the user's own entries, top-level value and variables stay, a user's entry past its model's window (or `auto`) holds the largest to that window, and with a `CLAUDE_CODE_AUTO_COMPACT_WINDOW` of the user's the least window is told as before.
- Claude Code is told what each of magpie's models can do in `CLAUDE_CODE_MODEL_CAPABILITIES` (`claudeCapsEnv`, `claudeCapabilities` in [`claude.go`](../../internal/agent/claude.go)): `<model>=effort[,xhigh_effort][,max_effort]` for those it is shown, and, while Claude Desktop is on magpie, for Desktop's `mythos-magpie-<number>` ids its Code tab hands it. A Claude model Claude Code knows gets no more than Claude Code gives it (Opus and Sonnet 4.6: no xhigh), and one with no known levels isn't named. A model that reaches max without xhigh (GLM-5.3 at low/high/max, DeepSeek V4 at high/max) is said to have xhigh too: the gateway runs xhigh at max for it (`fitEffort`), and Claude Code 2.1.299 turns Ultracode down without `xhigh_effort` ("Ultracode isn't available on …"), which in Desktop is the Ultracode level and dynamic workflows (leesunrise2364 on Discord; `TestClaudeModelCapabilities`). A value of the user's is left alone.
+25
View File
@@ -228,6 +228,31 @@ func LANSecret() string {
return ""
}
// Default says secret is the sharing key magpie itself made (the default
// key ConfigureLAN keeps), whether sharing is on now or not: magpie's own,
// never one the user brought, so a write that keeps "a caller key of the
// gateway's own the user put there" must not keep it (#2545: with sharing
// off the key stays enabled in the store, Authenticate still took it, and
// Rekey could no longer bring gateway.Token back). An older magpie kept it
// in the settings alone; that value answers too, short of its revoked
// mirror.
func Default(secret string) bool {
if secret == "" {
return false
}
mu.Lock()
defer mu.Unlock()
s := settings.Load()
keys, err := load()
if err == nil {
if i := slices.IndexFunc(keys, func(k Key) bool { return k.LAN || k.ID == s.LANKeyID }); i >= 0 {
return subtle.ConstantTimeCompare([]byte(secret), []byte(keys[i].Secret)) == 1
}
}
return s.LANKey != "" && !strings.HasPrefix(s.LANKey, revokedLANPrefix) &&
subtle.ConstantTimeCompare([]byte(secret), []byte(s.LANKey)) == 1
}
// Export returns credentials only for the encrypted backup bundle.
func Export() ([]Key, error) {
mu.Lock()
+12 -1
View File
@@ -13,6 +13,7 @@ import (
"strings"
"time"
"github.com/yetone/magpie/internal/access"
"github.com/yetone/magpie/internal/agentenv"
"github.com/yetone/magpie/internal/catalog"
"github.com/yetone/magpie/internal/desktopdir"
@@ -1479,9 +1480,19 @@ func claudeIn(at place) *Agent {
}
}
gw := gwAt()
tok := wiredKey()
// a caller key of the gateway's own where magpie's token goes goes
// through magpie all the same: theirs stays, as a sync keeps one
// (mergeKept, keyHolds); only a value the gateway would refuse is
// wired over (#2545). The sharing key magpie made is magpie's own,
// however much Authenticate takes it, so it never counts as theirs
// (Default): sharing going off brings gateway.Token back
if v, _ := edit.GetJSON(path, "env.ANTHROPIC_AUTH_TOKEN"); v != tok && keyHolds(v, tok) && !access.Default(v) {
tok = v
}
kvs := []edit.KV{
{Path: "env.ANTHROPIC_BASE_URL", Value: gw},
{Path: "env.ANTHROPIC_AUTH_TOKEN", Value: wiredKey()},
{Path: "env.ANTHROPIC_AUTH_TOKEN", Value: tok},
{Path: "env.ANTHROPIC_SMALL_FAST_MODEL", Value: spell(tiers["haiku"])},
{Path: "model", Value: spell(main)},
}
+114
View File
@@ -5,7 +5,9 @@ import (
"path/filepath"
"testing"
"github.com/yetone/magpie/internal/access"
"github.com/yetone/magpie/internal/edit"
"github.com/yetone/magpie/internal/gateway"
"github.com/yetone/magpie/internal/provider"
)
@@ -177,3 +179,115 @@ func TestClaudeEffortMax(t *testing.T) {
t.Fatal("ultra taken")
}
}
// #2545: a key made under Gateway keys, put in Claude Code's
// ANTHROPIC_AUTH_TOKEN in place of magpie's, goes through magpie all the
// same, so a model pick keeps it, as a sync keeps one. A key the gateway
// doesn't take is still wired over.
func TestClaudePickKeepsAGatewayKeyOfTheUsers(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
if err := provider.Save(provider.Provider{ID: "deepseek", Name: "DeepSeek", Chat: "https://api.deepseek.com/v1", Key: "k", Models: []string{"pro"}}); err != nil {
t.Fatal(err)
}
path := filepath.Join(home, ".claude", "settings.json")
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(path, []byte(`{"theme": "dark"}`), 0o644); err != nil {
t.Fatal(err)
}
a := claude(home)
if err := a.Field("model").Set("deepseek/pro"); err != nil {
t.Fatal(err)
}
if tok, _ := edit.GetJSON(path, "env.ANTHROPIC_AUTH_TOKEN"); tok == "" {
b, _ := os.ReadFile(path)
t.Fatalf("not wired:\n%s", b)
}
secret, err := access.Update("add-key", access.Change{Name: "claude"})
if err != nil {
t.Fatal(err)
}
if err := edit.SetJSON(path, edit.KV{Path: "env.ANTHROPIC_AUTH_TOKEN", Value: secret}); err != nil {
t.Fatal(err)
}
if d := a.Check(); d != "" {
t.Fatalf("a key the gateway issued is drift: %s", d)
}
if err := a.Field("model").Set("deepseek/pro"); err != nil {
t.Fatal(err)
}
if v, _ := edit.GetJSON(path, "env.ANTHROPIC_AUTH_TOKEN"); v != secret {
b, _ := os.ReadFile(path)
t.Fatalf("a model pick wrote over the user's caller key:\n%s", b)
}
if err := edit.SetJSON(path, edit.KV{Path: "env.ANTHROPIC_AUTH_TOKEN", Value: "sk-not-this-gateways"}); err != nil {
t.Fatal(err)
}
if err := a.Field("model").Set("deepseek/pro"); err != nil {
t.Fatal(err)
}
if v, _ := edit.GetJSON(path, "env.ANTHROPIC_AUTH_TOKEN"); v == "sk-not-this-gateways" {
t.Fatalf("a key the gateway doesn't take is kept: %q", v)
}
}
// #2545's review: the sharing key magpie itself made is never the user's.
// Claude Code is wired to an address beyond loopback (MAGPIE_ADDR), where
// magpie writes the sharing key while sharing is on and gateway.Token when
// it is off; a pick kept the sharing key, which still authenticates (it
// stays enabled in caller-keys.json with sharing off), so sharing off
// never brought gateway.Token back. Claude has no WSL twin: the address is
// how its writeTiers reaches the sharing key, as a distro is Codex's.
func TestClaudeSharingOffWiresGatewayTokenBack(t *testing.T) {
t.Setenv("MAGPIE_ADDR", "192.0.2.10:3425")
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
if err := provider.Save(provider.Provider{ID: "deepseek", Name: "DeepSeek", Chat: "https://api.deepseek.com/v1", Key: "k", Models: []string{"pro"}}); err != nil {
t.Fatal(err)
}
path := filepath.Join(home, ".claude", "settings.json")
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(path, []byte(`{"theme": "dark"}`), 0o644); err != nil {
t.Fatal(err)
}
a := claude(home)
if err := a.Field("model").Set("deepseek/pro"); err != nil {
t.Fatal(err)
}
if tok, _ := edit.GetJSON(path, "env.ANTHROPIC_AUTH_TOKEN"); tok != gateway.Token {
b, _ := os.ReadFile(path)
t.Fatalf("wired with sharing off: key %q, want magpie's own\n%s", tok, b)
}
if err := access.ConfigureLAN(true, false); err != nil {
t.Fatal(err)
}
lan := access.LANSecret()
if lan == "" {
t.Fatal("no sharing key")
}
if err := a.Field("model").Set("deepseek/pro"); err != nil {
t.Fatal(err)
}
if tok, _ := edit.GetJSON(path, "env.ANTHROPIC_AUTH_TOKEN"); tok != lan {
t.Fatalf("sharing on: key %q, want the sharing key", tok)
}
if err := access.ConfigureLAN(false, false); err != nil {
t.Fatal(err)
}
if err := a.Field("model").Set("deepseek/pro"); err != nil {
t.Fatal(err)
}
if tok, _ := edit.GetJSON(path, "env.ANTHROPIC_AUTH_TOKEN"); tok != gateway.Token {
t.Fatalf("sharing off: key %q, want gateway.Token back", tok)
}
}
+19 -2
View File
@@ -17,6 +17,7 @@ import (
"github.com/pelletier/go-toml/v2"
"github.com/yetone/magpie/internal/access"
"github.com/yetone/magpie/internal/catalog"
"github.com/yetone/magpie/internal/codexcat"
"github.com/yetone/magpie/internal/edit"
@@ -392,12 +393,28 @@ func codexIn(at place) *Agent {
s := settings.Load()
return codexAsyncSync(path, at.key("codex.async"), routed, s.CodexAsyncCompact, s.CodexAsyncCompactPercent)
}
// keptBearerToken is the table's bearer token when it is one the
// gateway takes: a caller key of the gateway's own the user put in
// magpie's token's place goes through magpie all the same, so theirs
// stays, as a sync keeps one (keyHolds); only a value the gateway would
// refuse is wired over (#2545). The sharing key magpie made is magpie's
// own, however much Authenticate takes it, so it never counts as theirs
// (Default): sharing going off brings gateway.Token back
keptBearerToken := func(table string) string {
tok := at.gwKey()
if t, err := edit.GetTOMLTable(path, table); err == nil {
if v := t["experimental_bearer_token"]; v != tok && keyHolds(v, tok) && !access.Default(v) {
return v
}
}
return tok
}
putProvider := func() error {
kvs := []edit.KV{
{Path: "name", Value: "magpie"},
{Path: "base_url", Value: at.v1()},
{Path: "wire_api", Value: "responses"},
{Path: "experimental_bearer_token", Value: at.gwKey()},
{Path: "experimental_bearer_token", Value: keptBearerToken("model_providers." + magpieID)},
// Codex offers its built-in image tool (image_gen.imagegen) and
// the other OpenAI-provider tools only to a provider it reads as
// the OpenAI actor: one that does not require OpenAI auth but
@@ -548,7 +565,7 @@ func codexIn(at place) *Agent {
edit.KV{Path: "name", Value: id},
edit.KV{Path: "base_url", Value: at.v1()},
edit.KV{Path: "wire_api", Value: "responses"},
edit.KV{Path: "experimental_bearer_token", Value: at.gwKey()},
edit.KV{Path: "experimental_bearer_token", Value: keptBearerToken("model_providers." + id)},
); err != nil {
return err
}
+41
View File
@@ -6,6 +6,8 @@ import (
"strings"
"testing"
"github.com/yetone/magpie/internal/access"
"github.com/yetone/magpie/internal/edit"
"github.com/yetone/magpie/internal/provider"
)
@@ -416,3 +418,42 @@ func TestCodexSyncPutsProviderTableBack(t *testing.T) {
t.Fatalf("own model:\n%s", cfg)
}
}
// #2545: a key made under Gateway keys, put in the provider table's
// experimental_bearer_token in place of magpie's, goes through magpie all
// the same, so a model pick keeps it, as a sync keeps one. A key the
// gateway doesn't take is still wired over.
func TestCodexPickKeepsAGatewayKeyOfTheUsers(t *testing.T) {
home, read := codexHome(t, `{"tokens":{"access_token":"x","id_token":"x.e30.x"}}`,
"model = \"gpt-5.5\"\n\n[projects.\"/x\"]\ntrust_level = \"trusted\"\n")
cx := codex(home)
if err := cx.Fields[0].Set("fake/m1"); err != nil {
t.Fatal(err)
}
if cfg := read(); !strings.Contains(cfg, `experimental_bearer_token = "magpie"`) {
t.Fatalf("not wired:\n%s", cfg)
}
secret, err := access.Update("add-key", access.Change{Name: "codex"})
if err != nil {
t.Fatal(err)
}
path := filepath.Join(home, ".codex", "config.toml")
if err := edit.SetTOMLKey(path, "model_providers.magpie", "experimental_bearer_token", secret); err != nil {
t.Fatal(err)
}
if err := cx.Fields[0].Set("fake/m1"); err != nil {
t.Fatal(err)
}
if cfg := read(); !strings.Contains(cfg, `experimental_bearer_token = "`+secret+`"`) {
t.Fatalf("a model pick wrote over the user's caller key:\n%s", cfg)
}
if err := edit.SetTOMLKey(path, "model_providers.magpie", "experimental_bearer_token", "sk-not-this-gateways"); err != nil {
t.Fatal(err)
}
if err := cx.Fields[0].Set("fake/m1"); err != nil {
t.Fatal(err)
}
if cfg := read(); strings.Contains(cfg, `experimental_bearer_token = "sk-not-this-gateways"`) {
t.Fatalf("a key the gateway doesn't take is kept:\n%s", cfg)
}
}