Skip to content

feat: make compaction prompts configurable at runtime - #343

Open
philau2512 wants to merge 1 commit into
leookun:mainfrom
philaudev:feat/runtime-compaction-config
Open

feat: make compaction prompts configurable at runtime#343
philau2512 wants to merge 1 commit into
leookun:mainfrom
philaudev:feat/runtime-compaction-config

Conversation

@philau2512

@philau2512 philau2512 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Feature Pull Request

User Story

  • As a: Cursor BYOK desktop user
  • I want to: customize the conversation compaction prompt from a local configuration file
  • So that: I can control how conversations are summarized without rebuilding or restarting the application

Acceptance Criteria

  • The application creates ~/.cursor-byok-v3/rules/compaction.md from the bundled default prompt when the file does not exist.
  • Existing user-edited prompt files are preserved and never overwritten.
  • Each manual (/summarize) and automatic compaction reads the current file contents, so saved edits apply without restarting the application.
  • An empty or whitespace-only prompt file falls back to the bundled compaction prompt.
  • The desktop app provides a Config page with an action to open the prompt file in the system default editor.
  • Read errors identify the affected configuration file instead of silently reverting to the bundled prompt.

Key Changes

  • Added managed runtime configuration for the compaction prompt at:
    ~/.cursor-byok-v3/rules/compaction.md
    
  • The prompt compiler reads the configured file for every compaction request and continues substituting {{FAKE_MODEL_NAME}}.
  • Manual /summarize and automatic context-window compaction now use the same compiled runtime compaction prompt.
  • Removed the separate hard-coded prompt previously used by automatic compaction.
  • Empty or whitespace-only configuration files use the bundled default compaction prompt.
  • Missing, unreadable, or invalid UTF-8 configuration files produce an explicit error naming the affected path; they do not silently fall back.
  • Added tests for default-file creation, preservation of existing content, runtime reload behavior, readable file errors, and empty-file fallback.
  • Added a desktop Config page, navigation entry, Tauri command, and fixed-file permission for opening the configuration file with the system default editor.
  • Added English and Chinese translations for the configuration interface.

Demo

N/A

Testing

  • Self-reviewed
  • Automated verification:
    • cargo test prompting::compiler::tests
    • cargo test --no-run
    • cargo test --test compaction
    • cargo check
  • Manual test steps:
    1. Start the desktop application.
    2. Open Harness → Config.
    3. Select Open configuration file.
    4. Confirm that ~/.cursor-byok-v3/rules/compaction.md opens in the system default editor.
    5. Edit and save the prompt file.
    6. Trigger /summarize and verify the subsequent model request uses the saved prompt.
    7. Trigger automatic compaction by exceeding the configured context threshold and verify it uses the same saved prompt.
    8. Empty the file, save it, and verify both compaction paths use the bundled default prompt.
    9. Delete, make unreadable, or replace the file with invalid UTF-8, then verify the application reports a configuration error naming that file.

Impact & Reviewer Notes

  • Database Migration: No.
  • Environment Variables: No.
  • Permissions / Access Control: Yes. Adds a narrowly scoped Tauri permission for the fixed compaction prompt file opening command. The frontend cannot provide an arbitrary file path.
  • Risk / Review Focus:
    • Confirm both /summarize and automatic compaction use the same runtime prompt.
    • Confirm empty files fall back only to the bundled default prompt.
    • Confirm deleted, unreadable, and invalid UTF-8 files return an explicit configuration error instead of silently falling back.
image

@philau2512
philau2512 marked this pull request as draft August 25, 2026 09:36
@philau2512
philau2512 marked this pull request as ready for review August 25, 2026 09:39
@leookun

leookun commented Aug 25, 2026

Copy link
Copy Markdown
Owner

I’m wondering whether this feature may not be necessary, as many of our users may not be familiar with this type of configuration. It could potentially cause some confusion and require additional explanation and support.

For example, I’m considering simplifying the Provider even further:
#333

I still think this PR is very valuable, but perhaps we could avoid adding a configuration UI. Instead, if ~/.cursor-byok-v3/prompts/compaction.md exists (separate from rules), it could automatically override the built-in prompt. We could then document this later as an advanced feature for users who need it.

Co-authored-by: philau2512 <dplau25122002@gmail.com>
@leookun

leookun commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Thanks again for the contribution. I’ve prepared a much smaller implementation based on the core idea of this PR:

cfc333d

This version:

only checks ~/.cursor-byok-v3/prompts/compaction.md;
uses it to override the built-in prompt when the file exists and is non-empty;
falls back to the built-in prompt when the file is missing or empty;
applies to both manual and automatic compaction;
does not create the file automatically;
does not add configuration UI or include the unrelated global rules changes.
Since the current PR branch contains the broader implementation, could you please replace it with this clean commit? You can do that with:

git fetch https://github.com/leookun/cursor-byok.git fix/pr343-minimal-compaction-prompt
git switch feat/runtime-compaction-config
git reset --hard FETCH_HEAD
git push --force-with-lease origin feat/runtime-compaction-config
I’ve also kept your contribution credited through Co-authored-by.

@philau2512
philau2512 force-pushed the feat/runtime-compaction-config branch from aa07133 to cfc333d Compare August 26, 2026 18:54
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.

2 participants