Skip to content

fix: allow repeated automatic compaction - #354

Open
injectiver wants to merge 2 commits into
leookun:mainfrom
injectiver:fix/repeated-auto-compaction-upstream
Open

fix: allow repeated automatic compaction#354
injectiver wants to merge 2 commits into
leookun:mainfrom
injectiver:fix/repeated-auto-compaction-upstream

Conversation

@injectiver

Copy link
Copy Markdown

Summary

  • allow automatic compaction to run again after a new revision adds more context
  • generate a unique runtime event ID for every automatic compaction
  • cap model-projected tool-result text at 64 KiB while preserving the complete result in local storage
  • reuse one UTF-8-safe head/tail truncation helper for provider projection and shell output

Motivation

A long Agent run can compact successfully and then receive another multi-megabyte tool result. The previous one-shot guard prevented a second compaction, so the next provider request could fail with context_too_large. Reusing the same automatic-summary event ID also caused the store to reject a second summary with different content.

Testing

  • cargo test -p cursor-server --lib automatic_compaction_can_run_again_after_the_revision_advances
  • cargo test -p cursor-server --lib oversized_tool_results_are_bounded_only_in_provider_projection
  • cargo test -p cursor-server --test tool_loop one_run_can_auto_compact_again_after_more_tool_output

The integration regression test produces two consecutive 4 MiB Read results in one Agent run and verifies the sequence normal call → compaction → normal call → compaction → final call. Each provider projection is limited to 64 KiB, while both complete results remain stored in SQLite.

Xiashangning added a commit to Xiashangning/cursor-byok that referenced this pull request Aug 27, 2026
Brings in two fixes from leookun#354:
- fix: allow repeated automatic compaction
- fix: estimate compaction from projected history

Semantic conflicts resolved in server/tests/tool_loop.rs: updated the
new repeated-compaction test to the current ModelConfigInput fields
(effort_options, context_options) and PromptCompiler::new signature.
Xiashangning added a commit to Xiashangning/cursor-byok that referenced this pull request Aug 27, 2026
Brings in two fixes from leookun#354:
- fix: allow repeated automatic compaction
- fix: estimate compaction from projected history

Semantic conflicts resolved in server/tests/tool_loop.rs: updated the
new repeated-compaction test to the current ModelConfigInput fields
(effort_options, context_options) and PromptCompiler::new signature.
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.

1 participant