Skip to content

feat(session): add suffix compaction - #44264

Open
hugojosefson wants to merge 4 commits into
anomalyco:devfrom
hugojosefson:suffix-compaction
Open

hugojosefson wants to merge 4 commits into
anomalyco:devfrom
hugojosefson:suffix-compaction

Conversation

@hugojosefson

@hugojosefson hugojosefson commented Aug 22, 2026

Copy link
Copy Markdown

Note

🤖 Prepared by GPT-6 Astra on behalf of hugojosefson

Issue for this PR

N/A

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds experimental compaction.mode: "suffix" to both session runtimes. Prepend stays the default.

Suffix compaction appends summary instructions to the captured request to keep cached prompt tokens. It blocks tool execution and falls back to prepend when necessary.

Safeguards:

  • Limit reasoning and summary output to 16,384 tokens, subject to model limits.
  • Check context capacity and reject truncated summaries before replacing history.
  • Keep recovery active during fallback, with terminal errors reported only when recovery fails or the user cancels.
  • Preserve earlier task facts without more task work during summarization.

The TUI shows compaction mode, fallback reason, timing, and token usage. A filesystem import cycle correction permits the compiled server to start model requests.

How did you verify your code works?

Validation:

  • 703 tests passed, one skipped. All 30 package typechecks passed.
  • Generated client check, targeted lint, and Linux x64 build passed.
  • Compiled HTTP/SSE check: a blocked summary tool call triggered prepend fallback and automatic continuation without an intervening terminal error or idle event.

Full lint reports an existing octal escape error in packages/session-ui/src/v2/components/prompt-input/index.tsx:163.

Screenshots / recordings

None.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

Related PR:

This PR is related because it also deals with session compaction configuration and behavior, though it focuses on thresholds and continuous compaction prevention rather than the suffix compaction mode itself.

The current PR #44264 (feat(session): add suffix compaction) appears to be the primary implementation of this feature, as it's the only one matching the specific "suffix compaction" functionality.

No duplicate PRs found for the exact suffix compaction feature being implemented in PR #44264.

@Enough1122

Copy link
Copy Markdown

AI code review — automated review for reference, author can ignore or act on any point.

This diff is very large (36 files, +2594/−282), so automated line-by-line review is skipped here — recommending human review for this one.

Keep recoverable suffix errors internal until fallback finishes.
Reserve output space for reasoning and summary text, and reject truncated summaries.
Use measured input tokens when available and count reasoning in overflow checks.
Clarify the summary instructions for previous summaries and planned work.
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