8000 feat: add profile-specific context condensing thresholds by SannidhyaSah · Pull Request #4456 · RooCodeInc/Roo-Code · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add profile-specific context condensing thresholds #4456

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

SannidhyaSah
Copy link
@SannidhyaSah SannidhyaSah commented Jun 8, 2025

Related GitHub Issue

Related to: #4342 and Closes #4118

Description

This PR implements profile-specific context condensing thresholds, addressing one of the context management improvements outlined in issue #4342 (It also closes #4118) . This feature allows users to configure different automatic threshold percentages for intelligent context condensing based on their API configuration profiles. Previously, there was only a single global threshold that applied to all profiles, which was inefficient since different LLM models have varying context window sizes.

Key implementation details:

  • Added new settings profileSpecificThresholdsEnabled and profileThresholds to the global settings schema
  • Extended the sliding window algorithm to check for profile-specific thresholds before falling back to the global threshold
  • Created a new UI component ProfileThresholdManager for managing profile-specific configurations
  • Implemented support for -1 threshold values to indicate using the default global threshold
  • Added comprehensive state management and persistence for the new settings

What reviewers should focus on:

  • The logic in src/core/sliding-window/index.ts for threshold resolution
  • The new UI component integration in the settings panel
  • State synchronization between frontend and backend via vscode.postMessage

Test Procedure

Manual Testing:

  1. Open VSCode with the extension installed
  2. Navigate to Settings → Context Management
  3. Enable "Profile-Specific Thresholds" checkbox
  4. Select a profile from the dropdown and set a custom threshold (e.g., 75)
  5. Save the configuration and verify it appears in the list
  6. Test with -1 value to ensure it falls back to global threshold
  7. Start a conversation and verify the correct threshold is applied based on the active profile

Automated Testing:

  • Run pnpm test to execute all test suites
  • New tests cover both backend logic and frontend UI components
  • Tests verify threshold resolution logic, UI state management, and edge cases

Type of Change

  • 🐛 Bug Fix: Non-breaking change that fixes an issue.
  • New Feature: Non-breaking change that adds functionality.
  • 💥 Breaking Change: Fix or feature that would cause existing functionality to not work as expected.
  • ♻️ Refactor: Code change that neither fixes a bug nor adds a feature.
  • 💅 Style: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
  • 📚 Documentation: Updates to documentation files.
  • ⚙️ Build/CI: Changes to the build process or CI configuration.
  • 🧹 Chore: Other changes that don't modify src or test files.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Code Quality:
    • My code adheres to the project's style guidelines.
    • There are no new linting errors or warnings (npm run lint).
    • All debug code (e.g., console.log) has been removed.
  • Testing:
    • New and/or updated tests have been added to cover my changes.
    • All tests pass locally (npm test).
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date (rebased) with the main branch.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Changeset: A changeset has been created using npm run changeset if this PR includes user-facing changes or dependency updates.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Before: Only global threshold setting available

image

After: New profile-specific threshold management UI with:

  • Checkbox to enable/disable profile-specific thresholds
  • Dropdown to select API configuration profiles
  • Input field for threshold percentage (supports -1 for default)
  • Save/Remove buttons for managing configurations
  • List display of configured profile thresholds

image

Documentation Updates

  • No documentation updates are required.
  • Yes, documentation updates are required. The settings documentation should be updated to explain the new profile-specific threshold feature and how to configure it.

Additional Notes

This feature significantly improves the user experience for users working with multiple LLM models that have different context window sizes. The implementation maintains backward compatibility - existing users will continue to use the global threshold until they explicitly enable profile-specific thresholds.

The UI design follows the existing patterns in the settings panel and includes proper internationalization support with translation keys added to the English locale file.

This PR addresses one aspect of the context management improvements discussed in issue #4342. Additional PRs may be needed to fully address all the concerns raised in that issue.

Get in Touch

Discord: Lews


Important

Adds profile-specific context condensing thresholds, allowing different settings per API profile, with UI and backend support.

  • Behavior:
    • Introduces profile-specific context condensing thresholds in sliding-window/index.ts, allowing different thresholds per API configuration profile.
    • Supports -1 as a threshold value to use the global default.
  • Settings:
    • Adds profileThresholds to global-settings.ts schema.
    • Updates ContextManagementSettings.tsx to include UI for managing profile-specific thresholds.
  • Testing:
    • Extensive tests in sliding-window.test.ts for threshold logic and edge cases.
    • UI tests in ContextManagementSettings.test.tsx to verify new settings behavior.
  • Misc:
    • Updates ClineProvider.ts and webviewMessageHandler.ts for state synchronization.
    • Adds i18n support for new UI elements in multiple locale files.

This description was created by Ellipsis for a850d4d. You can customize this summary. It will automatically update as commits are pushed.

@samhvw8
Copy link
Collaborator
samhvw8 commented Jun 8, 2025

this is cool, since each model has difference context window and effective context window, this will be crucial pr feature :D

@mrubens
Copy link
Collaborator
mrubens commented Jun 8, 2025

What do you think of something like this where we just migrate them to all be profile-specific: #2655? Not sure we need a checkbox for this.

@SannidhyaSah
Copy link
Author

What do you think of something like this where we just migrate them to all be profile-specific: #2655? Not sure we need a checkbox for this.

I initially considered that placement. However, I've positioned this setting alongside the other auto-condensing options for a couple of reasons: it's directly related to that function, and it becomes irrelevant if auto-condensing is disabled.
Regarding the checkbox, you're right. It's unnecessary, and I'll remove it.
Please advise on the placement decision so I can proceed. I am currently implementing the rest of the settings page anyways .

