Skip to content

Infinite Build ↔ Compaction loop after task completion #31111

Closed as not planned

Description

@bloodyshaad

Description

Summary

OpenCode enters an infinite Build ↔ Compaction cycle after a task completes.

The task is successfully completed, but after compaction the agent automatically re-enters Build mode with the same goal instead of returning control to the user.

This happens with both simple and large tasks and causes repeated processing, repeated file reads, and unnecessary token/credit consumption.

Expected Behavior

  1. User submits a task.
  2. Agent completes the task.
  3. Compaction runs if needed.
  4. Session is marked complete.
  5. Control returns to the user.

Actual Behavior

  1. User submits a task.
  2. Agent completes the task.
  3. Compaction runs.
  4. Build mode automatically starts again.
  5. The same goal is processed again.
  6. Compaction runs again.
  7. The cycle repeats indefinitely.

Example

Prompt:

Create a file called hello.txt containing "Hello World".

Observed:

  • Build creates hello.txt successfully.
  • Compaction reports that all tasks are complete.
  • Build starts again with the exact same goal.
  • Compaction runs again.
  • Loop continues.

Larger Tasks

For larger projects (e.g. operating system development):

  • Agent reads the project directory.
  • Produces an analysis/report.
  • Compaction occurs.
  • Agent reads the same files/directories again.
  • Produces nearly identical analysis.
  • Compaction occurs again.
  • Repeats indefinitely.

The agent never progresses beyond the planning/analysis phase.

Additional Symptoms

  • Repeated reads of the same files after compaction.
  • New prompts sometimes continue the previous task instead of processing the new request.
  • Occurs in both CLI and Windows GUI Beta.
  • Observed across multiple models.
  • Consumes credits/tokens while making no progress.

Possible Cause

Compaction appears to preserve the task goal but does not correctly preserve or clear task completion state.

The compaction summary correctly reports:

  • Task completed
  • No remaining steps

However Build mode is immediately restarted with the same completed goal.

Plugins

No response

OpenCode version

1.16.0

Steps to reproduce

  1. Open OpenCode 1.16.0
  2. Start a new session
  3. Run: "Create a file called hello.txt containing Hello World"
  4. Wait for the file to be created
  5. Observe Compaction running
  6. Observe Build mode automatically restarting with the same completed task
  7. Repeat cycle indefinitely

Also reproducible with larger tasks where the agent repeatedly re-reads the same project files after compaction.

Screenshot and/or share link

No response

Operating System

Windows 10

Terminal

Windows Terminal (Powershell)

Activity

  1. github-actions commented on Jun 6, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Please review these issues to see if your report is already tracked. If one of the above covers your case, consider adding a comment there with your specific reproduction details rather than opening a new issue.

  2. github-actions commented on Aug 6, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions