Skip to content

Feat: Profile condense override with model-aware token caps#5845

Closed
Neonsy wants to merge 2 commits intoKilo-Org:mainfrom
Neonsy:feat/profile-context-override-and-none-percentage-value-option
Closed

Feat: Profile condense override with model-aware token caps#5845
Neonsy wants to merge 2 commits intoKilo-Org:mainfrom
Neonsy:feat/profile-context-override-and-none-percentage-value-option

Conversation

@Neonsy
Copy link
Copy Markdown

@Neonsy Neonsy commented Feb 13, 2026

Context

Implemented a surgical redesign of condense trigger settings so global behavior stays percent-based, while profile-level behavior can be explicitly overridden per settings-selected profile using either % of hard limit or a fixed token threshold.
This addresses UX confusion around percentage-only control by allowing direct token targeting without changing global semantics.

Implementation

Added a new profileCondenseOverrides setting shape and threaded it through shared types, extension state, provider serialization, webview settings payload flow, and runtime threshold resolution.

Key changes:

  • Kept global auto-condense toggle + global percent slider behavior unchanged.
  • Removed inline profile selector from condense threshold controls.
  • Added a current-profile-only override block with:
    • Override for this profile enable checkbox
    • mode selector: % of hard limit / Fixed token limit
    • percent editor (5..100) with computed token equivalent
    • token editor clamped to model effective budget
    • hard-limit/cap display and inline clamp notice when cap decreases
  • Implemented centralized runtime threshold resolution so willManageContext and manageContext share the same logic.
  • Preserved hard safety behavior (prevContextTokens > allowedTokens still forces context management).
  • Kept legacy profileThresholds as backward-compatible read fallback; new writes use profileCondenseOverrides.
  • Added/updated tests for UI behavior, settings payload/change detection, provider round-trip/defaults, and core context trigger behavior.
  • Added a changeset for the user-facing feature.

How to Test

  1. In Settings, go to Context Management.
  2. Verify global auto-condense + global percent slider still behaves as before.
  3. Verify there is no profile dropdown inside condense threshold controls.
  4. In the new current-profile override block:
    • Toggle override OFF and confirm mode/inputs are disabled.
    • Toggle override ON and confirm mode/inputs are enabled.
  5. In % mode:
    • Set a percent value and confirm computed token equivalent updates.
  6. In Fixed token limit mode:
    • Enter a token value and confirm it clamps to the displayed model hard cap/effective budget.
  7. Change profile/model from settings-selected profile and confirm:
    • token value auto-clamps when cap decreases
    • inline clamp notice is shown.
  8. Validate tests:
    • cd webview-ui && pnpm test src/components/settings/__tests__/ContextManagementSettings.spec.tsx
    • cd webview-ui && pnpm test src/components/settings/__tests__/SettingsView.change-detection.spec.tsx
    • cd webview-ui && pnpm test src/components/settings/__tests__/SettingsView.unsaved-changes.spec.tsx
    • cd src && pnpm test core/context-management/__tests__/context-management.spec.ts
    • cd src && pnpm test core/webview/__tests__/ClineProvider.spec.ts
  9. Repo-level checks:
    • cd src && pnpm check-types
    • cd src && pnpm lint
    • pnpm build

Note

Research done by myself (mostly) but implementation was fully done by AI this time.

I have only tested the basics, so I'm not aware of edge cases.

@abdulrahimpds @mikij @bernaferrari @kevinvandijk

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 13, 2026

🦋 Changeset detected

Latest commit: 98ae2e5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kilo-code Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Neonsy Neonsy changed the title Profile condense override with modes and model-aware token caps Feat: Profile condense override with model-aware token caps Feb 13, 2026
@Neonsy Neonsy force-pushed the feat/profile-context-override-and-none-percentage-value-option branch from cdb4aa8 to 9b84b90 Compare February 13, 2026 15:16
@bernaferrari
Copy link
Copy Markdown
Contributor

bernaferrari commented Feb 13, 2026

I like it!!

@Neonsy
Copy link
Copy Markdown
Author

Neonsy commented Feb 13, 2026

I like it!!

@abdulrahimpds suggested it on Discord

@Neonsy Neonsy force-pushed the feat/profile-context-override-and-none-percentage-value-option branch from 9b84b90 to 8be03a8 Compare February 13, 2026 16:52
@abdulrahimpds
Copy link
Copy Markdown

@Neonsy will look into it soon

@Neonsy
Copy link
Copy Markdown
Author

Neonsy commented Feb 13, 2026

I probably won't change the core PR though, cause this current setup makes the most sense

You cannot have a fixed size limit as global, cause models have different max values

@Neonsy Neonsy force-pushed the feat/profile-context-override-and-none-percentage-value-option branch from 8be03a8 to f224829 Compare February 14, 2026 11:03
@Neonsy Neonsy force-pushed the feat/profile-context-override-and-none-percentage-value-option branch 5 times, most recently from d8f0678 to 3fda336 Compare February 18, 2026 11:59
@Neonsy Neonsy force-pushed the feat/profile-context-override-and-none-percentage-value-option branch from 3fda336 to 98ae2e5 Compare February 22, 2026 00:46
export const TOKEN_BUFFER_PERCENTAGE = 0.1

