GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(session): stop auto-compacting after 3 consecutive attempts that don't shrink the request by OracleCLM · Pull Request #48188 · anomalyco/opencode

Conversation

@OracleCLM

@OracleCLM OracleCLM commented Sep 9, 2026

Copy link
Copy Markdown

Body

Compaction can only reduce the conversation. When what exceeds the
provider's context window is the fixed overhead — system prompt plus tool
definitions — every compaction genuinely succeeds (the request really is
smaller) and the very next turn overflows again. isOverflow() keeps evaluating
true, compaction.create() keeps firing, and the loop never terminates.

Observed live: Build -> "Task completed" -> Compaction -> Build -> "Task completed" -> Compaction …, cycling five or more times in about forty-five
seconds, never producing a visible answer.

The failure mode is worse than a visible hang. Once the queue of oversized
replies runs out in a test — or the provider's behaviour shifts slightly in
production — the loop ends on an ordinary small response and finishes with a
benign stop and no error at all. The session quietly stops doing what it
was asked instead of saying why it cannot.

The change

A per-run counter of consecutive compactions, capped at 3, on both triggers (the
preventive isOverflow check and the reactive mid-stream result === "compact"
path). When the cap is exceeded, the assistant message carries a
ContextOverflowError naming the actual constraint — the system prompt or the
tool set — and the loop stops.

The counter resets when a finished turn no longer overflows, which is the
precise meaning of "compaction did its job". Resetting on any completed turn
would defeat the cap in exactly the case it exists for, where every turn
succeeds and every turn is still too large.

Test

loop gives up after repeated auto-compaction instead of looping forever seeds
an already-finished oversized reply so the loop's first decision comes from the
preventive check, then queues more oversized turns than the cap allows — so what
is measured is how many the loop tries, not whether the queue runs out.

Verified in both directions: against the current code the test fails with
Expected: "ContextOverflowError" / Received: undefined — the benign silent
ending described above.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@OracleCLM
fix(session): stop auto-compacting after 3 consecutive attempts that …
223586c
…don't shrink the request

Compaction can only reduce the conversation. When what exceeds the provider's
context window is the fixed overhead — system prompt plus tool definitions —
every compaction genuinely succeeds (the request really is smaller) and the very
next turn overflows again. isOverflow() keeps evaluating true, compaction.create()
keeps firing, and the loop never terminates.

Observed live: Build -> "Task completed" -> Compaction -> Build -> ... cycling
five or more times in about forty-five seconds, never producing an answer.

The failure mode is worse than a visible hang: as soon as the sequence of
oversized replies ends, the loop finishes on an ordinary response with a benign
"stop" and no error at all. The session quietly stops doing what it was asked
instead of saying why it cannot.

Adds a per-run counter of consecutive compactions, capped at 3, on both triggers
(the preventive isOverflow check and the reactive mid-stream "compact" path).
When the cap is exceeded the assistant message carries a ContextOverflowError
naming the real constraint, and the loop stops.

The counter resets when a finished turn no longer overflows — the precise meaning
of "compaction did its job". Resetting on any completed turn would defeat the cap
in exactly the case it exists for, where every turn succeeds and every turn is
still too large.

The test seeds an already-finished oversized reply so the first decision comes
from the preventive check, and queues more oversized turns than the cap allows,
so it measures how many the loop tries rather than when the queue runs out.
Against the current code it fails with Expected "ContextOverflowError", received
undefined.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

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

Found one potentially related PR:

PR #10123: feat(session): add custom compaction thresholds along with prevention of continuous compaction
#10123

This PR appears related as it also addresses continuous/repeated compaction prevention in sessions. It may have explored similar solutions or approaches to preventing infinite compaction loops, though it focuses on thresholds rather than a 3-attempt cap with error handling.

The other results (PR #48188 is the current PR, #42424 is about model fallback which is unrelated).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the needs:issue label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 9, 2026
@github-actions github-actions Bot closed this Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

needs:issue

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@OracleCLM
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.