Skip to content

fix(session): drop oldest turns when compaction head exceeds model context - #51121

Open
stweil wants to merge 1 commit into
anomalyco:devfrom
stweil:compact-oversized-heads
Open

stweil wants to merge 1 commit into
anomalyco:devfrom
stweil:compact-oversized-heads

Conversation

@stweil

@stweil stweil commented Sep 24, 2026 •

Copy link
Copy Markdown

When the serialized conversation head no longer fits the model's usable context, compaction gave up with "Session too large to compact" and the session became unusable. Shrink the head from the oldest complete turns instead so the summarizer request fits the model context.

Assisted-by: OpenCode / qwen3.8-27b-thinking (Alibaba Cloud)

Issue for this PR

Fixes #29857, #48844 and maybe some more

Type of change

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

What does this PR do?

When the serialized conversation head no longer fits the model's usable context, compaction gave up with "Session too large to compact" and the session became unusable. Shrink the head from the oldest complete turns instead so the summarizer request fits the model context.

How did you verify your code works?

Tested in local work.

Screenshots / recordings

No UI change.

Checklist

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

@github-actions github-actions Bot added needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Sep 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@stweil

stweil commented Sep 24, 2026

Copy link
Copy Markdown
Author

Until this PR (or some other fix) is merged, a simple workaround can help: select a different model which has a larger context window than the current one. Then compression will work. After the successful compression, the original model can be used again to continue the work.

…ntext

When the serialized conversation head no longer fits the model's usable
context, compaction gave up with "Session too large to compact" and the
session became unusable. Shrink the head from the oldest complete turns
instead so the summarizer request fits the model context.

Assisted-by: OpenCode / qwen3.8-27b-thinking (Alibaba Cloud)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
@stweil
stweil force-pushed the compact-oversized-heads branch from 9102cbc to 36a9384 Compare September 25, 2026 07:17

This branch has not been deployed

No deployments
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.

[BUG]: /compact can exceed model context before summarization on large sessions

1 participant