-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: Add provider-scoped router model fetches in frontend #8917
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
Conversation
Implements intelligent provider filtering in the frontend to request only the models needed for the currently selected provider. This dramatically reduces memory usage by avoiding unnecessary fetches and smaller cache footprints. - Add DYNAMIC_ROUTER_PROVIDERS set to identify providers needing models - Disable useRouterModels for static providers (anthropic, openai-native, etc.) - Pass provider-specific filters for dynamic providers - Add observability logging to track request/response patterns - Update tests for new behavior Works with backend filtering (PR #8916) to achieve end-to-end payload reduction.
Review CompleteNo issues found. The implementation correctly:
|
…er filter to avoid race with active-only payload (pairs with #8916 backend filtering)
| import { useLmStudioModels } from "./useLmStudioModels" | ||
| import { useOllamaModels } from "./useOllamaModels" | ||
|
|
||
| const DYNAMIC_ROUTER_PROVIDERS = new Set<ProviderName>([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we’re going to forget to update this - isn’t this already in the types somewhere?
|
|
||
| if (message.routerModels) { | ||
| const keys = Object.keys(message.routerModels || {}) | ||
| console.debug( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this debug logging?
- Simplify backend to use single provider filter instead of array - Use existing isDynamicProvider from @roo-code/types instead of duplicating - Update frontend to request only the needed provider - Gate router model fetches entirely for static providers - Remove unnecessary debug logging - Update tests to reflect new behavior This combines and improves upon PRs #8916 and #8917 by: 1. Using a simpler single-provider API (provider: string instead of providers: string[]) 2. Leveraging existing type definitions from packages/types 3. Eliminating race conditions through simpler request/response matching 4. Reducing payload sizes and network usage Closes #8916 Closes #8917
|
Closing in favor of combined PR #8956 which addresses all feedback and uses a simpler single-provider API |
Problem
Part of the webview memory mitigation effort. The frontend was requesting all router models regardless of which provider was selected. This caused unnecessary memory allocation and cache reconciliation for models that would never be used.
Solution
Implement intelligent provider filtering in the frontend:
useRouterModelsentirely for static providersChanges
useSelectedModel.ts
DYNAMIC_ROUTER_PROVIDERSset defining providers that need router modelsenabled: falseproviders: [selectedProvider]useRouterModels.ts
enabledoption supportTests
useSelectedModel.spec.tsfor new static provider behaviorImpact
Before:
After:
Memory savings:
Files Changed
webview-ui/src/components/ui/hooks/useSelectedModel.tswebview-ui/src/components/ui/hooks/useRouterModels.tswebview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.tsTesting
Part of
This is the third PR in a series to reduce webview memory usage:
Dependencies
Requires PR #8916 to be merged first for backend filtering support. This PR sends provider filters that the backend must honor.
Manual Testing
[useRouterModels] request providers=["roo"]Important
Optimizes router model fetching by introducing provider-specific logic, reducing unnecessary memory usage for static providers.
useSelectedModel.ts: IntroducesDYNAMIC_ROUTER_PROVIDERSset to identify providers needing router models.useRouterModelsfor static providers and fetches only specific provider models for dynamic ones.useRouterModels.ts: Addsenabledoption and provider filtering togetRouterModels().useSelectedModel.spec.tsto test new static provider behavior and ensure correct loading/error states.This description was created by
for 1ff5392. You can customize this summary. It will automatically update as commits are pushed.