ac4af582301a4e8a29245dbba767eba31334ddf9
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8ee172ca03 |
search: a Codex account searches with its cheap model, not the flagship its list starts with
lucy_85908 (Discord #feedback, v0.1.2682) ran a third-party model in Codex
and found each web search magpie ran for it logged as Anthropic -> Responses
on gpt-6.1-sol, 10,532 tokens in, through the Codex account. The searcher
was picked right (a Codex account searches for models that can't), but its
model was not. smallCands ranks a provider's models by small-tier name
(haiku/mini/flash), then m.Price. A subscription's list has no prices, and
GPT-6 has no mini, so every Codex model ranked equal and the first listed
(gpt-6.1-sol) was used for every search and every AutoVision description.
Now a model with no price on the list is ranked by its list price
(Provider.ListPrice, the price the Usage page counts it at). "luna" is a
small-tier word beside mini, for when no catalog is loaded yet (the same
rule warmPick has used since #604). codex-auto-review is left out: it is
free only for the reviews it runs. A searcher or model named in Settings
-> Web search still wins (namedSearcher is unchanged). The fix is in the
pool AutoVision shares, so a Codex account's image descriptions now go to
the cheap model too.
Not changed: Codex's web_search = "cached" (external_web_access:false)
is still dropped when magpie searches for a model that can't; filed as
#5018.
Run at the pushed head (mote-run):
- go test ./internal/gateway -run TestCodexSearchesWithItsCheapModel
(new), and with Search|Searcher|Vision|Small|TestRankSmall|TestAutoVision:
ok.
- go test -timeout 45m ./internal/gateway at the pushed head (rebased on
|
||
|
|
7126f7de3e |
gateway: only the user's "it sees" lifts the small models' shape guess, and a group's ID stays out (#4359)
Review of ggbdpq's aa378a4f6 (the commit before). Its comment says a
group's, auto's or a subscription's agent-written ID stays out whatever
the user said of it, but the code put those guards inside the same
"user said nothing" branch, so a group/ or auto/ ID with a modelImages
entry entered the pool. And any answer lifted the guess, a "takes no
images" too: that says nothing of whether the ID is a vendor's model,
yet let a colon or *-embed/-tts/-free ID into the searcher's small
model pool, which has no image keep to hold it back.
Now the structural guards stand for every model, and only a modelImages
true lifts the colon/word guess.
Run (mote, -tags nogui):
- TestSmallCandsLiftOnlyWhatTheUserSaidSees, new: red on aa378a4f6
("pool [cn:text-only cn:sees group/g auto/a], want only cn:sees"),
green here.
- TestAutoVisionPicksANamespacedIDTheUserSaidSees (ggbdpq's): red with
search.go at origin/main
|
||
|
|
4932a8bd1c |
fix(gateway): a model the user said sees is picked though its ID carries a namespace colon (#4359)
What changed AutoVision never picked a model of a relay whose IDs carry a vendor namespace (cn:deepseek-v4.1-flash, gateway key 21/cn:…), though the user had marked every one as taking images in settings.json's modelImages: smallCands dropped every model whose lowercased ID holds a colon or a tilde, and the drop came after keep (seesAt) had read the user's answer, so their word never reached the pick — the pool came out empty and seer() said no model sees, while naming the model in vision worked. smallCands now reads the pool's settings once and leaves a model the user gave an answer about (ImageOverride) in the pool whatever characters its ID carries: their answer names one of the vendor's models in full, which is exactly what the colon, the tilde and the nano/lite/image/… words were guessing at. The shape filters stand for every model they said nothing of, and the structural ones — a group's, a found group's, and, on a subscription, what magpie wrote into its agent — stand even for a model they did name. The searcher's pool reads the same answer: the filters are one judgment, and a model the user proved real can be searched with too; a relay is asked to search only where it was before. Run - TestAutoVisionPicksANamespacedIDTheUserSaidSees (new) fails on the old smallCands with "AutoVision = \"\", want relay/cn:deepseek-v4.1-flash, the model the user said sees" and passes now; it also holds that with no answer of the user's the model stays out, and that their "takes no images" keeps it out. - go test -tags nogui -count=1 ./internal/gateway/ (whole package). Fixes #4359 Generated-by: GLM-5.3-Flash (ZCode) |
||
|
|
243aa709b2 |
gateway: AutoVision and the searcher's pick keep each provider's ranked models until a list, a provider or a setting changes
Why: a live heap profile of the app (yg6888 on X, ~1 GB held) had
36 GB allocated, and 5.3 GB of it was under seer -> autoVision ->
smallModelWhere. 4.8 GB of that came through agent.magpieModels
(provider.Described, asked for every agent's model list: dsh every 30s,
and the window's state). Each AutoVision did three things for every
provider that was on:
- built its Exposed list twice: once in smallReady, then again only to
read the picked model's price;
- asked spentModel (perKeyBarred, 1.4 GB) about every candidate model,
before picking one;
- copied the list three times in pickSmall.
The searcher's pick (searcherReady, Searchers, chosenSearcher) goes
through the same smallReady. For a Remote magpie it asked
p.Available() once per model (remoteSearch).
What changed:
- rankSmall puts the candidates in pickSmall's order once. pickSmall of
any subset is the first of that subset in this order, and
TestRankSmallIsPickSmall checks that against the old pickSmall over
2000 random lists and subsets. smallReadyOf then asks spentModel in
rank order and stops at the first model with allowance. The model it
picks, and whether it is ready, are the same as before. Usually only
one model is asked.
- The candidate carries its cost, so smallModelWhere no longer builds
Exposed a second time.
- keptSmallCands keeps each provider's ranked candidates in
stamped[smallKey, []smallCand]. The key is the provider id, the
signed-in account (agent, user, plan, home) and which filter ("sees",
"search"). Entries are dropped when provider.StampNow moves, or
after stampedFor (1 minute).
- provider.StampNow (hold.go, added with dsh's round) is made of:
- held.gen, which Changed moves: a provider saved, an account,
catalog.SaveLive/Touched/Reset, a plugin's change;
- filememo.Gen (settings.Save and every other write this process
makes);
- environSum;
- the time and size of the providers' file, the settings file and the
catalog's cache file, so a write by another magpie (the CLI) counts
too.
The one-minute backstop covers what nothing signals: a list another
magpie fetched, or another program changing an existing account's
model list. A new account is a new key, so it is seen at once (within
provider.Accounts' own 30s).
- Whether a model is out of its allowance (spentModel) is still asked
on every call, never kept. Two callers building one key at the same
time each build it. Nothing waits on another, and nothing is built
under the lock.
Measured on the real path: a sandbox HOME with the live
~/.cache/magpie/models.json (5.8 MB, 231 providers) copied in, 12 API
key providers (openrouter, anthropic, openai, google, deepseek,
nano-gpt, vercel, kilo, requesty, aihubmix, zenmux, poe), and the
catalog.Provider fix 4f044c24c applied to both sides. The benchmark is
go test -bench, -benchtime 2s, not committed. The pick is
requesty/mimo-v2.6-flash before and after.
| Benchmark | Before | After |
| --- | --- | --- |
| AutoVision | 769.7 ms, 22,075,218 B, 73,732 allocs/op | 7.3 ms, 238,201 B, 1,134 allocs/op |
| AutoVision under provider.Hold | 347.8 ms, 21,532,432 B, 69,061 allocs/op | 2.1 ms, 85,207 B, 244 allocs/op |
What is left is mostly provider.All, which reads the accounts.
Tests:
- TestAutoVisionDoesNotBuildListsAgain: AllocsPerRun of AutoVision and
searcherModel with 4 and with 400 listed models. It allows 50
allocations of difference: 521 against 527.
- Broken by hand (stamped.get always builds), it went red at 611
against 1055.
- TestAutoVisionSeesEachChange checks that each change is picked up:
- picks changed through provider.Save;
- a vendor's list re-fetched with new prices (catalog.SaveLive);
- providers.json rewritten directly, as another magpie would;
- settings.Save moving the stamp;
- a Codex sign-in written into the same HOME.
Broken by hand (the stamp ignored, only the minute kept), it went red
at "AutoVision = "" after Haiku and Gemini were enabled". Run with the
other AutoVision tests, TestAutoVisionPassesOverOneOut went red too.
- TestAutoVisionKeptListsAskAllowanceEachTime checks that a used-up
Codex account is seen on the very next call.
Run:
- gofmt -l internal/: clean.
- GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean.
- set -o pipefail; go test -count=1 -timeout 45m ./internal/gateway/
./internal/provider/ ./internal/catalog/ ./internal/gui/, at load
~400 (other sessions' suites), with 4f044c24c applied:
- gateway ok 2259.7s, provider ok 821.8s, catalog ok 16.5s.
- gui FAIL in two tests that fail the same way without this change.
Each was run alone, with these files reverted, on 28bcd4f7e:
- TestMainWindowCorners: the real AppKit window was killed at its
40s deadline, alone too (#1936, #2645).
- TestSetAnswersWhileDevinAndProvidersHang: setting slow/slow-1
took 10.9s against its 10s bound. Alone it took 3.3 to 5.4s with
this change and 4.6 to 5.9s without it, passing 3 of 3 (#1375).
- The new tests were run again after the split into two commits:
go test -run 'TestInfoCounts|TestAutoVision|TestRankSmall|Searcher'
./internal/gateway/: ok.
|