// kilocode_change start
export type ProfileCondenseOverride = {
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.

[SUGGESTION]: Duplicate type definition — ProfileCondenseOverride is already defined and exported from @roo-code/types via packages/types/src/global-settings.ts (line 64). Consider importing it instead of redefining it here to keep a single source of truth.

The same shape is also duplicated as ProfileCondenseOverrideValue in ContextManagementSettings.tsx and inline in vscode-extension-host.ts. Consolidating to one canonical type from @roo-code/types would reduce maintenance burden.

export const profileCondenseOverrideSchema = z.object({
enabled: z.boolean(),
mode: profileCondenseOverrideModeSchema,
percent: z.number(),
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.

[SUGGESTION]: The Zod schema uses bare z.number() for percent and tokens without range constraints. While the application layer clamps values (e.g., clampNumber in the UI and resolveCondenseTrigger on the backend), adding .min()/.max() here would provide defense-in-depth validation at the schema level.

For example:

percent: z.number().min(0).max(100),
tokens: z.number().min(0),

}),
)
}
}, [currentProfileId, hardLimitTokens, profileCondenseOverrides, t]) // eslint-disable-line react-hooks/exhaustive-deps
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.

[SUGGESTION]: The eslint-disable-line react-hooks/exhaustive-deps suppresses the missing updateCurrentProfileOverride dependency. While this is safe in practice (since profileCondenseOverrides is already in the deps array), wrapping updateCurrentProfileOverride in React.useCallback would eliminate the need for the suppression and make the dependency chain explicit.

"defaultProfile": "افتراضي عام",
"defaultDescription": "إذا وصل السياق للنسبة يختصر (لكل الملفات).",
"profileDescription": "نسبة مخصصة لهذا الملف فقط.",
"profileOverrideLabel": "Override for this profile",
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.

[WARNING]: All 8 new translation keys (profileOverrideLabel, currentProfileLabel, hardLimitLabel, mode.percent, mode.tokens, percentEquivalent, tokensUnit, profileTokenClamped) are untranslated English strings in all 21 non-English locale files. These should be translated or flagged for localization follow-up.

This comment applies to all non-English locale files changed in this PR (ar, ca, cs, de, es, fr, hi, id, it, ja, ko, nl, pl, pt-BR, ru, sk, th, tr, uk, vi, zh-CN, zh-TW).

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Feb 22, 2026

Code Review Summary

Status: 4 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 3
Issue Details (click to expand)

WARNING

File Line Issue
webview-ui/src/i18n/locales/ar/settings.json (and 21 other locale files) 925 All 8 new i18n keys are untranslated English strings in all non-English locales

SUGGESTION

File Line Issue
src/core/context-management/index.ts 28 ProfileCondenseOverride type is duplicated in 4 places — could import from @roo-code/types
packages/types/src/global-settings.ts 61 Zod schema z.number() lacks .min()/.max() range constraints for percent and tokens
webview-ui/src/components/settings/ContextManagementSettings.tsx 156 eslint-disable-line react-hooks/exhaustive-deps could be avoided by wrapping updateCurrentProfileOverride in useCallback
Other Observations (not in diff)

Issues found in unchanged code or cross-cutting concerns:

File Line Issue
Non-English locale files Various The selectProfile i18n key was removed from en/settings.json but remains as dead code in all other locale files
Files Reviewed (38 files)
  • .changeset/bright-taxis-share.md - 0 issues
  • packages/types/src/global-settings.ts - 1 issue
  • packages/types/src/vscode-extension-host.ts - 0 issues
  • src/core/context-management/__tests__/context-management.spec.ts - 0 issues
  • src/core/context-management/index.ts - 1 issue
  • src/core/task/Task.ts - 0 issues
  • src/core/webview/ClineProvider.ts - 0 issues
  • src/core/webview/__tests__/ClineProvider.spec.ts - 0 issues
  • webview-ui/src/components/settings/ContextManagementSettings.tsx - 1 issue
  • webview-ui/src/components/settings/SettingsView.tsx - 0 issues
  • webview-ui/src/components/settings/__tests__/ContextManagementSettings.spec.tsx - 0 issues
  • webview-ui/src/components/settings/__tests__/SettingsView.change-detection.spec.tsx - 0 issues
  • webview-ui/src/components/settings/__tests__/SettingsView.unsaved-changes.spec.tsx - 0 issues
  • webview-ui/src/context/ExtensionStateContext.tsx - 0 issues
  • webview-ui/src/context/__tests__/ExtensionStateContext.spec.tsx - 0 issues
  • webview-ui/src/i18n/locales/ar/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/ca/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/cs/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/de/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/en/settings.json - 0 issues
  • webview-ui/src/i18n/locales/es/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/fr/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/hi/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/id/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/it/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/ja/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/ko/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/nl/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/pl/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/pt-BR/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/ru/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/sk/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/th/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/tr/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/uk/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/vi/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/zh-CN/settings.json - 1 issue (untranslated)
  • webview-ui/src/i18n/locales/zh-TW/settings.json - 1 issue (untranslated)

Fix these issues in Kilo Cloud

@markijbema
Copy link
Copy Markdown
Contributor

Hi! Thank you for taking the time to contribute to this project—we really appreciate it.

We are currently working on re-platforming the core of our VS Code and JetBrains extensions to be based on our new Kilo CLI, with a complete rebuild based on OpenCode as our new foundation, which means this PR unfortunately won't be compatible with the new architecture.

If you think this feature or fix is still relevant, we'd love for you to check out the new version and consider contributing it there. The new code is now in this repository. Alternatively, if you think this is an urgent fix to the old vscode extension (like a recent model change, or an urgent bug fix), we’d welcome the PR at https://github.com/Kilo-Org/kilocode-legacy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants