Skip to content

Compaction returns total=0, causing infinite loop with max-steps guard #37871

Closed as not planned

Description

@382960875

Description

Environment
Version: 1.18.3
Model: big-pickle (via opencode provider)
Agent: Sisyphus - Ultraworker → Atlas - Plan Executor
Steps to Reproduce
Configure opencode with a small-context model (e.g., one with ~8K context window)
Ask an agent to work on a task that involves reading several large source files (>10K tokens total, e.g., multiple large Java service/controller files)
Observe the log
What Happens
The agent enters a permanent loop of compaction → refill → compaction:

text
Sisyphus - Ultraworker → reads files, context overflows
→ tail fallback: budget=8000, size=10000+, total=0
→ compaction (returns total=0)
→ Plan Executor → re-reads same files
→ tail fallback again...

In one observed instance:

239 loop iterations over 1+ hour
104 compaction calls
8 tail fallbacks, all with total=0
CPU pegged at 100% on one core, ~900MB memory
Session eventually reached step 157+ with no sign of stopping
Key log evidence
text
tail fallback budget=8000 size=14073 total=0
tail fallback budget=8000 size=10360 total=0
tail fallback budget=8000 size=10152 total=0
tail fallback budget=8000 size=10164 total=0
... (repeated 8 times, every few seconds)

The total=0 after every compaction means the compacted output was empty/useless, so the agent had no choice but to re-read files, re-triggering the overflow.

Expected Behavior
Circuit breaker on compaction failure: If compaction repeatedly returns total=0 (or total < some threshold like budget * 0.1), the agent should stop and report an error to the user instead of retrying indefinitely.

Max-steps guard: There should be a configurable or built-in limit on the total number of loop iterations per session (e.g., 50-100). After that, the session should abort with a clear error message.

Progressive backoff: If compaction fails, the agent could try trimming context more aggressively before compaction, or split into smaller steps with fewer files at a time.

Impact
Resource waste: 1+ hour of 100% CPU, ~900MB memory consumed for zero progress
User confusion: The agent looks like it's "working" but is actually stuck in a loop with no feedback
No recovery possible: Without external intervention (kill the process), the loop never terminates

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Jul 20, 2026

    @github-actions
    Contributor

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

  2. github-actions commented on Sep 20, 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