ac4af582301a4e8a29245dbba767eba31334ddf9
11
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f73f39050d |
catalog: a provider's model list is built once a load, without copying every model to the heap for each
Why magpie's own process sat at ~650 MB: a live heap profile of a
user's magpie (magpie heap, 48 minutes) held ~157 MB live but had
allocated 34.8 GB, ~725 MB a minute, so Go's heap peaked near 885 MB
and the footprint followed it. KeepDshWired's round every 30 seconds
was 11.8 GB of it: magpieModels("dsh") → Provider.Catalog → ... →
catalog.Provider for each catalog, which built every model again, and
mdProvider.levels alone was 5.97 GB flat. Its `kin = &x` took the
address of the range variable, so every model of the provider was
copied to the heap for every model asked: allocations grew with the
square of a provider's models.
- levels keeps the kin by id, date and levels, the same choice as
before (newest by release date, then id, with levels, not after the
model), with no pointer to the loop's copy.
- Provider keeps each provider's list for the load it was built from
and gives callers a copy of it; Reset drops them, and a list built
from a load that a Reset ended meanwhile isn't kept (gen).
Run:
- real models.json (5.8 MB), Provider for every provider id, a pass:
63.5 MB / 272,952 allocs before; 8.96 MB / 10,478 with the levels fix
alone; 3.2 MB / 232 with both (a throwaway benchmark, not committed).
- TestProviderAllocsGrowWithModels: red with `kin = &x` put back
(40012 allocations for 200 models, at most 2000 wanted); red with the
memo not stored; red with Provider handing out its own slice
(a caller's change reached the next one). Green on this code.
- go test -race -count=3 ./internal/catalog: ok.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on
catalog, provider and agent: ok.
- Full suite, go test -count=1 -timeout 45m ./... on this batch at load
~380: every package ok but agent and gateway (past 45m, #2869),
TestQueueFullAndWaitedOut (#3061), TestRequestBuildsProvidersOnce
(#2965), TestMainWindowCorners (#2645, red alone on main too) and the
app.js budget (raised in its own commit). gateway alone: ok but
TestClaudeAccountsSpentFallBackToCodex (#2858); agent alone past 45m
at load ~600, its codex/running/connect tests ok alone.
Not done here: a singleflight in provider's heldOf was written and
taken out again; a waiter blocking on another request's build can
deadlock if that build needs a lock the waiter holds, and nothing here
proved it can't.
|
||
|
|
c8b4ac7755 |
fix(catalog): honor models.dev reasoning toggles (#1294)
* catalog: honor reasoning toggles as off effort Include none when models.dev reports both a reasoning toggle and effort levels. Keep toggle-only entries level-less, and leave effort-only entries unchanged. Validation: go test ./... with GOFLAGS=-tags=nogui; all packages pass. The new catalog regression failed before the fix and passes after it. No vendor API request was made locally. * catalog: limit reasoning off to DeepSeek * catalog: include verified Kimi reasoning toggles * fix(catalog): keep off effort provider scoped |
||
|
|
9964535adc |
provider: a model models.dev has just listed without its reasoning levels takes its family's, so Codex's picker offers them for a relay's gpt-6.1-sol (NextCommit on Discord)
NextCommit's Codex showed no reasoning-effort picker for a relay's (an OpenAI-compatible key provider) gpt-6.1-sol, while gpt-6-astra had one, and magpie's log said the effort went from none to low. models.dev had listed gpt-6.1-sol as a reasoning model but without reasoning_options yet, or not at all, so magpie knew no levels for it: Codex's catalog got supported_reasoning_levels [] (no picker), and the gateway, not knowing "none" was one of the model's levels, sent Codex's "none" as "low" (#899). What changed: - catalog: a thinking model with no levels of its own and no budget takes the levels of the newest model of its models.dev family (same provider, thinking, with levels) released on or before it (mdProvider.levels). Used by Provider and ListedBy. A model with its own levels, a budgeted one, one that doesn't think, or one with no family is as before. - catalog.KinEfforts: for an id no provider lists, the levels of the newest listed model of the same shape with the version numbers left out (gpt-6.1-sol -> gpt-#-sol), never a budgeted or non-thinking one. - provider.borrowedEfforts: tries ListedBy, then EffortsOf, then KinEfforts. Entry.Efforts, which every agent's model list is built from (Codex, Claude Code, OpenCode, dsh, ...), goes through it, as do Known, Levelless, groups and plugins. - Xiaomi's mimo, which takes a thinking switch only (#214), still gets no levels; gpt-4.1 gets none. With levels known, an effort the user picks in Codex goes through as picked. The none->low mapping remains for models whose levels are still unknown (#899). What was run: - New tests: TestFamilyLevels (catalog) and TestNewModelTakesItsFamilysLevels (provider, Codex catalog levels for relay/gpt-6.1-sol). Both fail with levels() and the KinEfforts call neutered (levels "" against the family's), and pass with them. - Real Codex CLI 0.162.1 under a sandbox HOME against a sandbox magpie gateway (127.0.0.1:3592) and a fake relay (127.0.0.1:3591) listing gpt-6.1-sol and gpt-6-astra. The models.dev cache had reasoning_options stripped from every gpt-6.1-sol entry to match the reporter's. - Built from origin/main: magpie-models.json gave relay/gpt-6.1-sol default None, levels []. - With this change: default medium, levels none..max,ultra. - Codex /model showed "Select Reasoning Level for GPT-6.1 Sol · relay". Picking Medium, High and None sent reasoning_effort "medium", "high" and "none" to the relay. - gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...; GOOS=linux and GOOS=windows builds: all clean. - go test ./... under a temp HOME, with GOCACHE and GOMODCACHE pinned. Every package passed except four that hit the 10-minute default timeout with load average ~40 (TestCopilotSecretToolUsername's 5s secret-tool wait as well). Rerun with -timeout 40m -p 2, internal/agent, gateway, library and provider all passed. Not tried: the Claude Code, OpenCode and dsh model files written for the same relay model; they take Entry.Efforts like Codex. |
||
|
|
2df2e0886d |
plugin, provider, gateway: a plugin's model is listed with every kind it takes and gives (audio, video, pdf), not image alone (#1595, tkhs101)
The plugin host read a model's capabilities.input only for "image", and
fromModelsDev hard-coded output to text, so /v1/models listed
opencode-zen-free's muse-spark-1.3-contributor-free (models.opencode.ai:
input text/image/audio/video/pdf) as ["text","image"] with no output.
- host.js: fromModelsDev and the config merge keep modalities.input and
.output whole; the listing sends inputs/outputs, the kinds the
capabilities object marks true, in OpenCode's order.
- plugin.Model gets Inputs/Outputs; pluginCatalog puts them on
catalog.Model's new InputModalities/OutputModalities (input only where
the plugin said what it takes, as ImageInput already is).
- catalog: models.dev entries and a vendor's live list (now reading
modalities.output) fill the same fields; Decorate carries the catalog's
when the live list says nothing, beside ImageInput.
- provider.Entry.Modalities() is what the gateway lists: the source's
kinds, with "image" still decided by Images, so the user's own
"takes images" override still wins and the other kinds stay.
Not changed: the 7 models the report lists as having lost their levels
have reasoning_options [] upstream (models.opencode.ai), so "reasoning,
no levels" is what they are; mimo-v2.6-flash turns away levels (#214).
DSH's model kinds and Muse's list still say text/image only.
Tests: TestPluginModelModalities (gateway) with the reporter's literal
metadata: muse-spark's config as opencode-zen-free 0.1.3's configModels
writes it, and mimo-v2.6-flash-free's capabilities as its models hook
lists them; a model said nothing of stays unlisted, and the image
override drops image only. TestFetchedModalitiesKeepEveryKind (catalog).
Broken by hand: host.js without inputs gives the report's [text image]
(red); Entry.Modalities without the Inputs branch (red); Decorate
without the fill (red). Run: go test catalog, plugin, provider, gateway;
gofmt -l; GOOS=linux and windows go vet on the four; go test ./...
green on 76db4c6c2+this; after rebasing on
|
||
|
|
729f6bdbdf |
models: a model its maker lists with a thinking switch alone takes no borrowed levels, and the gateway sends it no more than high (#214 Moody-Max: opencode 的 mimo-v2.6 Flash 你这边设置的默认推理强度是 max 导致400报错)
A model not under its provider's own models.dev vendor (a relay or provider of the user's, a live id that doesn't match, or a preview/-exp or typed id Known looks up) took the levels most listed for it across all of models.dev. For mimo-v2.6-flash those are the resellers' (llmgateway, counted once per upstream host it lists, and requesty, up to max), while Xiaomi lists it with a thinking switch alone. OpenCode was offered variants up to max, Pi and Codex the same levels, and the gateway passed max on unchanged (fitEffort keeps an effort when no levels are known), which Xiaomi turned away with a 400. The same held for Zhipu's glm-5/5.1/5v-turbo, Kimi k2.6, MiniMax M2.x, gemma-4 and others whose makers give no levels while resellers give up to max. Now catalog.ListedBy looks a model up in given catalogs (vendor prefix, case, a ':free' or '(…)' suffix aside) and gives the levels listed there, none for a switch or no options, and skips an entry with a token budget alone (Claude 4.5), which says nothing of efforts. Known looks in the provider's own catalogs first, and every borrow (Known, effortsOf) asks the makers' catalogs (vendor presets, less Groq and Ollama Cloud, marked Hosts as they serve others' models) before the crowd. The crowd vote counts a provider once per list, so an aggregator listing a model under several hosts no longer outvotes the rest. Provider.Levelless says a model is known to have no levels, and the gateway (fitFor, on the direct and fallback paths) sends such a model no more than high; a model whose levels are simply unknown is still sent what was asked. Tests: TestEffortsOfOneVoteAProvider and TestListedBy (catalog); TestMakerLevelsBeforeResellers (provider: Xiaomi's preset, a preview left out of the list and a relay get no levels, an unlisted model and a budget-only Claude one still borrow, Levelless); TestOpenCodeNoResellerLevelsForSwitchModel (opencode.json has empty variants for Xiaomi's and a relay's mimo, three for a reseller-only model; Pi has no reasoning or thinkingLevelMap for mimo); TestSwitchModelSentNoMoreThanHigh (gateway: mimo asked max/xhigh sent high, low as asked, an unknown model max). The agent and gateway tests fail on main. An audit of every preset against the current models.dev snapshot found the cases above. Not tested with a real Xiaomi key or a running OpenCode. go build -tags nogui (and linux, windows), go test -tags nogui ./... pass. |
||
|
|
d287a05161 | providers: Amazon Bedrock, with a Bedrock API key (#176: 增加 AWS Bedrock 作为 model provider) — Bedrock's runtime serves Claude on Anthropic's messages at /anthropic/v1/messages and the other models on chat completions at /openai/v1, both taking a Bedrock API key (AWS_BEARER_TOKEN_BEDROCK) with no SigV4, so a vendor preset reaches it: pick one of ten regions and paste the key. Claude ids (anthropic.claude…) go on messages only, the rest on chat only, for the preset and for any provider at a bedrock-runtime host; the runtime has no /models, so the preset's list (Claude as global. inference profiles, plus gpt-oss, Qwen3 Coder, DeepSeek, Kimi, GLM and MiniMax) is it, and a profile kept in one geography (apac., us., eu.…) is typed in by hand and takes its context size from the model it names. The region selector scrolls where its regions don't fit. Tested against a fake Bedrock through the gateway (apac.anthropic.claude-opus-5-5 on /anthropic/v1/messages with x-api-key, gpt-oss on /openai/v1/chat/completions with the Bearer key) and in a sandbox magpie web; not yet against real AWS | ||
|
|
b5d47ca5e7 |
gateway: an image sent to a model that can't see is dealt with before it goes out, and one a tool returned no longer ends the chat (#56)
A model's image input is taken from models.dev and the provider's own list, and a group's from its members: only a model known to be text-only is refused an image — one whose support is unknown still gets it, and Codex, OpenCode and Pi are told which models take images. An image the user attaches for a text-only model answers 400 in the client's own format before the upstream is asked; an image earlier in the chat, or one a tool returned (Claude Code's Read, Codex's view_image, a Chat tool message), becomes a short text note, so a chat that met a picture carries on after a switch to a text-only model. Thanks @herrkaefer. |
||
|
|
d6784bd114 | codex: a model a custom provider serves takes the reasoning levels models.dev gives it from the others serving it, so the Codex app offers an effort for it (a Volcengine endpoint's glm-5.3-flash showed 中 with nothing to pick, and magpie's effort control a "none" Codex never used) — levels were only taken from models.dev's entry for the vendor itself, and a vendor it doesn't list (a custom provider, a proxy) had none, so Codex's catalog carried no supported_reasoning_levels; a model models.dev doesn't list for its vendor now takes, by bare id as the context window is found, the levels most of the providers giving any give it (glm-5.3-flash: low, high, max, default high), one no one gives levels for keeps none. Codex's effort is settled on one the model takes when a model is picked and when the catalog is synced, magpie shows the catalog's default where none is set, and the gateway sends a Chat vendor reasoning_effort at the model's nearest level (Codex's medium goes to glm-5.3-flash as high), as asked where the model's are not known | ||
|
|
09c635cf03 | agents: a model through magpie tells Pi, Crush, omp and Codex how much it holds, and a provider added, edited or removed reaches the model lists agents keep in files of their own — the catalog carried no context window, so Pi took every model through magpie for a 128K one (a CLIProxyAPI's gpt-5.5 holds 922K) and Crush for a 200K one; each model now carries models.dev's input limit, else its context, looked up by bare id as most of the providers serving it give it (a proxy's "openai/gpt-5.4", "gpt-5.4(high)", "glm-4.6:free" find it too; a group holds the least of its members'). And those lists were written only when a model was picked: Codex's magpie-models.json, Pi's models.json, OpenCode's, Crush's, Command Code's, omp's and Hermes' provider blocks and dsh's llm-deepseek entry kept the catalog as it was then, so a provider added later never showed. Saving a provider, a vendor's list fetched anew or models.dev synced now rewrites each one magpie wrote, where it differs, and the app does once at start-up; a Codex signed in to ChatGPT, which asks the gateway, kept its cached list under the backend's ETag, which a change of magpie's never changed — the ETag (and a reply's X-Models-Etag) now carries a tag of magpie's models, and a cache from before a change is aged so the next Codex asks again | ||
|
|
626933ff2b | codex: a magpie model that takes images says so in the catalog magpie gives Codex, which otherwise drops an attached image before sending — every magpie model was listed as text-only, so a picture pasted into Codex never reached a vision model; whether a model takes images is what its vendor's models.dev entry says, or for one served by a vendor models.dev doesn't list, what most of the providers serving that model say, and a routing group takes them only when every member does | ||
|
|
702477525a |
Claude subscription as a provider; model lists fetched, never compiled in
A signed-in Claude Code is now offered as a provider (claude/…) like Codex and Copilot. Anthropic classifies another agent's system prompt as third-party traffic even over Claude Code's OAuth, so magpie drives the real local claude binary for every generation: the caller's tools are bridged in over MCP (magpie claude-mcp-helper), and tool results resume the same Claude Code turn. Token counting is estimated locally so the OAuth token takes no side path. No model list is compiled in any more. The built-in catalog, preset defaults and Claude Code's alias list are gone; the picker shows the models.dev catalog (refreshed in the background when stale) layered with each vendor's own /models answer, and signed-in accounts fetch theirs at start-up. Whether a model rejects temperature/top_p now comes from models.dev rather than a name prefix. The gateway retries a Chat request on the Responses endpoint when the model is Responses-only, and remembers that. Recent calls keep the first 256 KB of request and response bodies, viewable in the call list. The Usage tab shows subscription allowances (Claude, Codex, Copilot) as the vendors report them. |