Skip to content

fix(llmloop): charge frozen zone in compression budget and keep latest round - #1473

Closed
Hiro-hunter-dev-job wants to merge 1 commit into
alibaba:mainfrom
Hiro-hunter-dev-job:fix/compression-frozen-zone
Closed

Hiro-hunter-dev-job wants to merge 1 commit into
alibaba:mainfrom
Hiro-hunter-dev-job:fix/compression-frozen-zone

Conversation

@Hiro-hunter-dev-job

Copy link
Copy Markdown

Description

partitionMessages sized the kept recent rounds as 80% of max_tokens without charging the always-kept head (system + first user prompt, which holds the group's diffs and earlier summaries):

  • compression kept too many rounds, the result still exceeded the limit, and the loop stopped with StopCompression although compressing more would have fit;
  • when every round fit that budget, every round was summarized, including the tool call and result the model had just requested.

The head's tokens are now subtracted from the budget. The most recent round is protected when it fits next to the head; if it does not fit, it is summarized as before and the review continues. TestScanAgent_WaitBackground_NoLeakOnRun relied on summarizing the only, just-executed round; its mock now produces an older round for the async job to compress.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

How Has This Been Tested?

  • New regression test(s) fail on main and pass with this change (verified both ways).
  • make check passes; full unit suite passes on Windows 11 (Go 1.27) and in a golang:1.26.5 Linux container replaying the CI job (go test -race, coverage >= 90%).

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA
  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

AI disclosure: found and fixed with Claude Code (model: Claude Opus 5) during an audit where every finding had to be proven by a failing test.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

@Hiro-hunter-dev-job
Hiro-hunter-dev-job force-pushed the fix/compression-frozen-zone branch from eaea268 to fee403f Compare September 20, 2026 11:46
@Hiro-hunter-dev-job
Hiro-hunter-dev-job marked this pull request as ready for review September 20, 2026 18:00
@Hiro-hunter-dev-job

Copy link
Copy Markdown
Author

Closing this one. It came out of an audit I ran on the project, and I am not able to see it through review the way CONTRIBUTING asks — answering maintainer questions myself, without AI. Rather than leave it unanswered, I would rather close it.

The work is not lost if it is useful to you: the branch stays on my fork at https://github.com/Hiro-Mati/open-code-review/tree/fix/compression-frozen-zone, with the regression test that fails without the fix. Feel free to take it over or reuse it under the project's license; no attribution needed.

Sorry for the volume, and thanks for your time.

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