feat(agent): restructure context compression handoff - #1903
Merged
Conversation
- unify manual and automatic compression through a shared token-budgeted plan - retain historical user messages before the summary and preserve the exact recent context suffix - keep tool call and result groups atomic when selecting recent context - add a dedicated continuation reminder and replace stale reminders during recompression - refine the compaction prompt and summary assembly for concise task handoffs - retry context overflows using the next complete atomic message boundary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
min(20k, context_window * 10%).Fixes #
Type and Areas
Type:
Feature / refactor
Areas:
Rust core, agent session compression, agent execution
Motivation / Impact
The previous compression flow depended on the model to reproduce user messages and handled manual and automatic compression differently. It also used turn anchors and boundary reminders when the recent-context cutoff split a turn.
This change uses locally available conversation data to retain historical user messages, summarizes only the prefix before the cutoff, and preserves the suffix exactly. Manual and automatic compression now share the same behavior, reducing duplicated logic and making the post-compression context structure more predictable.
Verification
pnpm run fmt:rscargo test -p bitfun-core agentic::session::compression::compressor::tests --libcargo check --workspace