Repository navigation
Description
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
- User submits a task.
- Agent completes the task.
- Compaction runs if needed.
- Session is marked complete.
- Control returns to the user.
Actual Behavior
- User submits a task.
- Agent completes the task.
- Compaction runs.
- Build mode automatically starts again.
- The same goal is processed again.
- Compaction runs again.
- 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
- Open OpenCode 1.16.0
- Start a new session
- Run: "Create a file called hello.txt containing Hello World"
- Wait for the file to be created
- Observe Compaction running
- Observe Build mode automatically restarting with the same completed task
- 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
github-actions commentedon Jun 6, 2026
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.
github-actions commentedon Aug 6, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.