Skip to content

Agent loops 277 times on MCP resource_list without circuit breaker #31942

Description

@dmhliu

Summary

An OpenCode agent made 277 consecutive calls to gumps_mcp_resource_list searching for a non-existent MCP resource, exhausting the workspace token spend limit. No built-in circuit breaker or loop detection prevented this.

Steps to Reproduce

  1. Configure an OpenCode agent with an MCP server (MCP Gateway at https://mcp-dev.gumps.net/mcp)
  2. Ask the agent to find or use an MCP resource/skill that does not exist on that server (e.g., "m365-inbox")
  3. Observe the agent repeatedly calling mcp_resource_list with different filter prefixes

Expected Behavior

After 2–3 consecutive mcp_resource_list calls returning no matching results, the agent should stop searching and report that the resource was not found.

Actual Behavior

The agent called gumps_mcp_resource_list 277 times in a single session, each time with a slightly different filter prefix, all returning empty results. This consumed enough tokens to hit the $500 workspace spend limit, blocking all further agent activity.

The agent did not recognize the pattern of repeated empty results and did not stop.

Acceptance Criteria

  • Agent detects repeated identical-tool calls with empty/no-match results and stops after a configurable threshold (e.g., 3 consecutive misses)
  • Agent reports "resource not found" to the user instead of continuing to search
  • A built-in circuit breaker prevents any single tool from being called more than N times consecutively with the same outcome
  • Regression test added covering repeated empty MCP resource searches

Additional Context

  • Environment: Production (gumps-daily-flash repo, OpenCode runtime)
  • Frequency: Observed once, but the pattern is deterministic — any search for a non-existent resource triggers it
  • Business impact: Hit $500 workspace spend limit, blocked all agent activity until limit reset
  • Evidence: Changelog entry in gumps-daily-flash repo: [2026-06-11 10:00] NOTE Agent looped 277 times calling gumps_mcp_resource_list searching for non-existent "m365-inbox" skills
  • Workaround applied: Created a project-level .cursor/rules/loop-prevention.mdc rule instructing agents to stop after 3 consecutive empty results. This is a belt-and-sunders fix at the project level; the platform should enforce this natively.
  • User-supplied hypothesis (unverified): This is a bug in OpenCode's loop detection — the platform should have a built-in circuit breaker for repeated tool calls.

Filed by AI Agent | Platform: opencode | Repo: newgumps/it-director
Ref: IT-DIR-f81560f4 | 2026-06-11 | Context: Agent spent $500 workspace limit on 277 MCP resource_list calls

Activity

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