RubyLLM uses a static bundled models.json as its model registry. New
models released by providers (e.g., gpt-5.1, gpt-5.2) are not available
until the gem is updated, causing ModelNotFoundError for self-hosted
users who configure newer models.
Refresh the model registry synchronously during Llm::Config.initialize!
to fetch the latest model list from configured providers and models.dev,
then persist with save_to_json. This runs once per process on the first
LLM request, adding ~1-2s to that request. Falls back gracefully to the
bundled registry on failure.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
RubyLLM uses a static bundled models.json as its model registry. New
models released by providers (e.g., gpt-5.1, gpt-5.2) are not available
until the gem is updated, causing ModelNotFoundError for self-hosted
users who configure newer models.
Refresh the model registry asynchronously via a background thread during
Llm::Config.initialize! to fetch the latest model list from configured
providers and models.dev, then persist with save_to_json. The bundled
registry is available immediately; the refresh updates it in the
background without blocking the first LLM request.
Use double-checked locking with a mutex to prevent concurrent threads
from spawning duplicate refresh operations.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
RubyLLM uses a static bundled models.json file as its model registry.
New models released by providers (e.g., gpt-5.1, gpt-5.2) are not
available until the gem is updated. This causes ModelNotFoundError
for self-hosted users who configure newer models.
Call RubyLLM.models.refresh! during Llm::Config.initialize! to fetch
the latest model list from configured providers and models.dev. Persist
the result with save_to_json to tmp/ruby_llm_models.json so subsequent
processes load from disk instead of making HTTP calls. The file has a
1-hour TTL to balance freshness with performance.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>