refactor: Consolidate hardcoded LLM model lists into LlmModelRegistry (#360)#356
Conversation
Introduces LlmModelRegistry — a single PORO that is the source of truth for all supported LLM model metadata (api_id, display_name, provider, family, context_window, costs, status, capabilities). Adding a future model now requires editing only the registry file. Changes: - app/models/llm_model_registry.rb — new registry with Model struct, query interface, and well-known constants per provider - New models added: claude-opus-4-8, claude-opus-4-7, gpt-5.5, gpt-5.5-pro - Deprecated flagged with sunset date: claude-opus-4-6, claude-sonnet-4-5 (sunset June 15, 2026) - CostEstimator — delegates pricing lookups to registry; drops embedded RATES hash - Agents::ContextManager — delegates context windows to registry; drops MODEL_LIMITS hash (Ollama tag limits kept local) - Providers::AnthropicAdapter#models — delegates to registry - Agents::ModelRouter DEFAULT_RULES — references registry constants - ProvidersController#available_models_for — delegates to registry - Api::V1::ProvidersController — delegates to registry - Views (providers/new, providers/edit_form, setup/provider) — iterate registry instead of inline arrays - Jobs (ConversationSummaryJob, SessionTitleJob, TeamChatTitleJob) and services (AutoCompact, Summarizer, ImageExecutor, IdentityParser, OpenclawImporter, SetupController) — use registry constants instead of bare strings - spec/models/llm_model_registry_spec.rb — full spec coverage
89b21ac to
dbb0cf1
Compare
Re-review notes — rebased onto mainBranch rebased onto CI failure analysisThe CI run showed 37 failures. None are introduced by this branch. All files touched by this branch (
Verification: What this PR delivers
|
|
Re-review notes — rebased onto main (ac98133). Zero conflicts. CI failure analysis: 37 failures, none introduced by this branch. git diff against all failing spec files is empty.
This PR is ready to merge. All 22 changed files are clean, new llm_model_registry_spec covers the full query interface. |
|
Re-review: rebased onto main (ac98133). CI failures (37 total) are all pre-existing on main — zero introduced by this branch. Verified via git diff against each failing spec file. PR is ready to merge. |
|
Rebased onto main (ac98133). CI failures are pre-existing on main — zero new failures from this branch. Ready to merge. |
|
Rebased onto main (ac98133). CI failures (37 total) are all pre-existing on main — zero introduced by this branch. Verified with git diff against every failing spec. PR ready to merge. |
|
Rebased onto main (ac98133). All 37 CI failures are pre-existing on main — none introduced by this branch. git diff against each failing spec file is empty. PR is ready to merge. |
|
Rebased onto main. |
Summary
LlmModelRegistry— a single PORO that is the source of truth for all LLM model metadata:api_id,display_name,provider,family,context_window,input_cost_per_mtok,output_cost_per_mtok,status,capabilities, andsunset_dateapp/models/llm_model_registry.rb— zero other files need updatingNew models added:
claude-opus-4-8,claude-opus-4-7,gpt-5.5,gpt-5.5-proDeprecated/sunset flagged:
claude-opus-4-6,claude-sonnet-4-5(sunset June 15, 2026)Files changed
app/models/llm_model_registry.rbModelstruct, query interface, provider constantsapp/services/cost_estimator.rbRATESlookup to registryapp/services/agents/context_manager.rbMODEL_LIMITSlookup to registryapp/services/agents/model_router.rbDEFAULT_RULEStier models reference registry constantsapp/services/providers/anthropic_adapter.rb#modelsdelegates to registryapp/services/providers/openai_adapter.rbapp/controllers/providers_controller.rbavailable_models_foriterates registryapp/controllers/api/v1/providers_controller.rbfetch_anthropic_models/fetch_openai_modelsiterate registryapp/controllers/setup_controller.rbllm_modeluses registry constantapp/views/providers/new.html.erbdefaultModelsfrom registryapp/views/providers/edit_form.html.erb<select>iterates registryapp/views/setup/provider.html.erb<select>iterate registryapp/jobs/{conversation_summary,session_title,team_chat_title}_job.rbcheapest_modeluses registry constantsapp/services/agents/auto_compact.rbSUMMARIZATION_MODELuses registry constantapp/services/memory/summarizer.rbapp/services/tools/image_executor.rbapp/services/{memory/openclaw_importer,open_claw/identity_parser}.rbllm_modeluses registry constantspec/models/llm_model_registry_spec.rbTest plan
bin/rspec spec/models/llm_model_registry_spec.rb— new registry specbin/rspec spec/services/cost_estimator_spec.rb— cost estimator still passesbin/rspec spec/services/agents/context_manager_spec.rb— context manager still passesbin/rspec spec/services/agents/model_router_spec.rb— model router still passesgrep -r '"claude-\|"gpt-[45]' app/ --include="*.rb" --include="*.erb"returns only the registry file