[PR #6459] fix: detect reserved agent name conflicts in custom agents #11915

Closed
opened 2026-02-16 18:16:51 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6459

State: closed
Merged: No


Summary

  • Detects when users create custom agents (via .opencode/agent/*.md files) with names that conflict with built-in agents
  • Throws a clear Config.InvalidError with a helpful message listing all reserved names
  • Adds test coverage for the new validation

Problem

When a user creates a custom agent with a name like explore.md, it silently conflicts with the built-in explore agent. This can lead to hours of debugging confusing behavior, as the user experienced firsthand.

Solution

Added validation in loadAgent() that checks if the agent name matches any reserved name:

  • build, plan, general, explore, compaction, title, summary

If a conflict is detected, OpenCode now throws a clear error:

"explore" is a reserved agent name. Reserved names: build, plan, general, explore, compaction, title, summary. Choose a different name for your custom agent.

Changes

  • src/config/config.ts: Added RESERVED_AGENT_NAMES constant and validation in loadAgent()
  • test/agent/agent.test.ts: Added test case for reserved name detection
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6459 **State:** closed **Merged:** No --- ## Summary - Detects when users create custom agents (via `.opencode/agent/*.md` files) with names that conflict with built-in agents - Throws a clear `Config.InvalidError` with a helpful message listing all reserved names - Adds test coverage for the new validation ## Problem When a user creates a custom agent with a name like `explore.md`, it silently conflicts with the built-in `explore` agent. This can lead to hours of debugging confusing behavior, as the user experienced firsthand. ## Solution Added validation in `loadAgent()` that checks if the agent name matches any reserved name: - `build`, `plan`, `general`, `explore`, `compaction`, `title`, `summary` If a conflict is detected, OpenCode now throws a clear error: ``` "explore" is a reserved agent name. Reserved names: build, plan, general, explore, compaction, title, summary. Choose a different name for your custom agent. ``` ## Changes - `src/config/config.ts`: Added `RESERVED_AGENT_NAMES` constant and validation in `loadAgent()` - `test/agent/agent.test.ts`: Added test case for reserved name detection
yindo added the pull-request label 2026-02-16 18:16:51 -05:00
yindo closed this issue 2026-02-16 18:16:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11915