Skip to content

[Bug]: Plugin/user agents not injected into Sisyphus system prompt (customAgentSummaries type mismatch) #2386

@cuipengfei

Description

@cuipengfei

Note: This issue was raised by the Sisyphus agent itself, based on code-level investigation during a deep-dive session into the OMO agent system.

Bug Description

Plugin agents (59 agents from 18 namespaces) and user-installed agents (~/.claude/agents/*.md) are not injected into the Sisyphus primary agent's system prompt. This is caused by a type mismatch in createBuiltinAgents() where the customAgentSummaries parameter receives an OpenCode client object instead of the expected agent summary array.

As a result, Sisyphus has zero awareness of any plugin or user agents at runtime. The only way to discover available agents is by intentionally triggering a resolver error to get the full agent list back in the error message.

Steps to Reproduce

  1. Install oh-my-opencode with any plugin agents registered (e.g., pr-review-toolkit, error-diagnostics, etc.)
  2. Start a session with the Sisyphus agent
  3. Ask Sisyphus to list available agents or delegate to a plugin agent by name
  4. Observe that Sisyphus has no knowledge of plugin/user agents in its system prompt

Alternatively, trace the code path:

  1. In src/agents/dynamic-agent-prompt-builder.ts, the createBuiltinAgents() function accepts customAgentSummaries as the 8th parameter
  2. In src/agents/custom-agent-summaries.ts, parseRegisteredAgentSummaries() checks Array.isArray(input)
  3. The actual value passed is params.ctx.client (an OpenCode SDK client object)
  4. Array.isArray(client) returns false → function returns [] → no agent summaries injected

Expected Behavior

All registered agents (builtin + plugin + user) should be summarized and injected into Sisyphus's system prompt, so it can intelligently route task() calls to the correct agent by name without trial-and-error.

Actual Behavior

parseRegisteredAgentSummaries() receives an OpenCode client object (not an array), silently returns an empty array, and no plugin/user agent information reaches the system prompt. There is no warning log for this silent failure.

Doctor Output

 oMoMoMoMo Doctor

 ⚠ 2 issues found:

1. Model override uses unavailable provider
   Provider(s) not found in OpenCode model cache: 4141, 4142
   Affects: model resolution

2. Comment checker unavailable
   Comment checker binary is not installed.
   Fix: Install @code-yeongyu/comment-checker
   Affects: comment-checker hook

Code Path Analysis

1. Agent Registration (works correctly)

agent-config-handler.ts merges agents from all sources:

  • OMO builtin agents (10)
  • User agents from ~/.claude/agents/*.md
  • Project agents
  • Plugin agents (59 from 18 plugin namespaces)

All 72+ agents are successfully registered in OpenCode's agent registry and are callable via task(subagent_type="agent-name").

2. System Prompt Injection (broken)

The createBuiltinAgents() function in dynamic-agent-prompt-builder.ts accepts a customAgentSummaries parameter (8th argument). This is intended to inject a summary of all available agents into the Sisyphus system prompt.

However, the caller passes params.ctx.client (the OpenCode SDK client object) instead of an array of agent summaries.

In custom-agent-summaries.ts:

export function parseRegisteredAgentSummaries(input: unknown): AgentSummary[] {
  if (!Array.isArray(input)) return []  // <-- client object hits this, returns []
  // ... parsing logic never reached
}

3. Impact on Agent Routing

Since Sisyphus has no agent summaries in its prompt:

  • It cannot discover plugin agents by name
  • task(subagent_type="some-plugin-agent") only works if the caller already knows the exact agent name
  • The only discovery mechanism is triggering the resolver error, which dumps the full agent list in the error message

Secondary Finding: Model Routing for Plugin Agents

During this investigation, we also confirmed that plugin agents inherit their model from OpenCode's MRU (Most Recently Used) list in ~/.local/state/opencode/model.json, not from any explicit configuration. This is because:

  1. OMO's agent-loader.ts does not parse the model field from agent frontmatter (AgentFrontmatter type has no model property)
  2. The subagent-resolver.ts model resolution chain: AGENT_MODEL_REQUIREMENTS[key] (builtin only) → agentOverride?.model (none) → matchedAgent.model (none) → categoryModel (undefined)
  3. When model is undefined, OpenCode falls back to Provider.defaultModel() → reads model.json MRU

This means plugin agents get whatever model the user last manually selected in the TUI, which may not be appropriate.

Configuration

Using default oh-my-opencode configuration with custom providers (4141, 4142) proxied through copilot-api.

Additional Context

  • This issue was discovered through a systematic code-level audit of the entire OMO agent system pipeline: registration → injection → resolution → model routing
  • The bug is a silent failure with no error logs or warnings, making it very difficult to notice
  • All 72+ registered agents work correctly when called by exact name; only the discovery/awareness mechanism is broken
  • Tested with 7 different plugin agents (code-simplifier, mermaid-expert, error-detective, c4-context, haskell-pro, typescript-pro, legacy-modernizer) — all executed successfully when called by name

Operating System

Linux (WSL2)

OpenCode Version

1.2.21

oh-my-opencode Version

3.11.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions