Skip to content

feat(condense): allow provider profile override#904

Open
twinlunarstarz-dev wants to merge 1 commit into
Zoo-Code-Org:mainfrom
twinlunarstarz-dev:feat/context-condensing-profile-override
Open

feat(condense): allow provider profile override#904
twinlunarstarz-dev wants to merge 1 commit into
Zoo-Code-Org:mainfrom
twinlunarstarz-dev:feat/context-condensing-profile-override

Conversation

@twinlunarstarz-dev

@twinlunarstarz-dev twinlunarstarz-dev commented Jul 16, 2026

Copy link
Copy Markdown

Related GitHub Issue

Closes: #609

Description

Adds an opt-in context-condensing model override in Context Management settings.

  • Keeps the current mode's model as the default and as an explicit dropdown option.
  • Shows the provider-profile dropdown only while the override is enabled.
  • Resolves the selected saved provider profile into an independent API handler.
  • Uses that handler for manual condensation, automatic threshold condensation, and forced context-window recovery.
  • Falls back to the current mode if the selected profile is missing or cannot be loaded.
  • Continues counting the post-condense context with the active task handler, because the resulting summary returns to that model.

The implementation deliberately reuses the existing provider-profile storage, cached SettingsView state, condensing pipeline, and fallback behavior. This keeps the production change limited to the settings schema/state wiring, one profile resolver, and one optional handler parameter through the existing condensation calls.

This aligns with the roadmap's reliability and provider/model support goals by allowing users to choose a compatible, lower-cost summarization model without changing their active task model.

Test Procedure

Automated verification:

  • pnpm --dir src exec vitest run core/task/__tests__/Task.spec.ts core/condense/__tests__/index.spec.ts core/context-management/__tests__/context-management.spec.ts core/webview/__tests__/ClineProvider.spec.ts
    • 299 tests passed.
  • pnpm --dir webview-ui exec vitest run src/components/settings/__tests__/ContextManagementSettings.spec.tsx src/components/settings/__tests__/SettingsView.change-detection.spec.tsx src/components/settings/__tests__/SettingsView.unsaved-changes.spec.tsx
    • 42 tests passed.
  • Type checks passed for src, webview-ui, and packages/types.
  • Lint passed for src, webview-ui, and packages/types.
  • Translation completeness passed with node scripts/find-missing-translations.js.
  • Full workspace production build passed with pnpm build.
  • A production VSIX was built and installed locally to verify the modified extension loads.

Runtime coverage specifically asserts that:

  1. Manual condensation loads the selected profile and passes its handler to summarizeConversation.
  2. Automatic threshold condensation passes the independently built handler through manageContext.
  3. Forced context-window recovery uses the same selected handler.
  4. summarizeConversation sends the request through the selected handler while retaining the active handler for post-condense token counting.
  5. The dropdown remains hidden until the override is enabled and includes the current-mode fallback.

Reviewer verification:

  1. Create at least two provider configuration profiles.
  2. Open Settings → Context Management.
  3. Enable Override the context condensing model.
  4. Select the secondary profile.
  5. Trigger manual context condensation or lower the automatic threshold until condensation runs.
  6. Confirm the secondary provider receives the condensation request while the active task remains on its original model.
  7. Select Use the model running in the current mode and confirm condensation returns to the active task model.

Testing environment: Windows, VS Code 1.108.2. The repository requests Node 20.20.2; local verification used Node 24.11.1 with pnpm 10.8.1 and completed successfully.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to GitHub Issue [ENHANCEMENT] Support user-configurable api/model profile for Context Compaction / Condensation #609.
  • Scope: The changes are focused exclusively on selecting the context-condensing provider profile.
  • Self-Review: The complete diff and all condensation entry points were reviewed.
  • Testing: Runtime and UI regression tests cover the new behavior.
  • Documentation Impact: Documentation impact was considered below.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

