Skip to content

feat(agent): restructure context compression handoff - #1903

Merged
wsp1911 merged 1 commit into
GCWing:mainfrom
wsp1911:dev2
Jul 30, 2026
Merged

feat(agent): restructure context compression handoff#1903
wsp1911 merged 1 commit into
GCWing:mainfrom
wsp1911:dev2

Conversation

@wsp1911

@wsp1911 wsp1911 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Unify manual and automatic context compression through a shared planning path.
  • Retain historical user messages within min(20k, context_window * 10%).
  • Preserve an exact recent-context suffix selected by a strict token budget.
  • Assemble compressed context as retained user messages, summary, recent context, and a continuation reminder.
  • Refine the compaction prompt to produce concise handoff summaries without duplicating reloadable content.
  • Keep assistant tool calls and their tool results atomic across the compression cutoff.

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:rs
    • Completed successfully.
  • cargo test -p bitfun-core agentic::session::compression::compressor::tests --lib
    • 14 tests passed.
  • cargo check --workspace

- 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
@wsp1911
wsp1911 merged commit c1d0066 into GCWing:main Jul 30, 2026
7 checks passed
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