Skip to content

Add configurable discussion model registry#492

Merged
rjroy merged 1 commit into
mainfrom
feat/configurable-discussion-models
May 22, 2026
Merged

Add configurable discussion model registry#492
rjroy merged 1 commit into
mainfrom
feat/configurable-discussion-models

Conversation

@rjroy

@rjroy rjroy commented May 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replaces the hardcoded DiscussionModel enum and DISCUSSION_MODEL_MAP with a runtime registry loaded from memory-loop-config.json at daemon startup
  • Vaults store a plain model name string resolved against the registry at session-creation time; unset vaults fall through to pi-agent's own default instead of always using opus
  • Model dropdown in vault settings is now dynamic: fetches from the daemon, shows "No models configured." when empty, and renders <name> (unknown) for stale/unknown values

What changed

New:

  • daemon/src/global-config.ts — registry module; reads from MEMORY_LOOP_CONFIG env var or ${VAULTS_DIR}/memory-loop-config.json; missing/malformed config is non-fatal
  • GET /models route in daemon + Next.js proxy at /api/models
  • nextjs/lib/daemon/models.tsModelEntry type + getModels() client

Removed from shared:

  • DiscussionModelSchema (Zod enum), VALID_DISCUSSION_MODELS, DEFAULT_DISCUSSION_MODEL, resolveDiscussionModel()
  • discussionModel is now string | undefined everywhere

Updated:

  • session-manager.tsresolveModelForPiAgent() looks up getRegistry() instead of a local map; unknown names log a warning and return undefined
  • ConfigEditorDialog.tsx — dynamic dropdown replacing hardcoded opus/sonnet/haiku options
  • All dependent tests updated; test injection via configureRegistryForTesting / _resetRegistryForTesting

Test plan

  • bun run test — 2042 tests, 0 failures
  • bun run typecheck — clean across all packages
  • Start daemon with no config file → GET /api/models returns { "models": [] }, no fatal errors
  • Write ${VAULTS_DIR}/memory-loop-config.json with model entries, restart daemon → dropdown shows them
  • Set vault discussionModel to a name not in registry → session starts, warning logged, no crash
  • Leave discussionModel unset → session starts with pi-agent default, no warning

🤖 Generated with Claude Code

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

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@rjroy rjroy merged commit 9950045 into main May 22, 2026
2 checks passed
@rjroy rjroy deleted the feat/configurable-discussion-models branch May 22, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant