Skip to content

feat: Add context window support for AI providersΒ #7209

@jiayi-xdu

Description

@jiayi-xdu

What specific problem does this solve?

Currently, Roo-Code relies on fixed context window sizes predetermined by model providers. During extended conversations or when processing large documents, the context window can grow excessively large, leading to significant performance degradation and noticeably slower response times. Furthermore, in scenarios with file size or upload restrictions, this oversized context frequently exceeds system limits, causing operations to fail and preventing users from completing their tasks.

Additional context (optional)

No response

Roo Code Task Links (Optional)

No response

Request checklist

  • I've searched existing Issues and Discussions for duplicates
  • This describes a specific problem with clear impact and context

Interested in implementing this?

  • Yes, I'd like to help implement this feature

Implementation requirements

  • I understand this needs approval before implementation begins

How should this be solved? (REQUIRED if contributing, optional otherwise)

Add Custom Context Window Size Support for Model Providers

  • Support Custom Model Info in Schema: Extend the baseProviderSettingsSchema to include an optional CustomModelInfo field for user-defined token limits.
  • Add An Input Field In UI: Added reusable context window input component with validation and visual feedback in webview-ui/src/components/common/ContextWindow.tsx. Support for displaying and editing custom model information, with default values used as fallback when no custom information is provided.
  • Provider Model Handling: Update info if CustomModelInfo is provided. Get CustomModelInfo in getModel function in src/api/providers/*.ts, update info if CustomModelInfo is provided.

How will we know it works? (Acceptance Criteria - REQUIRED if contributing, optional otherwise)

Given a user editing a model provider's settings (e.g., Groq/Vertex)
When user select a model and enter "128000" in the context window size field and save the setting
Then the value is provided to model provider
And saved to CustomModelInfo when settings are submitted
But no changes are made to othermodel parameters

Technical considerations (REQUIRED if contributing, optional otherwise)

The implementation will affect the following files:
packages/types/src/provider-settings.ts
webview-ui/src/components/common/ContextWindow.tsx (new)
webview-ui/src/components/settings/providers/.tsx
src/api/providers/
.tsx

Trade-offs and risks (REQUIRED if contributing, optional otherwise)

If user give a low context window and open Automativally trigger intelligent context condensing, summary may fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue/PR - TriageNew issue. Needs quick review to confirm validity and assign labels.enhancementNew feature or requestproposal

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions