Skip to content

fix(core): guard non-reducing compaction - #34261

Closed
cwj2001 wants to merge 1 commit into
anomalyco:devfrom
cwj2001:compaction-budget
Closed

fix(core): guard non-reducing compaction#34261
cwj2001 wants to merge 1 commit into
anomalyco:devfrom
cwj2001:compaction-budget

Conversation

@cwj2001

@cwj2001 cwj2001 commented Jun 27, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #27924

Type of change

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

What does this PR do?

Stops overflow recovery when compaction does not make progress.

After the recovery summary is added, the runner re-estimates the request. It only retries the provider if the compacted request is smaller than the original request and within the model context budget. Otherwise it persists the original overflow error and exits instead of retrying into another overflow cycle.

How did you verify your code works?

From packages/core:

  • bun test test/session-runner.test.ts --test-name-pattern "overflow"
  • bun typecheck

Screenshots / recordings

Not a UI change.

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 a potentially related PR:

Related PR:

The other PRs found (#33667, #18941) are related to overflow and compaction in general but appear to address different aspects of the issue.

@cwj2001

cwj2001 commented Jun 27, 2026

Copy link
Copy Markdown
Author

#34029 and this PR cover different failure modes.

#34029 handles aborts/errors while generating the overflow recovery summary.

This PR handles the case where recovery summary generation succeeds, but the rebuilt request is still over budget or is not smaller than the original request. In that case we persist the original overflow error instead of retrying into another overflow cycle.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(session): infinite compaction loop when compression fails to reduce context

2 participants