A heap profile of the live magpie (v0.1.2646, 37 minutes, the owner's
real accounts) had buildModels allocate 1288MB. 553MB of it was the
gateway's seer, asked once per list build (provider.Described), and
238MB was codexEfforts -> TakesEffort -> CacheEntries, which decodes the
whole Codex models_cache.json for each model asked.
- buildModels asks describedNow(), kept per provider.StampNow() in a
stampedLists like the lists themselves, so every agent's list of one
stamp shares one answer, and a change (a provider saved) asks again.
- TakesEffort reads a slug's default level from cacheLevels(), a
filememo.Read of the cache file by its stat: the decode keeps only
each model's level, and runs again when the file changes. magpie's own
added entries are skipped as CacheEntries skips them.
Run on mote (macOS 27.2):
- TestListsAskVisionOnce (new): pi, claude, codex, opencode, droid and
dsh lists ask Described once; after a provider save, once more, and a
"no" reaches the new list. With buildModels asking Described itself
(put back by hand): red. Restored: ok.
- TestTakesEffortReadsTheCacheOnChange (new): a 300-model cache, levels
for a slug and codex/<slug>, the default for magpie/x and an unknown
one, 20 allocs or fewer a look, and the new level after a rewrite a
minute later. With TakesEffort on CacheEntries again (by hand): red.
Restored: ok.
- go test ./internal/agent ./internal/codexcat at this tree: ok (162.5s).
./internal/gateway and ./internal/gui at the tree before the test's
last fix (only the new test changed since): ok but
TestCodexPoolSaysTheClientsVersion (#4807, red in a full gateway run
on mote, untouched here) and TestMainWindowCorners/macOS_26_SDK
(#3949, red on macOS 27).
- gofmt -l clean; go vet, GOOS=windows and GOOS=linux go vet of both
packages: ok.
Not tried: a heap profile of a live build with this change.