The production VSIX was installed and exercised locally. A screenshot is not attached because the new control uses the existing settings components and visual language; the component tests verify the conditional dropdown and its options. I can add an installed-extension screenshot if maintainers want one before moving the PR out of draft.

Documentation Updates

  • No documentation updates are required. The setting includes localized English label and description text in the existing Context Management UI.
  • Yes, documentation updates are required.

Additional Notes

  • The existing issue is assigned to @awschmeder. This is opened as a draft for collaboration and maintainer confirmation rather than assuming ownership.
  • The feature was previously removed upstream because raw provider-specific tool/reasoning blocks could be incompatible across models. The current condensing implementation already converts tool calls/results to text before the summarization request; this PR also chooses image filtering based on the condensing handler while leaving the stored conversation unchanged.
  • The selected profile is only loaded when condensation will actually run, avoiding profile resolution during ordinary requests below the threshold.
  • Codex materially assisted with implementation and verification. The resulting diff was reviewed against all three runtime entry points and the repository's contribution requirements.

Get in Touch

GitHub: @twinlunarstarz-dev. A Discord username was not provided.

Summary by CodeRabbit

  • New Features

    • Added an option to use a separate provider configuration for context condensing.
    • Added settings controls to enable the override and select a configuration or the current mode.
    • Context condensing now uses the selected configuration when available and safely falls back to the current configuration if needed.
  • Bug Fixes

    • Improved context-window recovery and condensation behavior when a selected configuration is unavailable.
  • Tests

    • Added coverage for configuration selection, fallback behavior, and settings interactions.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 78165dbd-f80e-4c0b-ad65-8e9dff98b7ce

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Context condensation now supports an optional provider API configuration override. Settings and extension state carry the selection, task flows resolve the selected profile, and summarization uses it while retaining the active handler for token counting and fallback.

Changes

Context condensing profile override

