diff --git a/internal/catalog/catalog.go b/internal/catalog/catalog.go index 82da1d966..a410b3870 100644 --- a/internal/catalog/catalog.go +++ b/internal/catalog/catalog.go @@ -615,12 +615,18 @@ func load() map[string]mdProvider { return mdev } -// Reset forgets the loaded catalog so the next call re-reads the cache. +// Reset forgets the loaded catalog so the next call re-reads the cache, +// and tells Forget: what the provider package built of the old one (the +// windows and output limits of its entries) is kept between requests +// for a moment, and would answer for the old catalog meanwhile. func Reset() { loadMu.Lock() - defer loadMu.Unlock() loaded = false mdev, images, windows, outputs, efforts, thinks, names, listed, canonical = nil, nil, nil, nil, nil, nil, nil, nil, nil + loadMu.Unlock() + if Forget != nil { + Forget() + } } // Sync downloads the models.dev catalog into CachePath. It serializes with diff --git a/internal/provider/hold_test.go b/internal/provider/hold_test.go index a7124d289..6b5c415e5 100644 --- a/internal/provider/hold_test.go +++ b/internal/provider/hold_test.go @@ -89,8 +89,8 @@ func TestHoldKeptForTheNextRequest(t *testing.T) { // What is held across requests is built again when anything it was built // from may have moved: a write that only tells filememo (settings.Save, an // account's file), the providers' or the settings' file written by -// another process (the CLI's "magpie group add"), and the groups served -// or not (GateGroups, ServeGroups). +// another process (the CLI's "magpie group add"), the groups served or +// not (GateGroups, ServeGroups), and the models.dev catalog read again. func TestHoldKeptUntilAWrite(t *testing.T) { defer func(d time.Duration) { heldFor = d }(heldFor) heldFor = time.Minute // a loaded machine's pause between requests isn't the change @@ -123,6 +123,9 @@ func TestHoldKeptUntilAWrite(t *testing.T) { os.WriteFile(settings.Path(), []byte(`{}`), 0o600) }}, {"the groups gated", func() { GateGroups(nil)() }}, + // models.dev's catalog read again: the entries' windows and + // output limits come from it (Pi's maxTokens, Crush's default) + {"the catalog reset", catalog.Reset}, } { was := n c.write()