-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: refresh models button not flushing cache properly #9870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Re-review completed - no new issues found. The latest change improves async behavior by ensuring Latest change (commit 8a5560f):
Overall PR summary:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
9ed9955 to
0d40375
Compare
…rning from flushModels()
|
Added a commit to resolve a last remaining issue reported in #9683 (comment) |
Related GitHub Issue
Closes: #9682
Description
This PR fixes two related issues with the LiteLLM provider (and potentially others like LM Studio and Ollama):
flushModelsfunction was being called without credentials (apiKey, baseUrl), causing the subsequentrefreshModelscall to fail when trying to fetch models from the provider.RouterProvider.getModel()was being called synchronously beforefetchModel()had populated the instance's model list. This caused it to fall back to the default model (Claude 3.7 Sonnet) for the first request or system prompt generation, even if a different model was selected.Implementation Details:
flushModelssignature insrc/api/providers/fetchers/modelCache.tsto acceptGetModelsOptionsinstead of just a provider string. This allows credentials to be passed through torefreshModels.src/core/webview/webviewMessageHandler.tsto passapiKeyandbaseUrlwhen handling therefreshRouterModelsmessage for LiteLLM, LM Studio, and Ollama.RouterProvider.getModel()insrc/api/providers/router-provider.tsto check the global synchronous cache (getModelsFromCache) if the instance'sthis.modelsis empty. This ensures models are available immediately if they have been previously cached, preventing the fallback to the default model on the first request.Test Procedure
Verify Refresh:
Verify Model Selection:
gemini-3-pro-preview).claude-3-7-sonnet-20250219.Unit Tests:
npm run test src/api/providers/__tests__/lite-llm.spec.tsnpm run test src/api/providers/fetchers/__tests__/modelCache.spec.tsnpm run test src/core/webview/__tests__/webviewMessageHandler.routerModels.spec.tsPre-Submission Checklist
Documentation Updates
Important
Fixes refresh models button by passing credentials and ensures correct model usage on initial request.
flushModelsinmodelCache.tsto acceptGetModelsOptionsfor credentials, ensuringrefreshModelscan fetch models correctly.RouterProvider.getModel()inrouter-provider.tsto use global cache ifthis.modelsis empty, preventing fallback to default model.webviewMessageHandler.tsto passapiKeyandbaseUrlforrefreshRouterModelsmessage for LiteLLM, LM Studio, and Ollama.webviewMessageHandler.routerModels.spec.tsto verifyflushModelsandgetModelsare called with correct credentials.extension.tsfor Roo models cache handling.This description was created by
for 9ed9955. You can customize this summary. It will automatically update as commits are pushed.