Skip to content

Conversation

@SannidhyaSah
Copy link
Collaborator

@SannidhyaSah SannidhyaSah commented May 22, 2025

Description

This pull request introduces significant enhancements to the context condensing feature, providing users with more control and flexibility. The changes that were implemented include:

  • Custom API Configuration for Condensing: Users can now select a specific API configuration (from their existing API profiles) to be used exclusively for context condensing tasks. This is managed via a new dropdown in the "Experimental Settings" section.
  • Custom System Prompt for Condensing: Users can define a custom system prompt that will be used during the summarization process for context condensing. This is configurable via a new textarea in "Experimental Settings".
  • Backend State Management: New global settings (condensingApiConfigId, customCondensingPrompt) were added and integrated into the extension's state management.
  • Core Logic Updates: The core condensing function (summarizeConversation) and related task logic (Task.ts, sliding-window/index.ts) were updated to utilize these new settings, including validation and fallback mechanisms for the API handler.
  • UI Implementation: New UI components (dropdown and textarea) were added to ExperimentalSettings.tsx along with necessary i18n localization updates.
  • Error Handling & Logging: Improved error handling for invalid API configurations and logging for when custom settings are used.
  • Comprehensive Testing: New unit tests were added to src/core/condense/__tests__/index.test.ts and new integration tests were created in e2e/src/suite/condensing.test.ts to cover the new functionality.

These changes allow for more tailored and potentially more effective context summarization based on user preferences and specific API capabilities.

Test Procedure

  1. Automated Tests:

    • Ensure all unit tests pass: npm run test:unit src/core/condense/__tests__/index.test.ts
    • Ensure all integration tests pass: npm run test:e2e e2e/src/suite/condensing.test.ts (or the full e2e suite via pnpm test).
    • All project checks (compilation, linting, Knip) have passed via pre-commit/pre-push hooks. The current pnpm test run will provide final confirmation.
  2. Manual Testing Steps:

    • Navigate to VSCode Settings -> Extensions -> Roo Code -> Experimental Settings.
    • Test API Configuration Selection:
      • Observe the new "Condensing API Configuration" dropdown. It should list your available API profiles and a "Default" option.
      • Select a specific API profile from the dropdown.
      • Save the settings.
      • Trigger a context condensing operation (e.g., by having a long conversation that exceeds token limits).
      • Verify (e.g., through logs or by observing behavior if the selected API profile has distinct characteristics) that the chosen API configuration was used for condensing.
      • Select an invalid/deleted API configuration ID (if possible to simulate, or test the fallback by temporarily making a config invalid) and verify it falls back to the default condensing mechanism.
    • Test Custom Condensing Prompt:
      • In Experimental Settings, enter a specific custom prompt into the "Custom Condensing System Prompt" textarea.
      • Save the settings.
      • Trigger a context condensing operation.
      • Verify that the custom prompt was used (this might require inspecting the summarized output for characteristics influenced by your custom prompt, or checking logs if detailed logging for prompts is available).
    • Test Default Behavior:
      • Set "Condensing API Configuration" to "Default".
      • Clear the "Custom Condensing System Prompt" textarea.
      • Save settings.
      • Trigger a context condensing operation and verify it uses the standard condensing mechanism and prompt.
    • Test Persistence:
      • Close and reopen VSCode.
      • Verify that your chosen condensing settings in Experimental Settings are persisted.

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). (Note: Marked as N/A as per discussion)
  • 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 / pre-commit hooks).
    • 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 / pnpm test). (Currently running - will update this checkbox based on results)
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date (rebased) with the main branch. (Please verify before merging)
  • 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. (Consider if this user-facing feature warrants a changeset: pnpm changeset)
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

OLD

image

NEW

image

Documentation Updates

Information about the new configurable settings needs to be be added in the docs.

Additional Notes

Get in Touch


Important

Enhancements to context condensing feature include customizable API configurations and system prompts, updated backend state management, improved error handling, and comprehensive testing.

  • Behavior:
    • Users can select a specific API configuration for context condensing via a new dropdown in "Experimental Settings".
    • Users can define a custom system prompt for condensing via a new textarea in "Experimental Settings".
    • New global settings condensingApiConfigId and customCondensingPrompt added to state management.
    • Core condensing function summarizeConversation updated to use new settings with validation and fallback.
  • UI:
    • Added dropdown and textarea components to ExperimentalSettings.tsx.
    • Updated i18n localization for new UI elements.
  • Error Handling & Logging:
    • Improved error handling for invalid API configurations.
    • Added logging for custom settings usage.
  • Testing:
    • Added unit tests in index.test.ts and integration tests in condensing.test.ts for new functionality.

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

SannidhyaSah and others added 4 commits May 22, 2025 16:09
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Comment on lines 134 to 148
// Log when using custom prompt for debugging and telemetry
if (customCondensingPrompt?.trim()) {
console.log(`Task [${taskId}]: Using custom condensing prompt.`)
// TODO: Add telemetry for custom condensing prompt usage
// This would require extending the telemetry service with a new method like:
// telemetryService.captureCustomCondensingPromptUsed(taskId);
}

// Log when using custom API handler for condensing
if (condensingApiHandler) {
console.log(`Task [${taskId}]: Using custom API handler for condensing.`)
// TODO: Add telemetry for custom condensing API handler usage
// This would require extending the telemetry service with a new method like:
// telemetryService.captureCustomCondensingApiUsed(taskId, condensingApiConfigId);
}
Copy link
Collaborator

@mrubens mrubens May 22, 2025

Choose a reason for hiding this comment

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

Instead of this, how about we just add a couple new properties to telemetryService.captureContextCondensed(taskId, isAutomaticTrigger ?? false) above?

} = (await this.providerRef.deref()?.getState()) ?? {}

// Get condensing configuration for automatic triggers
const state = await this.providerRef.deref()?.getState()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Code might be a little cleaner if you put this at the top of the method const state = await this.providerRef.deref()?.getState() ?? {} and then just directly refer to state.customCondensingPrompt etc

</div>
<VSCodeTextArea
resize="vertical"
value={customCondensingPrompt || ""}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this would be easier to use if the value defaulted to SUMMARY_PROMPT to make it obvious what the default is and to make it easier for people to make minor adjustments. In this case we wouldn't need a placeholder, and hitting the reset button would just populate with the default value.

Copy link
Collaborator

@mrubens mrubens left a comment

Choose a reason for hiding this comment

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

Awesome! Really excited about getting this live. Message me on Discord if you want to discuss any of the feedback. Thank you!

@SannidhyaSah
Copy link
Collaborator Author

Awesome! Really excited about getting this live. Message me on Discord if you want to discuss any of the feedback. Thank you!

I've made the proposed changes. Please review them.

@mrubens mrubens merged commit d149d65 into RooCodeInc:main May 22, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap May 22, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap May 22, 2025
@SannidhyaSah SannidhyaSah deleted the feature/condensing-enhancements branch May 23, 2025 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants