Skip to content

Infinite clarification/compaction loop on empty git repo #32615

Closed as not planned

Description

@Cunhov

Summary

OpenCode can enter a clarification/compaction loop on an empty git repository and burn tokens without making progress. This is both a correctness bug and a cost-control bug.

Why this matters

On a directory that contains only .git/, there is no project context to inspect. The expected behavior is a single short clarification prompt and then idle waiting. Instead, OpenCode can keep re-entering the same "I don't have a clear task / What would you like me to help you with?" flow and trigger compaction again.

That behavior is not just noisy. It can consume a large amount of context and API budget while producing no useful output.

Environment

  • OpenCode: 1.17.4 and 1.17.7 observed
  • OS: macOS 26.5 arm64
  • Terminal: Apple_Terminal
  • Project directory: /Users/bestoptionnotebook/Projects/teste
  • Repository state: only .git/ exists, no source files

Reproduction

  1. Create or open a directory that contains only a .git folder.
  2. Start OpenCode in that directory.
  3. Send a minimal prompt such as teste.
  4. Observe OpenCode respond that the directory is empty / no clear task exists.
  5. Observe repeated clarification prompts and compaction attempts instead of a single pause for user input.

Actual behavior

  • Clarification prompts repeat instead of stopping
  • Compaction may fire repeatedly
  • The session can burn a large number of tokens without any progress

Expected behavior

  • One short clarification prompt
  • No compaction loop on an empty repo
  • No repeated re-entry into the same idle state

Notes

I also observed that compaction.auto = false avoids the loop in my local config, which suggests the failure is in the compaction/empty-context path rather than in the model output itself.

Activity

  1. Cunhov commented on Jun 16, 2026

    @Cunhov
    Author

    Local measurements:

    • /Users/bestoptionnotebook/Projects/teste contains only .git/.
    • opencode debug file list . returns only .git/.
    • opencode debug scrap recognizes the repo correctly as worktree=/Users/bestoptionnotebook/Projects/teste.
    • With compaction.auto=false, a minimal prompt completes normally.
    • With the empty repo and compaction enabled, the user-visible behavior is a repeated clarification loop instead of a single idle prompt.

    This looks like a failure in the empty-repo / clarification path and should be guarded so it cannot re-enter compaction without new user input.

  2. github-actions commented on Jun 16, 2026

    @github-actions
    Contributor

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

    If your issue is distinct from these (e.g. specific to an empty git repo triggering the loop rather than general session state), please add a note clarifying what differentiates it.

  3. Cunhov commented on Jun 16, 2026

    @Cunhov
    Author

    Follow-up with local evidence:

    • opencode debug file list . in /Users/bestoptionnotebook/Projects/teste returns only .git/.
    • opencode debug scrap recognizes the repo as worktree=/Users/bestoptionnotebook/Projects/teste with vcs=git.
    • opencode debug config currently resolves compaction.auto=false when set globally.
    • With compaction.auto=false, a minimal prompt completes normally.
    • With compaction enabled via config override on the same empty repo, the user-visible behavior is the repeated clarification / compaction loop described above.

    Relevant local session data:

    • Session on the empty repo with a short prompt and compaction disabled completed normally with only ~7.8k input tokens.
    • Earlier sessions that hit the bad path on the same machine showed ~249k input tokens before aborting / looping.

    Separate note: there is also a model-resolution pitfall if the model is passed without the provider prefix. The working identifier in my environment is opencode/deepseek-v4-flash-free.

  4. github-actions commented on Aug 16, 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