Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

provider: levels kept of a model's own narrow only what is offered again (#92)

yetoneedff2f819a0f
diff --git a/docs/reference.md b/docs/reference.md
index 60cd9894e..be0f99693 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -1254,16 +1254,18 @@ It writes the same stores `magpie model context`, `output`, `images` and
`efforts` do — the window in providers.json, the rest in settings.json
(`modelOutputs`, `modelImages`, `modelEfforts`, `modelReasonless`) — so the
order above holds for each part, and a catalog refresh keeps them. A model
-nothing knew the levels of can be given them (`--reasoning low-high`); one
-that has its own can only be narrowed to some of them. A bad number, an
+nothing knew the levels of can be given them (`--reasoning low-high`), and
+a request to it is sent at the nearest of those. One that has its own can
+only be narrowed to some of them, which narrows what agents are offered:
+the vendor is still asked at any level it has, as with
+`magpie model efforts`. A bad number, an
unknown flag, a level that isn't one, or a range that runs backwards is
refused, and nothing of the command is written.
What you set wins everywhere magpie reads a model: the app's badges and
level chips, the gateway's `/v1/models` (`context_window`,
`max_output_tokens`, `reasoning_levels`), the `max_tokens` a request is sent
-with, the level a request is sent at (an ask above the levels you kept goes
-at the nearest one you kept), whether images reach it or are described
+with, whether images reach it or are described
first, which model magpie picks to describe images, and the model lists
magpie writes into the agents.
diff --git a/docs/subsystems/gateway-routing.md b/docs/subsystems/gateway-routing.md
index 5ff13c5ab..ae13b6434 100644
--- a/docs/subsystems/gateway-routing.md
+++ b/docs/subsystems/gateway-routing.md
@@ -180,7 +180,7 @@ recorded as a prediction failure (`noPrediction`).
- A request to an Anthropic endpoint that turns thinking off is sent as the model takes it (`thinkingOffAsTaken`, in `forwardOnce`, so relayed requests, count_tokens, magpie's own thinking-off and retries all get it; the model is read as the vendor names it, from the body, or from the path for Bedrock and Vertex). Claude Sonnet 5.5 refuses `thinking: {type: "disabled"}` and is sent `{type: "between_tools"}` alone, at effort `high` at most. Opus 5.5, Fable 5 and Mythos 5 refuse it at every effort and are sent no thinking, at effort `low` unless one was asked, with `classifierRoom` added to a reply limit below it, as Claude Code does. Opus 5 and Haiku 5.5 take it only up to `high`, so `xhigh` and `max` are asked as `high`. `between_tools` sent to any other Claude goes as `disabled`, or as none where that is refused too. Other vendors' models, older Claudes and later lines than these go as they came (#1454). A Sonnet 5.5 by a name these rules can't read, answering 400 that asks for `between_tools` (`asksBetweenTools`), is asked again with it, once; a refusal of `disabled` at any effort (`thinkingOffRefused`) is asked again with thinking left to the model, as `alwaysThinks` is. So is a relay that reads `disabled` as reasoning effort `none` and turns that level away naming the ones it takes (Sub2API's gpt-6.1-sol, "does not support reasoning effort \"none\"; use low, medium, high, xhigh or max", #1465); `refusesThinkingOff` is the one list of these refusals for both routes. A relayed request refused so marks the model (`markUnfit(offRefused)`), and its later requests go with thinking left to the model at once until magpie restarts, as auto mode's classifier asks on every action.
- A Chat or Responses client's reasoning turned off (`none`, `ThinkOff`), translated to an Anthropic endpoint (`buildAnthropic`), goes as `thinking: {type: "disabled"}`; it went as thinking at a 4096-token budget before (#1636). A model that refuses it (`refusesThinkingOff`: `alwaysThinks`, `mandatoryReasoning`, `thinkingOffRefused`, or `none` turned away naming the levels taken) is asked again at its least (`thinkingBackOn`), and `markUnfit(offRefused)` sends it so at once until magpie restarts. A translated request's level can differ from the one asked: `none` and `minimal` go as `low` where the model's levels don't say it stops (`effortOf`). The route keeps the level asked; the try, the usage log and Routing's "went" say the one built (`noteWireEffort`, `wireEffort` in [`wire_effort.go`](../../internal/gateway/wire_effort.go)). Gemini's builders say theirs their own way and are logged as asked.
- A model the user ticked no levels of (`ModelReasonless` in [settings](../../internal/settings/settings.go), `SetModelReasonless`; the provider editor's Names & levels, or `magpie model efforts <provider/model> off`) is sent no reasoning field on any route, whatever the agent asks: the candidate loop strips the body with `withoutAnyReasoning` ([`quiet.go`](../../internal/gateway/quiet.go): Chat's `reasoning_effort`, `reasoning`, `thinking`, `enable_thinking` and `include`'s `reasoning.encrypted_content`, Responses' `reasoning`, Anthropic's `thinking` of any type and `output_config.effort`, Gemini's `thinkingConfig`), the Anthropic relay doesn't add `thinking:{type:disabled}` for it, and `forwardTranslated` clears `Effort`, `ThinkOff` and `Thinking` for its other callers. It offers no levels (`Efforts`, `entryFor`), is `Quiet`, and as a routing-group member doesn't take the group's levels away. The learned refusals above cover only reasoning *off* and Gemini levels; a vendor that answers a plain `reasoning_effort` with 422 (yuexian7 on Discord) is not learned, so this is the user's switch. `TestReasonlessModelSentNoReasoning`, `TestReasonlessAnthropicRelay`, `TestGroupReasonlessMemberKeepsLevels`, `model-reasonless.test.cjs`.
-- The levels the user kept of a model (`ModelEfforts`, `SetModelEfforts`; `magpie model efforts`, `magpie model spec --reasoning`, Dani Ariyanto on Discord) are the levels a request is fitted to, not only the ones offered: `provider.Efforts` returns the kept ones, so `fitEffort` sends an ask above them at the highest kept and one below at the lowest. Before, #92 narrowed only the lists handed out and an agent asking xhigh still got xhigh. A model the lists know no levels of can be given them; it then counts as reasoning (`entryFor`). `AutoVision` honours the user's `ModelImages` over the model's own (`seesAt`). `TestModelSpecReachesTheGateway`, `TestKeptLevelsBoundTheAsk`, `TestAutoVisionTakesTheUsersVision`.
+- Levels the user kept of a model's own (`ModelEfforts`, `SetModelEfforts`; `magpie model efforts`, the editor's Names & levels, `magpie model spec --reasoning`) only narrow what is offered (#92): `provider.Efforts` returns the vendor's list's or models.dev's levels, and `fitEffort` fits a request to those, so an agent asking xhigh of a model kept to low–high still asks xhigh. A model no list knows levels of can be given them (`magpie model spec --reasoning`, Dani Ariyanto on Discord); those are then its levels, a request is fitted to them, and it counts as reasoning (`entryFor`). `AutoVision` honours the user's `ModelImages` over the model's own (`seesAt`). `TestModelSpecReachesTheGateway`, `TestNarrowedVendorLevelsAskAsBefore`, `TestAutoVisionTakesTheUsersVision`.
- A request to an Anthropic endpoint with `temperature`, `top_p` or `top_k` reaches a model that refuses them without them (`samplingAsTaken`, beside `thinkingOffAsTaken` in `forwardOnce`): Opus 4.7, 4.8, 5 and 5.5, Fable 5, Mythos 5, Sonnet 5 and 5.5, and Haiku 5.5, whose 400 is "`temperature` is deprecated for this model" (Claude Code's auto mode classifier and magpie's own classifiers ask at temperature 0). Older Claudes, Haiku 4.5 among them, other vendors' models and later lines go as they came (#1454). A Claude by a name these rules can't read, answering that a sampling parameter is deprecated (`samplingDeprecated`), is asked again without them, once — a Chat or Responses client's request translated to Messages (`forwardTranslated`) as much as a relayed one.
- Claude Code's auto mode asks the API to review each action ([`automode.go`](../../internal/gateway/automode.go), Anthropic's [auto-mode-classifier-billing](https://code.claude.com/docs/en/auto-mode-classifier-billing)): the `dangerous-tool-use-…` beta, a `safeguards` field, and `safeguard_results` in the reply (a stream's in its `message_delta`). Only Anthropic runs that classifier, so they reach only a route it answers on (`AutoModeReviewed`): the Claude subscription (the bridge hands them to Claude Code's own binary), a Claude model under any vendor's spelling on a provider with a key (Anthropic's API, a relay, Bedrock, Vertex), and anything on `api.anthropic.com`. Another subscription's or a plugin's Claude model (Copilot, Kiro, Cursor…) is that vendor's service and isn't reviewed by its name: Copilot turns `safeguards` away (#1756), the others translate the request, so neither the beta nor `safeguards` is sent there (`TestAutoModeReviewedRoutes`, `TestAutoModeReviewLeftOffOtherSubscriptions`). There the beta, `safeguards` and the results pass as sent, a whole reply's results moved into a stream's `message_delta` (`anthropicWholeEvents`), tool-use ids unchanged. To any other model they are taken off (`serverReview`; a translation never carries them), and magpie never answers a result on Anthropic's behalf. Claude Code then classifies locally and names the gateway in a notice; the wiring turns the review off in its settings while no model it can reach through magpie is reviewed (`claudeReviewEnv`, [agent wiring](agent-wiring.md)), which is the page's remedy for a gateway that can't run the checks (1EFLOPS on X: Codex's model behind magpie). Reviewed there means `AutoModeReviewable`: a reviewed model on a route that reaches the Messages API, since a Claude model asked on a relay's Chat or Responses URL is translated and never carries the review (nexnull on Discord, `TestAutoModeReviewableAsksOnMessages`).
- Claude Code's billing line (`x-anthropic-billing-header: cc_version=…; cc_entrypoint=…; cch=…;`, its own first system block, `cch` changing every turn) goes on only to a Claude model asked on Anthropic's Messages API (`keepsBillingLine` in [`billing_line.go`](../../internal/gateway/billing_line.go): Anthropic's, a relay's, Bedrock's), as Claude Code sent it. Anywhere else it is left out, the rest of the system as sent (`withoutBillingLine`): a vendor's model relayed on Messages (`passthrough`), every translation to Chat, Responses or Gemini (`forwardTranslated`, Claude models too). Kept, a vendor read it as the prompt's first words and its prefix cache missed from byte 0 every turn (#1600, justrun1983: 4% read from DeepSeek's cache behind Command Code's plan). The Claude subscription's run sends its own (`withoutBillingHeader`), another magpie decides for the provider it picks, and Code Assist (Antigravity, Gemini CLI) is sent it as before, which `antigravityTurnsAway` reads (#666). Once Antigravity has turned such a request away, for `agForeseeing` (6 hours) after, a candidate loop with someone left after an Antigravity account skips it for a request that carries the line, without asking it (`antigravityForeseen`, #2156: each Claude Desktop turn waited about a second on the same refusal before the next member). The skip goes in `Fallback` with the hint, nothing rests, and the agent is told the refusal if nobody after it answers but with a quota. The last one left is still asked, and an old refusal foresees nothing, so a block Google lifts is noticed (`TestAntigravityTurnedAwayIsForeseen`).
diff --git a/internal/cli/model_spec_cli.go b/internal/cli/model_spec_cli.go
index 826460cf5..4df90ac8a 100644
--- a/internal/cli/model_spec_cli.go
+++ b/internal/cli/model_spec_cli.go
@@ -28,6 +28,8 @@ const specUsage = `usage:
What you set wins over the vendor's list and models.dev everywhere magpie reads them: the app's
badges, the gateway's model list and routing, max_tokens, image handling, and the model lists
magpie writes into the agents. A model you set nothing on is as it was. A catalog refresh keeps them.
+ Reasoning levels narrowed from the model's own only narrow what agents are offered; the vendor is
+ still asked at any level it has. Levels given a model with none known are what it is asked at.
e.g. magpie model spec kenari/glm-5:free --context 128k --output 16k --vision off --reasoning low-high`
diff --git a/internal/gateway/modelspec_test.go b/internal/gateway/modelspec_test.go
index 272b3c5cf..732a9a3f9 100644
--- a/internal/gateway/modelspec_test.go
+++ b/internal/gateway/modelspec_test.go
@@ -124,10 +124,13 @@ func TestModelSpecReachesTheGateway(t *testing.T) {
}
}
-// A model whose levels the vendor's list names, kept to some of them by
-// the user, is asked the nearest of those kept, not a level left out: the
-// user's range bounds the ask, as it bounds what agents are offered.
-func TestKeptLevelsBoundTheAsk(t *testing.T) {
+// Levels the user keeps of a model's own (magpie model efforts, Names &
+// levels, magpie model spec --reasoning) only narrow what agents are
+// offered (#92, 47e12df41): the vendor is still asked at any level it
+// has, so an agent's xhigh goes as xhigh. Only a model with no levels
+// known is fitted to the ones the user declared
+// (TestModelSpecReachesTheGateway).
+func TestNarrowedVendorLevelsAskAsBefore(t *testing.T) {
fresh(t)
os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755)
data := `{"kenari":{"models":{"sol":{"id":"sol","name":"Sol","reasoning_options":[{"type":"effort","values":["low","medium","high","xhigh","max"]}]}}}}`
@@ -155,18 +158,17 @@ func TestKeptLevelsBoundTheAsk(t *testing.T) {
res.Body.Close()
return up.last(t)["reasoning_effort"]
}
- if got := ask("xhigh"); got != "xhigh" {
- t.Fatalf("with every level offered, xhigh went as %v", got)
- }
r := "low-high"
if err := provider.SetModelSpec("kenari/sol", provider.SpecChange{Reasoning: &r}); err != nil {
t.Fatal(err)
}
- if got := ask("xhigh"); got != "high" {
- t.Fatalf("kept to low-high, xhigh went as %v", got)
+ if e, _ := provider.EntryOf("kenari/sol"); !slices.Equal(e.Efforts, []string{"low", "medium", "high"}) {
+ t.Fatalf("the levels offered are the ones kept: %v", e.Efforts)
}
- if got := ask("low"); got != "low" {
- t.Fatalf("kept to low-high, low went as %v", got)
+ for _, effort := range []string{"xhigh", "max", "low"} {
+ if got := ask(effort); got != effort {
+ t.Errorf("narrowed to low-high, %s went as %v; the vendor has it", effort, got)
+ }
}
}
diff --git a/internal/provider/modelprefs_test.go b/internal/provider/modelprefs_test.go
index abcb51915..29825f539 100644
--- a/internal/provider/modelprefs_test.go
+++ b/internal/provider/modelprefs_test.go
@@ -173,10 +173,8 @@ func TestModelEfforts(t *testing.T) {
if got := entry(t, "auto/sol").Efforts; !slices.Equal(got, []string{"low", "high"}) {
t.Fatal(got)
}
- // the gateway fits a request to the levels kept, not all the vendor
- // has: what the user kept wins in routing too (magpie model spec
- // --reasoning, Dani Ariyanto on Discord)
- if got := (Provider{ID: "a", Catalog: "a"}).Efforts("sol"); !slices.Equal(got, []string{"low", "high"}) {
+ // the vendor is still asked at any level it has
+ if got := (Provider{ID: "a", Catalog: "a"}).Efforts("sol"); len(got) != 4 {
t.Fatal(got)
}
if err := SetModelEfforts("a/sol", []string{"ultra"}); err == nil {
diff --git a/internal/provider/models.go b/internal/provider/models.go
index 5f36de381..a56113fd4 100644
--- a/internal/provider/models.go
+++ b/internal/provider/models.go
@@ -1594,15 +1594,18 @@ func (p Provider) RejectsTemperature(model string) bool {
}
// Efforts are the reasoning levels the model takes, when known: its own,
-// only those of them the user kept (magpie model efforts, magpie model
-// spec --reasoning), or those the user gave it when it has none known.
-// The gateway fits a request to these, so an agent asking a level the
-// user left out is asked the nearest one kept.
+// or those the user gave it when it has none known (magpie model spec
+// --reasoning on a custom provider's model). The gateway fits a request
+// to these. Levels the user kept of a model's own only narrow what is
+// offered (#92): the vendor is still asked at any level it has.
func (p Provider) Efforts(model string) []string {
if Reasonless(p.ID, model) {
return nil
}
- return effortsKept(p.Known(model), settings.Shared().ModelEfforts[p.ID+"/"+model])
+ if all := p.Known(model); len(all) > 0 {
+ return all
+ }
+ return effortsKept(nil, settings.Shared().ModelEfforts[p.ID+"/"+model])
}
// Thinks reports whether the model reasons: it has levels, its list says
diff --git a/internal/settings/settings.go b/internal/settings/settings.go
index e629ea6c0..6ff2bdcba 100644
--- a/internal/settings/settings.go
+++ b/internal/settings/settings.go
@@ -652,9 +652,10 @@ type Settings struct {
ModelNames map[string]string `json:"modelNames,omitempty"`
// ModelEfforts are the reasoning levels the user keeps of a model's,
// by "<provider id>/<model id>": the lists magpie hands out offer only
- // those, and the gateway fits a request's level to them; for a model
- // with no levels known they are the levels given it (see
- // provider.SetModelEfforts, magpie model spec).
+ // those, while the vendor is still asked at any level it has; for a
+ // model with no levels known they are the levels given it, and the
+ // gateway fits a request to them (see provider.SetModelEfforts,
+ // magpie model spec).
ModelEfforts map[string][]string `json:"modelEfforts,omitempty"`
// ModelReasonless are the models the user said take no reasoning ask,
// by "<provider id>/<model id>": magpie offers them no levels and