Skip to content

Agent has no effective no-progress/loop detection during repeated file investigation #43603

Closed as not planned

Description

@Adeldes

Description

What happened?

OpenCode can enter an effectively infinite tool-call loop when the agent encounters a missing file/path or cannot resolve an implementation detail.

Instead of stopping, asking for clarification, or reporting that the required information is unavailable, the agent repeatedly issues the same investigation intent without producing a new tool call or new information.

Example:

The agent attempted to locate a catalog API client file that did not exist at the requested path:

src/lib/api/catalog.ts

The tool returned:

Cannot find path ... src\lib\api\catalog.ts because it does not exist

After that, the agent repeatedly generated messages such as:

  • "Let me find the catalog api client."
  • "Let me search for it."
  • "Let me locate the catalog api client."
  • "Let me read PlanCatalogPage.tsx."
  • "Let me search once."
  • "Let me grep."
  • "Let me search for the relevant wiring."

This continued for a very large number of iterations without making meaningful progress.

The same behavior also occurred when the agent was trying to verify unresolved implementation details. It repeatedly announced that it would perform the same read/search operation instead of stopping when the required information could not be obtained.

This is especially problematic for autonomous coding workflows because:

  • it wastes a large number of tool calls/tokens
  • it can consume the entire execution budget
  • it delays the actual task indefinitely
  • there is no effective loop-breaker when the investigation produces no new information
  • the user receives no useful failure state or request for clarification

Expected behavior

When the same investigation attempt fails repeatedly, or when consecutive tool calls produce no new information, the agent should detect the loop and stop.

It should instead report something like:

"I cannot locate the requested file/path. I have already attempted the available search paths and received no new information. Please provide the correct path or clarify where the implementation is located."

A bounded retry policy or no-progress detection would be sufficient.

For example:

  • retry a missing-path search a limited number of times
  • detect repeated identical tool intents/results
  • stop after N consecutive no-progress iterations
  • ask the user for clarification when the required information cannot be resolved

The important point is that the agent should not continue generating "Let me search/read/find..." messages indefinitely without an actual new tool action or new information.

Plugins

No response

OpenCode version

1.18.18

Steps to reproduce

  1. Start an OpenCode coding session in a project.
  2. Give the agent a task that requires investigating a specific implementation or file.
  3. Make the referenced file/path incorrect, missing, renamed, or otherwise unavailable.
  4. Allow the agent to investigate using its normal search/read tools.
  5. Observe the agent after the tool reports that the file/path does not exist.
  6. The agent repeatedly generates investigation messages such as "Let me search", "Let me read", "Let me find it", etc., without making meaningful progress or stopping.
  7. The loop can continue for a very large number of iterations and consume the execution budget.

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

PowerShell

Activity

  1. github-actions commented on Aug 20, 2026

    @github-actions
    Contributor

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

    If your issue is distinct (e.g. specific to file-investigation tool intents rather than MCP or stream errors), feel free to clarify and a maintainer will triage accordingly.

  2. Adeldes commented on Aug 23, 2026

    @Adeldes
    Author

    I can confirm this behavior reproduced in a real OpenCode session after filing this issue.

    I analyzed the exported session in detail, and the failure mode is broader than the original missing-file example.

    Affected session:

    • OpenCode: 1.18.3
    • Model: deepseek-v4-flash via opencode-go
    • Session: ses_07a43c0c7ffeSWAifUdGDTYopv
    • Recorded session cost: $38.18
    • Total tool events: 17,570

    During the affected period (Aug 17–18), the agent repeatedly regenerated the same investigation intent and continued the execution cycle without meaningful progress.

    For example, the reasoning stream contains large repeated sequences of:

    • Let me read...
    • Let me read the file.
    • Let me read it.
    • Let me search...
    • Let me grep...
    • Let me apply the fix...

    In one analyzed window on Aug 18 (02:00–03:20 UTC+3), there were 108 tool events, with extensive repeated investigation/reasoning around the same targets.

    This appears to be a no-progress/circuit-breaker failure: the agent does not reliably recognize that repeated investigation is no longer producing new information, and it continues consuming execution budget instead of stopping or asking for clarification.

    I believe this is related to the core issue described here, but it is broader than a single missing-path retry and is not limited to an MCP or transport retry loop.

    I have also opened a support request regarding the abnormal usage/cost from this session. I can provide the full session export and extracted analysis if useful.

  3. agentgoblin commented on Aug 27, 2026

    @agentgoblin

    How about doom_loop permission? #45442 (comment)

  4. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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