Skip to content

Planner agent gets stuck in infinite loop when planning undefined projects #9445

Closed as not planned

Description

@mannyluvstacos

Bug Description

The Planner agent enters an infinite loop when invoked to plan a project that doesn't have existing specs or documentation in the codebase. The agent was invoked via @planner develop opencode-council-swarm and got stuck, requiring manual abort.

Steps to Reproduce

  1. Start an opencode session
  2. Invoke the planner agent with a project that doesn't exist: @planner develop opencode-council-swarm
  3. Observe the agent spinning indefinitely until manually aborted

Expected Behavior

The planner should:

  1. Search for existing specs/docs (reasonable timeout)
  2. If nothing found, acknowledge this and either:
    • Ask clarifying questions about what the project should be
    • Create a plan based on the project name semantics ("council-swarm" suggests multi-agent coordination)
    • Return a "no context found" response with suggestions

Actual Behavior

The agent enters an infinite loop, likely:

  • Repeatedly searching the same locations
  • Making identical exploration queries
  • No termination condition or max iteration limit

Root Cause Hypothesis

  1. No exploration timeout/limit - The planner's exploration phase has no max iterations
  2. Recursive search pattern - When no results found, it may retry the same search
  3. Missing early-exit condition - No check for "zero context found, ask user"
  4. Model looping - The claude-opus-4.5 model may be generating identical tool calls repeatedly

Proposed Fixes

Short-term

  • Add max iteration limit (e.g., 10 exploration attempts)
  • Add timeout for planning phase (e.g., 60 seconds)
  • Detect repeated identical tool calls and break

Long-term

  • Planner should have explicit "context gathering" phase with bounded scope
  • If no specs/docs found after N attempts, prompt user for requirements
  • Add loop detection at the Task tool level

Environment

  • Agent: planner.md (subagent mode)
  • Model: github-copilot/claude-opus-4.5
  • Temperature: 0.2
  • Invocation: @planner develop opencode-council-swarm

Related Context

The planner agent is configured at ~/.config/opencode/agents/planner.md and is designed to create .ralph-plan-*.md files for autonomous execution by Ralph. The loop appears to occur in the exploration phase before any plan file is created.

Additional Notes

This is a usability issue that wastes user time and API tokens. The agent should fail gracefully rather than loop indefinitely.

Activity

  1. github-actions commented on Jan 19, 2026

    @github-actions
    Contributor

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

    Additionally, this relates to:

    The core issue appears to be missing max iteration limits and loop detection mechanisms in the agent/task execution system.

  2. mannyluvstacos commented on Jan 19, 2026

    @mannyluvstacos
    Author

    please ignore, local agent pushed an issue that was not meant to be pushed

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