Layer / File(s) Summary
Settings contract and configuration UI
packages/types/src/*, src/core/webview/ClineProvider.ts, webview-ui/src/components/settings/*, webview-ui/src/i18n/locales/en/settings.json
Settings state now includes the condensing override flag and profile ID. The UI enables the override, selects a provider profile or current-mode configuration, and submits the values.
Condensing handler resolution
src/core/task/Task.ts, src/core/context-management/index.ts, src/core/condense/index.ts
Task context-management paths resolve a selected provider profile and pass its handler through to summarization. Invalid or unavailable handlers fall back to the active API handler with warnings.
Condensing behavior validation
src/core/condense/__tests__/index.spec.ts, src/core/task/__tests__/Task.spec.ts, webview-ui/src/components/settings/__tests__/ContextManagementSettings.spec.tsx
Tests cover handler selection, fallback behavior, profile resolution failures, retry recovery, and settings interactions.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Task
  participant ProviderSettingsManager
  participant ContextManagement
  participant SummarizeConversation
  Task->>ProviderSettingsManager: resolve selected condensing profile
  ProviderSettingsManager-->>Task: return profile configuration
  Task->>ContextManagement: pass condensingApiHandler
  ContextManagement->>SummarizeConversation: pass condensingApiHandler
  SummarizeConversation->>SummarizeConversation: send condensing request through selected handler
Loading

Suggested labels: awaiting-review

Suggested reviewers: navedmerchant

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the provider profile override for context condensation.
Description check ✅ Passed The PR description matches the template and fills the required issue, summary, testing, checklist, docs, and notes sections.
Linked Issues check ✅ Passed The changes implement #609's configurable condensing profile, handler fallback, UI selection, and settings/state wiring.
Out of Scope Changes check ✅ Passed The diff stays focused on condensation profile override plumbing, UI, tests, and localization without unrelated feature work.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@twinlunarstarz-dev twinlunarstarz-dev force-pushed the feat/context-condensing-profile-override branch from 6b6eb5f to 11e0fd3 Compare July 16, 2026 08:14
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@twinlunarstarz-dev twinlunarstarz-dev force-pushed the feat/context-condensing-profile-override branch from 11e0fd3 to 046bfd0 Compare July 16, 2026 08:28
@twinlunarstarz-dev twinlunarstarz-dev marked this pull request as ready for review July 16, 2026 08:40
@twinlunarstarz-dev

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/core/condense/__tests__/index.spec.ts (1)

1286-1306: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the fallback warning was actually logged.

warnSpy is created and mocked but never asserted on, so the test doesn't lock in the intentional console.warn fallback-notification behavior added in this PR.

✅ Proposed addition
 		try {
 			await summarizeConversation({
 				messages: sampleMessages,
 				apiHandler: mockMainApiHandler,
 				condensingApiHandler: invalidHandler,
 				systemPrompt: defaultSystemPrompt,
 				taskId: localTaskId,
 			})
 		} finally {
 			warnSpy.mockRestore()
 		}

 		expect(mockMainApiHandler.createMessage).toHaveBeenCalledOnce()
+		expect(warnSpy).toHaveBeenCalled()
 	})
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/core/condense/__tests__/index.spec.ts` around lines 1286 - 1306, Update
the test around summarizeConversation to assert that the mocked warnSpy records
the expected fallback warning when condensingApiHandler is invalid. Keep the
existing createMessage assertion and restore behavior unchanged, and match the
warning’s established message or relevant arguments.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@webview-ui/src/components/settings/ContextManagementSettings.tsx`:
- Around line 510-553: Remove the duplicate description div rendered inside the
condensingApiConfigOverride block in ContextManagementSettings, while preserving
the description shown below the checkbox and the select dropdown behavior.

---

Nitpick comments:
In `@src/core/condense/__tests__/index.spec.ts`:
- Around line 1286-1306: Update the test around summarizeConversation to assert
that the mocked warnSpy records the expected fallback warning when
condensingApiHandler is invalid. Keep the existing createMessage assertion and
restore behavior unchanged, and match the warning’s established message or
relevant arguments.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 522e9932-8bda-471e-85e3-730b927de00c

📥 Commits

Reviewing files that changed from the base of the PR and between c39535e and 046bfd0.

📒 Files selected for processing (12)
  • packages/types/src/global-settings.ts
  • packages/types/src/vscode-extension-host.ts
  • src/core/condense/__tests__/index.spec.ts
  • src/core/condense/index.ts
  • src/core/context-management/index.ts
  • src/core/task/Task.ts
  • src/core/task/__tests__/Task.spec.ts
  • src/core/webview/ClineProvider.ts
  • webview-ui/src/components/settings/ContextManagementSettings.tsx
  • webview-ui/src/components/settings/SettingsView.tsx
  • webview-ui/src/components/settings/__tests__/ContextManagementSettings.spec.tsx
  • webview-ui/src/i18n/locales/en/settings.json

Comment on lines +510 to +553
<SearchableSetting
settingId="context-condensing-model-override"
section="contextManagement"
label={t("settings:contextManagement.condensingApiConfiguration.label")}>
<VSCodeCheckbox
checked={condensingApiConfigOverride}
onChange={(e: any) => setCachedStateField("condensingApiConfigOverride", e.target.checked)}
data-testid="condensing-model-override-checkbox">
<span className="font-medium">
{t("settings:contextManagement.condensingApiConfiguration.label")}
</span>
</VSCodeCheckbox>
<div className="text-vscode-descriptionForeground text-sm mt-1">
{t("settings:contextManagement.condensingApiConfiguration.description")}
</div>
{condensingApiConfigOverride && (
<div className="mt-3">
<Select
value={condensingApiConfigId || "current-mode"}
onValueChange={(value) =>
setCachedStateField("condensingApiConfigId", value === "current-mode" ? "" : value)
}
data-testid="condensing-profile-select">
<SelectTrigger className="w-full">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="current-mode">
{t("settings:contextManagement.condensingApiConfiguration.useCurrentConfig")}
</SelectItem>
{listApiConfigMeta.map((config) => (
<SelectItem key={config.id} value={config.id}>
{config.name}
</SelectItem>
))}
</SelectContent>
</Select>
<div className="text-vscode-descriptionForeground text-sm mt-1">
{t("settings:contextManagement.condensingApiConfiguration.description")}
</div>
</div>
)}
</SearchableSetting>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove the duplicate description text.

The description text is currently rendered twice when the override is enabled: once below the checkbox and again below the select dropdown. Please remove this second instance to keep the UI clean.

♻️ Proposed fix
 							</Select>
-							<div className="text-vscode-descriptionForeground text-sm mt-1">
-								{t("settings:contextManagement.condensingApiConfiguration.description")}
-							</div>
 						</div>
 					)}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<SearchableSetting
settingId="context-condensing-model-override"
section="contextManagement"
label={t("settings:contextManagement.condensingApiConfiguration.label")}>
<VSCodeCheckbox
checked={condensingApiConfigOverride}
onChange={(e: any) => setCachedStateField("condensingApiConfigOverride", e.target.checked)}
data-testid="condensing-model-override-checkbox">
<span className="font-medium">
{t("settings:contextManagement.condensingApiConfiguration.label")}
</span>
</VSCodeCheckbox>
<div className="text-vscode-descriptionForeground text-sm mt-1">
{t("settings:contextManagement.condensingApiConfiguration.description")}
</div>
{condensingApiConfigOverride && (
<div className="mt-3">
<Select
value={condensingApiConfigId || "current-mode"}
onValueChange={(value) =>
setCachedStateField("condensingApiConfigId", value === "current-mode" ? "" : value)
}
data-testid="condensing-profile-select">
<SelectTrigger className="w-full">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="current-mode">
{t("settings:contextManagement.condensingApiConfiguration.useCurrentConfig")}
</SelectItem>
{listApiConfigMeta.map((config) => (
<SelectItem key={config.id} value={config.id}>
{config.name}
</SelectItem>
))}
</SelectContent>
</Select>
<div className="text-vscode-descriptionForeground text-sm mt-1">
{t("settings:contextManagement.condensingApiConfiguration.description")}
</div>
</div>
)}
</SearchableSetting>
<SearchableSetting
settingId="context-condensing-model-override"
section="contextManagement"
label={t("settings:contextManagement.condensingApiConfiguration.label")}>
<VSCodeCheckbox
checked={condensingApiConfigOverride}
onChange={(e: any) => setCachedStateField("condensingApiConfigOverride", e.target.checked)}
data-testid="condensing-model-override-checkbox">
<span className="font-medium">
{t("settings:contextManagement.condensingApiConfiguration.label")}
</span>
</VSCodeCheckbox>
<div className="text-vscode-descriptionForeground text-sm mt-1">
{t("settings:contextManagement.condensingApiConfiguration.description")}
</div>
{condensingApiConfigOverride && (
<div className="mt-3">
<Select
value={condensingApiConfigId || "current-mode"}
onValueChange={(value) =>
setCachedStateField("condensingApiConfigId", value === "current-mode" ? "" : value)
}
data-testid="condensing-profile-select">
<SelectTrigger className="w-full">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="current-mode">
{t("settings:contextManagement.condensingApiConfiguration.useCurrentConfig")}
</SelectItem>
{listApiConfigMeta.map((config) => (
<SelectItem key={config.id} value={config.id}>
{config.name}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
)}
</SearchableSetting>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@webview-ui/src/components/settings/ContextManagementSettings.tsx` around
lines 510 - 553, Remove the duplicate description div rendered inside the
condensingApiConfigOverride block in ContextManagementSettings, while preserving
the description shown below the checkbox and the select dropdown behavior.

@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR changes are ready and waiting for maintainer re-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Support user-configurable api/model profile for Context Compaction / Condensation

1 participant