Skip to content

[compound-engineering] Bug: repo-research-analyst prompt can self-recurse when used as a direct runnable subagent #492

@ChushulSuri

Description

@ChushulSuri

Bug Description

Component: Agent - repo-research-analyst
Summary: The agent prompt appears to include self-invocation examples that can trigger recursive self-delegation when the agent file is used directly as a runnable subagent in OpenCode.

Environment

  • Plugin Version: 2.28.0
  • Agent Platform: OpenCode
  • Agent Version: 1.3.13
  • OS: Darwin 25.3.0 x86_64

What Happened

When repo-research-analyst was invoked in an OpenCode-based integration, it repeatedly appeared to call itself instead of doing the research work directly. In practice this looked like repo-research-analyst running in a loop, with the same agent being invoked again and again, causing major latency and non-completion.

While debugging, I found that the agent prompt contains self-referential orchestrator examples such as:

  • I'll use the repo-research-analyst agent ...
  • use the repo-research-analyst agent ...

These examples are harmless if the file is only used as guidance for an orchestrator, but they become risky when the same file is used as the direct prompt for the runnable subagent itself.

Expected Behavior

The agent should perform repository research directly when invoked, without attempting to invoke another copy of itself.

Ideally the agent prompt would be safe across runtimes that may use the file directly as the subagent prompt.

Steps to Reproduce

  1. Use Compound Engineering agent content in an OpenCode-style integration where agent markdown is installed as runnable subagents.
  2. Invoke repo-research-analyst for broad repository research.
  3. Observe that the agent can repeatedly re-invoke itself instead of executing the task directly.

Error Messages

No explicit CLI error was shown. The main symptom was recursive self-delegation / looping behavior and severe slowness.

Additional Context

In my local compatibility layer, I mitigated this by:

  • removing top-level self-invocation example blocks from generated agent prompts
  • adding an explicit guard:
    • You are already acting as this subagent. Do the work directly. Never invoke yourself or another copy of this same agent.

This suggests the issue may be a prompt portability problem rather than an OpenCode-specific runtime bug.


Reported via /report-bug-ce skill

Metadata

Metadata

Assignees

No one assigned

    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