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: auto-resume agent loop after context compaction by Mr-Neutr0n · Pull Request #12970 · anomalyco/opencode

Conversation

@Mr-Neutr0n

@Mr-Neutr0n Mr-Neutr0n commented Feb 10, 2026

Copy link
Copy Markdown

Summary

Fixes #12780

After context compaction triggers, the agent sometimes stops and waits for the user to say "continue" instead of automatically resuming. The behavior is inconsistent because it depends on the processor's return value during compaction, which can vary based on response size and model behavior.

Root cause (two issues):

  1. SessionCompaction.process() gated the synthetic "Continue" user message on result === "continue". If the processor returned anything else (e.g. "compact" when the compaction response itself was large enough to trigger overflow detection), the synthetic message was skipped. Without this message, the main loop's exit condition (lastUser.id < lastAssistant.id) would see the compaction assistant as newer than the last user message and break out of the loop, stopping the agent.

  2. The main agent loop exit condition did not exclude compaction summary messages. A compaction assistant message with a non-tool-call finish reason (e.g. "stop", "end_turn") would trigger the exit even though the agent should continue processing after compaction.

Fix:

  • Move the error check (processor.message.error) before the synthetic message creation, and remove the result === "continue" gate. The synthetic "Continue" user message is now always created when auto=true and there is no error.
  • Add !lastAssistant.summary to the loop exit condition so the loop never breaks on a compaction summary message.

Related: #11301, #3053, #6068, #8394

Test plan

  • Trigger context compaction by running a long session that exceeds the model's context window
  • Verify the agent automatically resumes after compaction without requiring user to type "continue"
  • Verify the agent still correctly stops when compaction encounters an error
  • Verify manual compaction (auto: false) still works as before (no synthetic continue message)
  • Existing compaction tests pass

Sorry, something went wrong.

Uh oh!

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

matshch and dezren39 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
Mr-Neutr0n added 2 commits February 10, 2026 18:18
@Mr-Neutr0n
fix: propagate abort signal to prevent TUI freeze during processing
0c4ba11
@Mr-Neutr0n
fix: auto-resume agent loop after context compaction
b9a416b
@github-actions

github-actions Bot commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

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

No duplicate PRs found

All reactions

Sorry, something went wrong.

Uh oh!

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

This was referenced Feb 22, 2026
fix: recover from 413 Request Entity Too Large via auto-compaction #14707
Merged
feat(compaction): preserve original user prompt across compaction #14846
Closed
fix(opencode): handle context overflow error by triggering compaction #15320
Closed
fix(session): prevent infinite loop in auto-compaction when assistant ended its turn #15532
Closed
@Lee-SiHyeon Lee-SiHyeon mentioned this pull request Mar 1, 2026
Auto-compaction infinite loop when assistant ended its turn (finish !== tool-calls) #15533
Closed
@github-actions github-actions Bot mentioned this pull request Mar 5, 2026
fix: improve compaction continuation to prevent agent from stopping #16073
Closed
3 of 6 tasks
@github-actions github-actions Bot mentioned this pull request Mar 16, 2026
fix(provider): treat Anthropic billing_error as context overflow for auto-compaction #17766
Closed
@github-actions github-actions Bot mentioned this pull request Mar 31, 2026
fix(session): re-announce tools after compaction #20289
Closed
3 of 6 tasks
@github-actions

github-actions Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot closed this Apr 12, 2026
@acmerfight acmerfight mentioned this pull request Jul 14, 2026
feat(agent): make task and execution lifecycle explicit across recovery acmerfight/keel#442
Closed
15 of 17 tasks
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

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Agent paused after compaction

Uh oh!

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

1 participant

@Mr-Neutr0n
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.