Codex's Agents row asked CodexSubagentModels each poll, and each time it
took a copy of Codex's whole catalog (CatalogFor) and made a list from
it: 21.8 MB of forty polls of the Agents, Providers and Drift answers
with real accounts. The list is now kept as the catalog is (keptOf, per
provider.StampNow and keptFor), read from the catalog's own kept lists
(catalogKept) without a copy, and clipped so a caller appending makes
a list of its own. Its one caller, codex.go, only ranges over it.
TestCodexSubagentModelsKept: 200 models of a relay under Hold; asking
again allocates a quarter or less of what building them does.
Run on mote at c1457f2ee plus this change:
- gofmt; go vet darwin, windows, linux: ok
- TestCodexSubagentModelsKept alone 3/3 ok
- broken by hand (CodexSubagentModels builds each time): red, "allocated
1089523 bytes, building them 1089513"
- go test ./internal/provider ./internal/agent -timeout 45m: agent ok
(231.7s); provider ok but for this test's first version, whose
allocation-count bar failed (StampNow's stats count too); the test now
compares bytes and was run alone and broken again as above, not in the
whole package again
- real accounts, sandbox HOME, network blocked, 40 polls, against
c1457f2ee: CodexSubagentModels 21.8 MB -> not in the profile;
codexIn.func84 22.3 MB -> gone; Picks 135 -> 92 MB; state and drift
answers byte for byte the same, providers the same but for its
fetched times; footprint peak 135 MB, RSS at end 178 MB
Not run: the GUI suite (no GUI file changed), Windows and Linux test runs.
Rebased onto e4384fc3c (gateway, redact and GUI commits, none in internal/provider or internal/agent); not run again there.