Add configurable discussion model registry#492
Merged
Conversation
Replaces the hardcoded DiscussionModel enum and DISCUSSION_MODEL_MAP with
a runtime registry loaded from memory-loop-config.json at daemon startup.
Vaults now store a model name string that is resolved against the registry
at session-creation time; unset vaults fall through to pi-agent's own
default instead of always defaulting to opus.
- New daemon/src/global-config.ts: registry loaded from
MEMORY_LOOP_CONFIG env var or ${VAULTS_DIR}/memory-loop-config.json.
Missing/malformed config is non-fatal; daemon warns and continues with
empty registry.
- New GET /models route (daemon + Next.js proxy) returns the current
registry as { models: [{ name, provider, modelId }] }.
- Removed DiscussionModelSchema, VALID_DISCUSSION_MODELS,
DEFAULT_DISCUSSION_MODEL, and resolveDiscussionModel from shared.
discussionModel is now plain string | undefined throughout.
- ConfigEditorDialog model dropdown is now dynamic: fetches /api/models
on mount, shows "No models configured." when empty, and renders
"<name> (unknown)" for values absent from the registry.
- Test injection via configureRegistryForTesting / _resetRegistryForTesting
(no mock.module(), which Bun prohibits).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DiscussionModelenum andDISCUSSION_MODEL_MAPwith a runtime registry loaded frommemory-loop-config.jsonat daemon startup<name> (unknown)for stale/unknown valuesWhat changed
New:
daemon/src/global-config.ts— registry module; reads fromMEMORY_LOOP_CONFIGenv var or${VAULTS_DIR}/memory-loop-config.json; missing/malformed config is non-fatalGET /modelsroute in daemon + Next.js proxy at/api/modelsnextjs/lib/daemon/models.ts—ModelEntrytype +getModels()clientRemoved from shared:
DiscussionModelSchema(Zod enum),VALID_DISCUSSION_MODELS,DEFAULT_DISCUSSION_MODEL,resolveDiscussionModel()discussionModelis nowstring | undefinedeverywhereUpdated:
session-manager.ts—resolveModelForPiAgent()looks upgetRegistry()instead of a local map; unknown names log a warning and returnundefinedConfigEditorDialog.tsx— dynamic dropdown replacing hardcoded opus/sonnet/haiku optionsconfigureRegistryForTesting/_resetRegistryForTestingTest plan
bun run test— 2042 tests, 0 failuresbun run typecheck— clean across all packagesGET /api/modelsreturns{ "models": [] }, no fatal errors${VAULTS_DIR}/memory-loop-config.jsonwith model entries, restart daemon → dropdown shows themdiscussionModelto a name not in registry → session starts, warning logged, no crashdiscussionModelunset → session starts with pi-agent default, no warning🤖 Generated with Claude Code