claude-desktop: a 1M model runs at 1M in the Code tab again (fwxkogaia on X)
Claude Desktop 5.11492 (released 11-13) starts its Code tab's Claude Code
with CLAUDE_CODE_MAX_CONTEXT_TOKENS=200000 in its --settings file whenever
the provider routes models itself, the gateway included (Fcn=2e5 and Lcn in
index.chunk-xV3fJhc7.js; 4.16336 had no such value). Flag settings come
before ~/.claude/settings.json, so the window magpie writes there no longer
reached the Code tab, and every model picked by its plain entry ran at 200K,
a 1M one too. No magpie change caused it: nothing in v0.1.4300..v0.1.4322
touched what Desktop is told about 1M.
Claude Code takes a "[1m]" id for 1M whatever that variable says (pT in
2.1.322). magpie's profile now gets Desktop's own "Use 1M wherever it's
available" (modelPrefer1mContext: true, 3p only, Desktop 1.28929+) once, on
a switch on and from Sync, as toolSearchEnabled is (desktopSeedPrefer1M):
Desktop then shows a model it offers a 1M entry for by that entry alone
(D5n: prefer1m on every supports1m entry) and hands Claude Code its [1m] id.
Desktop offers that entry only for a row whose max_input_tokens is 1M or
more, so nothing smaller changes. The user's own value, false too, or their
taking it away, stays theirs. Compaction is as before: the working window,
or the whole window under Full window.
Not fixable this way: a model between 200K and 1M (a 272K or 400K GPT)
still runs at Desktop's 200K; only a managed policy setting comes before
flag settings, and magpie writes none.
Run (mote, at this tree):
- go test ./internal/agent -run TestClaudeDesktop: ok
- TestClaudeDesktopPrefers1M red with desktopSeedPrefer1M returning nil
("switch on: modelPrefer1mContext <nil>"), green with it
- go vet ./internal/agent for darwin, linux, windows: ok; gofmt -l: clean
- go test -timeout 45m ./... at base 98955300a plus this diff: exit 0,
101 packages ok, no FAIL (log kept whole)
Read, not run: Desktop 5.11492.5's app.asar (downloads.claude.ai zip) and
Claude Code 2.1.322's strings, for the 200K and the [1m] rule.
Not tried: a real Desktop 5.11492 on magpie in a sandbox; the Code tab's
/context with the new profile.
This commit is contained in:
@@ -151,6 +151,7 @@ something else shows up as drift.
|
||||
- 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, unless every model it can reach there surely gets Anthropic's results back (`claudeReviewed`, by `gateway.AutoModeAnswered`: a model `AutoModeReviewable` on the Claude subscription or on `api.anthropic.com` itself; a relay's Claude model, even on its Anthropic endpoint, may drop `safeguard_results`, and a Claude model asked on Chat or Responses never carries the review, nexnull on Discord, `TestClaudeReviewedOnlyWhereResultsComeBack`): 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, each judged on the provider (or group, or fallback) it resolves to, as the gateway judges its requests, so a Claude model on Copilot or Kiro writes `"0"` and a name magpie doesn't know is judged by the name (`TestClaudeReviewedJudgesTheSetModelWhereItGoes`). One model that doesn't answer is enough, since `/model` can take the session there; a model hidden from Claude Code doesn't count. Off, Claude Code runs its own classifier through the gateway (fitted to any model, `classifierStandIn`; the model is the Claude Code card's auto mode square, `CLAUDE_CODE_AUTO_MODE_MODEL`), which works on every model. Left on behind a route that doesn't answer, 2.1.322 doesn't fall back: with telemetry or feature flags off (`DISABLE_TELEMETRY`, `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`, …) it denies each action it would check, "Auto mode can't check actions in this session … your requests go through 127.0.0.1:3425, which doesn't pass it through" (`auto_mode_no_check_in_session`), on a Claude model too when the session could also reach another model (JoyYoung2Lucky on X). Before this, any reviewed model left it unset, which is how a relay's Claude beside DeepSeek met that denial. 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's tool search (`ENABLE_TOOL_SEARCH`, `claudeSearchEnv` in [`claude.go`](../../internal/agent/claude.go)) is written `"true"` while Claude Code is routed through magpie. On, MCP tools are named in a reminder and loaded by `ToolSearch` when the model needs them, not sent whole on every request. Claude Code before 2.1.304 keeps it off behind an `ANTHROPIC_BASE_URL` other than Anthropic's, so the MCP router's tools all went on each request (cybercaius on Discord: 245 tools, 124K tokens of a 341K context; 2.1.290 through a sandbox gateway sent 242,346 bytes of tools, 27,443 with it on); 2.1.304 and later turn it on there themselves, and `"true"` also keeps it on in a conversation begun without it. The gateway carries deferred tools to every upstream (`Tool.Deferred`, `withoutDeferredTools`). magpie's value is kept apart in the stash (`claude.tool_search`); a value the user set, an empty one too, is theirs; it goes when Claude Code is taken off magpie (`desktopOnly`, `unroute`; `TestClaudeToolSearchOn`). T3 Code's magpie instance carries `"true"` in its environment unless the user gave it a value there (`TestT3CodeToolSearchOn`).
|
||||
- Claude Desktop's Code tab gets tool search only with Desktop's own `toolSearchEnabled` policy on (3p only, off by default). Off, Desktop 2.7032 (`Ztr` "off") starts Claude Code with `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`, and Claude Code (2.1.312, 2.1.316: `oae` returns "standard") then keeps tool search off whatever `ENABLE_TOOL_SEARCH` says, so every MCP tool went whole on each request (bigcat1800 on Discord: 13 MCP servers, ~162K tokens; a sandbox CLI with 60 MCP tools sent 83 tools, 205KB). On, with the gateway provider and a bundled Claude Code of 2.1.247 or later, Desktop hands the CLI `ENABLE_TOOL_SEARCH=force` as a managed setting and the same CLI sent 13 tools, MCP ones behind `ToolSearch`, 56KB, asking only `tool-search-tool-2025-10-19` of the betas. magpie's profile gets `toolSearchEnabled: true` once, on a switch on and from Sync, as `claudeAiImport` is (`desktopSeedToolSearch`, `desktopSeedOnce`, mark `claude-desktop.tool-search`): a value the user set, false too, or took away since, stays theirs (`TestClaudeDesktopTurnsOnToolSearch`). A profile the user applied for magpie's gateway (`desktopAppliedGateway`) is not written.
|
||||
- Claude Desktop 5.11492 starts its Code tab's Claude Code with `CLAUDE_CODE_MAX_CONTEXT_TOKENS=200000` in its `--settings` file whenever the provider routes models itself, the gateway included (`Fcn`, `Lcn` in its app.asar; 4.16336 had none). Flag settings come before `~/.claude/settings.json`, so the window magpie writes there (`claudeContextEnv`) no longer reaches the Code tab: a 1M model picked by its plain entry ran at 200K (fwxkogaia on X, v0.1.4321). Claude Code takes a `[1m]` id for 1M whatever that variable says (2.1.322's `pT`), so magpie's profile gets Desktop's own "Use 1M wherever it's available" (`modelPrefer1mContext: true`, 3p only, Desktop 1.28929 and later) once, on a switch on and from Sync, as `toolSearchEnabled` is (`desktopSeedPrefer1M`, mark `claude-desktop.prefer-1m`; `TestClaudeDesktopPrefers1M`). Desktop then shows a model it offers a 1M entry for by that entry alone; it offers one only for a row whose `max_input_tokens` is 1M or more, so smaller models are unchanged, and one between 200K and 1M still runs at Desktop's 200K (only a managed policy setting comes before flag settings, and magpie writes none). The user's own value, false too, or their taking it away, stays theirs.
|
||||
- OpenMausBot (`openmausbot.go`) runs each bot on an engine from `instances` in `~/.openmausbot/config.json` (`$OMB_DATA_DIR`, `server/config.ts` in its source). magpie writes the `magpie` engine as OpenMausBot's own Claude endpoint (`newClaudeEndpoint`, `claude-endpoints.ts`): driver `claudeAgent`, access `custom`, `config.configDir` under `providers/magpie` so OpenMausBot starts Claude Code with its own `CLAUDE_CONFIG_DIR` and strips account keys the engine doesn't set (`claudeEnvironment`, `claude.ts`), `ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN` and `ANTHROPIC_API_KEY` at the gateway, and magpie's models as `config.endpointModels`, kept to the ids OpenMausBot's `CLAUDE_MODEL_ID` accepts (one bad id makes it refuse the whole engine). A non-empty `instances` is the whole fleet, so with none saved magpie writes OpenMausBot's `DEFAULT_FLEET` beside it (`ombFleet`, stashed as `openmausbot.fleet`) and takes it out again on off if the user hasn't changed it (`TestOpenMausBotFleetChanged`). The name, a model picked from the list, other env and a `cli` are the user's. OpenMausBot reads the file once at start and writes back the fleet it holds whenever an engine is edited in it, so the switch is refused while it runs (`errOMBRunning`; not checked on Windows) and the notice asks to quit it first. That write-back, and an edit of magpie's engine there (`updateClaudeEndpoint` keeps only the model picked and its tiers), leave `endpointModels` without models picked in magpie, and no catalog change follows to sync it again: while magpie serves, `KeepOpenMausBotListed` runs the sync every 30 seconds when the saved list differs from magpie's (`ombListStale`; maxleebeta on Discord, 11-08: Antigravity's models missing from its search). A copy started before magpie's last change to the engine (`ombPart`: the gateway, the first model and the list) offers the row's Restart (`restartApps`, `OpenMausBot.app` and `OpenMausBot.exe`). Codex bots use `~/.codex`, which magpie's Codex wiring already covers.
|
||||
- Avibe (`avibe.go`, `avibe-os` on PyPI, the `vibe` CLI) keeps its model sources in `model_hub.sources` of `config/config.json` in its home (`$AVIBE_HOME`, else `~/.avibe`, else a legacy `~/.vibe_remote`: `config/paths.py`). A source can't be written there by hand: its key is sealed in the Model Hub's store and Avibe adds it to its agents' route chains as it is made. So magpie adds the `magpie` source through the same internal API Avibe's Models page uses (`POST /internal/model-hub`, `core/handlers/model_hub/rpc.py`) on the control socket `state/dispatch.sock` in its home, or on Windows the loopback port and bearer token in `runtime/control-ipc/endpoint.json` (`core/control_ipc.py`). `create_source` makes an `api_key` source of vendor `custom` at the gateway's `/v1` with `agentKey("avibe")`, protocol `openai_chat` and `save_unverified` (Avibe's probe can't tell which protocol a gateway serving all of them speaks); Avibe then lists the models from `/v1/models` itself. Chat completions, not Responses: for a Responses source its CLIProxyAPI runs Codex's executor, which sends `codex-tui` headers the gateway would take for Codex. Its id is stashed (`avibe.source:<home>`); a source of the custom vendor at the gateway's `/v1` counts as magpie's too. `delete_source` and `refresh_source` are sent with `force` and then again with the `would_remove_hops` and `would_interrupt` Avibe answers with, as its page confirms them. A gateway address change makes the source again (the key goes with the address and `patch_source` can't change it). Every change needs Avibe running (`avibeLive` probes `list_sources`; `errAvibeDown`); `Sync` refreshes the source's models while it runs.
|
||||
- Kun (`kun.go`, KunAgent/Kun, an Electron app, `com.xingyuzhong.deepseekgui`; zhongxingyuyes on X) keeps its model connections in `model-connections.v2.json` in its data folder (`$KUN_DATA_DIR`, not ~-expanded, else `~/.kun/data`). A connection's key goes to Kun's credential store as it is made, so the file isn't written by hand: magpie adds the `magpie` connection the way Settings > Providers does, through the runtime's admin API at the `baseUrl` of `runtime.json` in that folder, with its `runtimeToken` as a bearer (loopback only). `POST /v1/model-connections/connect` makes an `http` connection with `api-key` auth at the gateway's `/v1`, `endpointFormat` `chat_completions`, `agentKey("kun")`, the models picked for Kun (500 at most) and the pick selected; another of magpie's models is `PATCH` of the list and `POST /v1/model-connections/select`. Every change names the registry's revision (409 `revision_conflict` otherwise). Kun's default before magpie's is stashed (`kun.prev:<dir>`) and selected again when magpie steps out, then the connection is `DELETE`d. Kun refuses to delete the connection its default names ("still has references: default.providerId"), so with no default of Kun's own to go back to, magpie's goes as Kun's Settings retires one: a provider-config transaction (`POST /v1/provider-config/transactions/preview`, then `commit`) that clears the default and removes the connection (`kunClient.remove`, `TestKunFromNothing`). Its id is stashed (`kun.id:<dir>`); an HTTP connection at the gateway's `/v1` counts as magpie's too. Every change needs Kun running (`kunLive` probes the snapshot; `errKunDown`); reads go to the registry file first. A sync brings the list up to the picked models, and makes the connection again only from the gateway's own address on an older port (`kunMoved`, as `avibeMoved`). Every test of the package but Kun's own finds a Kun running per data folder (`runningKun`).
|
||||
|
||||
@@ -203,7 +203,8 @@ func claudeDesktop(home string) *Agent {
|
||||
},
|
||||
}, desktopGatewayField(ps, func() error { return desktopApply(home, ps, magpieID) })}, append(desktopTierFields(home, ps), desktopSubagentField(ps), desktopSubagentEffortField(ps))...),
|
||||
// a Desktop already on magpie gets the import and tool search
|
||||
// policies too (desktopSeedImport, desktopSeedToolSearch), and a
|
||||
// policies too (desktopSeedImport, desktopSeedToolSearch,
|
||||
// desktopSeedPrefer1M), and a
|
||||
// profile for magpie's gateway it applies a key the gateway takes
|
||||
// (desktopKeyApplied)
|
||||
Sync: func() error {
|
||||
@@ -216,6 +217,9 @@ func claudeDesktop(home string) *Agent {
|
||||
if err := desktopSeedToolSearch(p); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if err := desktopSeedPrefer1M(p); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if err := desktopKeyApplied(p); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
@@ -619,12 +623,13 @@ const (
|
||||
desktopLocale = "claude-desktop.locale"
|
||||
desktopImport = "claude-desktop.import"
|
||||
desktopSearch = "claude-desktop.tool-search"
|
||||
desktopLong = "claude-desktop.prefer-1m"
|
||||
desktopSSH = "claude-desktop.ssh-hosts"
|
||||
desktopMCP = "claude-desktop.mcp"
|
||||
desktopMCPSeen = "claude-desktop.mcp-seen"
|
||||
)
|
||||
|
||||
var desktopStashKeys = []string{desktopStashed, desktopMode, desktopMode3p, desktopApplied, desktopMade, desktopProfile, desktopLocale, desktopImport, desktopSearch, desktopSSH, desktopMCP, desktopMCPSeen, desktopModelsMark, desktopDiscoveryMark}
|
||||
var desktopStashKeys = []string{desktopStashed, desktopMode, desktopMode3p, desktopApplied, desktopMade, desktopProfile, desktopLocale, desktopImport, desktopSearch, desktopLong, desktopSSH, desktopMCP, desktopMCPSeen, desktopModelsMark, desktopDiscoveryMark}
|
||||
|
||||
// desktopAdoptStash moves the stash a packaged Desktop's folders got
|
||||
// before they had keys of their own (when magpie wrote only one set) onto
|
||||
@@ -724,6 +729,9 @@ func desktopOn(p desktopPaths) error {
|
||||
if err := desktopSeedToolSearch(p); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := desktopSeedPrefer1M(p); err != nil {
|
||||
return err
|
||||
}
|
||||
// pointed at an address of this computer's for SSH remote sessions,
|
||||
// which 3p mode allows no host for until the profile says so
|
||||
if gw != gateway.URL() {
|
||||
@@ -822,6 +830,27 @@ func desktopSeedToolSearch(p desktopPaths) error {
|
||||
return desktopSeedOnce(p, desktopSearch, "toolSearchEnabled", true)
|
||||
}
|
||||
|
||||
// desktopSeedPrefer1M turns on Desktop's own "Use 1M wherever it's
|
||||
// available" (modelPrefer1mContext, 3p only, off by default) in magpie's
|
||||
// profile, so a model Desktop offers a 1M entry for is shown by that entry
|
||||
// alone and its Code tab hands Claude Code the "[1m]" id. Desktop
|
||||
// 5.11492 starts the Code tab's Claude Code with
|
||||
// CLAUDE_CODE_MAX_CONTEXT_TOKENS=200000 in its --settings whenever the
|
||||
// provider routes models itself, the gateway too (Fcn and Lcn in its
|
||||
// app.asar), and those flag settings come before ~/.claude/settings.json,
|
||||
// so the window magpie tells Claude Code there (claudeContextEnv) no longer
|
||||
// reached it: every model listed by its plain id ran at 200K, a 1M one too
|
||||
// (fwxkogaia on X, v0.1.4321). Claude Code takes a "[1m]" id for 1M whatever
|
||||
// that variable says (pT in 2.1.322). Desktop offers the 1M entry only for
|
||||
// a row whose max_input_tokens is 1M or more (magpie lists none of its rows
|
||||
// with supports_1m), so only models of 1M or more change; a smaller one
|
||||
// past 200K still runs at Desktop's 200K. Seeded once, as
|
||||
// toolSearchEnabled is: the user's own value, false too, or their taking it
|
||||
// away since, stays theirs.
|
||||
func desktopSeedPrefer1M(p desktopPaths) error {
|
||||
return desktopSeedOnce(p, desktopLong, "modelPrefer1mContext", true)
|
||||
}
|
||||
|
||||
// desktopSeedOnce writes key in magpie's profile once, where the profile
|
||||
// has none, and marks it in the stash under mark: once marked it is never
|
||||
// written again, so the user's own value, or their taking it away, holds.
|
||||
|
||||
@@ -149,7 +149,7 @@ func TestClaudeDesktopFresh(t *testing.T) {
|
||||
"inferenceGatewayApiKey": "magpie-claude-desktop", "inferenceGatewayAuthScheme": "bearer",
|
||||
"disableDeploymentModeChooser": true, "coworkEgressAllowedHosts": []any{"*"},
|
||||
"claudeAiImport": map[string]any{"enabled": true, "bannerBehavior": "detect"},
|
||||
"toolSearchEnabled": true,
|
||||
"toolSearchEnabled": true, "modelPrefer1mContext": true,
|
||||
}
|
||||
if prof := desktopJSON(t, p.prof); !reflect.DeepEqual(prof, want) {
|
||||
t.Errorf("profile: %v", prof)
|
||||
@@ -842,6 +842,64 @@ func TestClaudeDesktopLanguageOddValues(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// fwxkogaia on X (v0.1.4321): Desktop 5.11492 starts its Code tab's Claude
|
||||
// Code with CLAUDE_CODE_MAX_CONTEXT_TOKENS=200000 as flag settings on a
|
||||
// gateway, over the window magpie writes, so a 1M model picked by its
|
||||
// plain entry ran at 200K. Desktop's own modelPrefer1mContext shows such a
|
||||
// model by its 1M entry alone, whose "[1m]" id Claude Code takes for 1M.
|
||||
// magpie's profile gets it once, on a switch on and from Sync; the user's
|
||||
// own value, false too, or their taking it away since, stays theirs.
|
||||
func TestClaudeDesktopPrefers1M(t *testing.T) {
|
||||
home, p := desktopSandbox(t)
|
||||
a := claudeDesktop(home)
|
||||
if err := a.Field("provider").Set("magpie"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := desktopJSON(t, p.prof)["modelPrefer1mContext"]; got != true {
|
||||
t.Fatalf("switch on: modelPrefer1mContext %v", got)
|
||||
}
|
||||
|
||||
// on magpie before this change: none, no mark
|
||||
prof := desktopJSON(t, p.prof)
|
||||
delete(prof, "modelPrefer1mContext")
|
||||
b, _ := json.Marshal(prof)
|
||||
desktopWrite(t, p.prof, string(b))
|
||||
forget(desktopLong + p.key)
|
||||
if err := a.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := desktopJSON(t, p.prof)["modelPrefer1mContext"]; got != true {
|
||||
t.Fatalf("Sync on magpie: modelPrefer1mContext %v", got)
|
||||
}
|
||||
|
||||
// the user takes it away in Desktop's window: not written back
|
||||
desktopWrite(t, p.prof, string(b))
|
||||
if err := a.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.Field("provider").Set("magpie"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, has := desktopJSON(t, p.prof)["modelPrefer1mContext"]; has {
|
||||
t.Fatal("seeded again over the user's choice")
|
||||
}
|
||||
|
||||
// the user's own false, seen first: kept
|
||||
if err := edit.SetJSON(p.prof, edit.KV{Path: "modelPrefer1mContext", Value: false}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
forget(desktopLong + p.key)
|
||||
if err := a.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := desktopJSON(t, p.prof)["modelPrefer1mContext"]; got != false {
|
||||
t.Fatalf("the user's modelPrefer1mContext: %v", got)
|
||||
}
|
||||
if a.Check() != "" {
|
||||
t.Fatalf("check %q", a.Check())
|
||||
}
|
||||
}
|
||||
|
||||
// bigcat1800 on Discord: Desktop 4.4212 in 3p mode on magpie, 13 MCP
|
||||
// servers, and every tool's schema went whole on each request (~162K
|
||||
// tokens). Desktop starts Claude Code with experimental betas off unless
|
||||
|
||||
Reference in New Issue
Block a user