- Remove emoji from info text and use codicon instead
- Restructure layout to vertical stack for better spacing
- Position Save button on far right using justify-between
- Apply consistent styling with other settings sections
- Update tests to match hardcoded info text
@mrubens
Copy link
Collaborator
mrubens commented Jun 8, 2025

Hmm, I deleted an earlier comment. I'm having trouble wrapping my head around the right user experience for this section that lets you both choose a specific profile or just use the current one, and now to also make the threshold a per-profile configuration. 🤔

Screenshot 2025-06-08 at 7 55 52 AM

@mrubens
Copy link
Collaborator
mrubens commented Jun 8, 2025

I actually think the best approach might be to put a profile selector dropdown above the threshold slider in my screenshot, the same as what we have in the section below. So you're configuring "Default" by default, but can choose another.

@SannidhyaSah
Copy link
Author
SannidhyaSah commented Jun 8, 2025

Hmm, I deleted an earlier comment. I'm having trouble wrapping my head around the right user experience for this section that lets you both choose a specific profile or just use the current one, and now to also make the threshold a per-profile configuration. 🤔

Screenshot 2025-06-08 at 7 55 52 AM

The API configuration for context condensing needs to be accessible even when automatic triggering is off, as it's also used for the manual trigger .
To fix this, I suggest we make the API and prompt settings always visible in the 'Context' tab. We can then group the settings that are only for automatic triggering into a separate section that expands when the user enables it

@mrubens
Copy link
Collaborator
mrubens commented Jun 8, 2025

The API configuration for context condensing needs to be accessible even when automatic triggering is off, as it's also used for the manual trigger . To fix this, I suggest we make the API and prompt settings always visible in the 'Context' tab. We can then group the settings that are only for automatic triggering into a separate section that expands when the user enables it

Good call

@daniel-lxs daniel-lxs moved this from Triage to PR [Draft / In Progress] in Roo Code Roadmap Jun 8, 2025
- Simplified context management settings by removing ProfileThresholdManager
- Updated global settings types and core sliding window logic
- Modified webview message handlers and extension state context
- Updated all locale files for settings translations
- Removed ProfileThresholdManager component and related tests
- Updated ContextManagementSettings and SettingsView components
@SannidhyaSah
Copy link
Author

image
@mrubens is this better ?

@SannidhyaSah SannidhyaSah marked this pull request as ready for review June 10, 2025 09:06
@SannidhyaSah SannidhyaSah requested review from mrubens, cte and jr as code owners June 10, 2025 09:06
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels Jun 10, 2025
@@ -389,6 +390,13 @@
"maxConcurrentFileReads": {
"label": "Limit jednoczesnych odczytów",
"description": "Maksymalna liczba plików, które narzędzie 'read_file' może przetwarzać jednocześnie. Wyższe wartości mogą przyspieszyć odczyt wielu małych plików, ale zwiększają zużycie pamięci."
},
"condensingThreshold": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New translation keys (in the condensingThreshold object) are added for profile‐specific context condensing thresholds, but the values remain in English. Please provide Polish translations to ensure a consistent localized experience.

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

@@ -389,6 +390,13 @@
"maxConcurrentFileReads": {
"label": "Лимит одновременного чтения",
"description": "Максимальное количество файлов, которые инструмент 'read_file' может обрабатывать одновременно. Более высокие значения могут ускорить чтение нескольких небольших файлов, но увеличивают использование памяти."
},
"condensingThreshold": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'condensingThreshold' block in the Russian translation remains in English. Please provide proper Russian translations for these keys to maintain consistency.

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

@@ -389,6 +390,13 @@
"maxConcurrentFileReads": {
"label": "Eşzamanlı dosya okuma sınırı",
"description": "'read_file' aracının aynı anda işleyebileceği maksimum dosya sayısı. Daha yüksek değerler birden çok küçük dosyanın okunmasını hızlandırabilir ancak bellek kullanımını artırır."
},
"condensingThreshold": {
8000 "label": "Context Condensing Threshold",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new condensingThreshold keys in the Turkish translation are still in English. Please update them with Turkish translations.

Suggested change
"label": "Context Condensing Threshold",
"label": "Bağlam Yoğunlaştırma Eşiği",

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

@@ -389,6 +390,13 @@
"maxConcurrentFileReads": {
"label": "Giới hạn đọc file đồng thời",
"description": "Số lượng file tối đa mà công cụ 'read_file' có thể xử lý cùng lúc. Giá trị cao hơn có thể tăng tốc độ đọc nhiều file nhỏ nhưng sẽ tăng mức sử dụng bộ nhớ."
},
"condensingThreshold": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'condensingThreshold' translation keys in the Vietnamese file are in English. Please update them with appropriate Vietnamese translations.

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

@@ -389,6 +390,13 @@
"maxConcurrentFileReads": {
"label": "並行檔案讀取限制",
"description": "read_file 工具可以同時處理的最大檔案數。較高的值可能會加快讀取多個小檔案的速度,但會增加記憶體使用量。"
},
"condensingThreshold": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condensingThreshold keys in the Traditional Chinese file are not localized and remain in English. Please update them with appropriate Traditional Chinese translations.

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

@daniel-lxs daniel-lxs moved this from PR [Draft / In Progress] to PR [Needs Prelim Review] in Roo Code Roadmap Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PR - Needs Preliminary Review size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
Status: PR [Needs Prelim Review]
Development

Successfully merging this pull request may close these issues.

Context Condensing - Suggestion to Improve
5 participants
0