Bug: custom agents behave like a subagent when mode is empty in the agent/*.md file. #1351

Closed
opened 2026-02-16 17:30:34 -05:00 by yindo · 2 comments
Owner

Originally created by @kennyfrc on GitHub (Aug 17, 2025).

Originally assigned to: @thdxr on GitHub.

As discussed in this discord thread: link

Bug Description
When an agent is defined via ~/.config/open-code/agent/$(agent_name).md, if the mode is empty, then this agent is selectable as an agent but can be invoked like a subagent through prompting with no tagging.

Expected behavior
I expected this to behave like an agent similar to plan and build mode, which cannot be invoked through a prompt or a tag.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new agent file like ~/.config/open-code/agent/$(agent_name).md but with no mode. Here's mine
---
description: Senior software engineer
model: openai/gpt-5
temperature: 0
reasoningEffort: high
textVerbosity: low
reasoningSummary: auto
---

... some prompt
  1. Fire up opencode, then ask it something during build mode like "Please use the analysis agent to understand this codebase"
  2. Opencode should delegate the task and it will label it as "@analysis subagent" (but it's not a subagent)
  3. When I set mode: primary, I observe correct behavior.

Repo / version used

  • I used a light fork which contains a pending PR but it should not affect agent mode configuration.

Edit: here are some screenshots

Initial Prompt with Delegation:
Image

Created task (it's labeled as subagent)
Image

Originally created by @kennyfrc on GitHub (Aug 17, 2025). Originally assigned to: @thdxr on GitHub. As discussed in this discord thread: [link](https://discord.com/channels/1391832426048651334/1391832428024430645/1406663514873004032) **Bug Description** When an agent is defined via `~/.config/open-code/agent/$(agent_name).md`, if the `mode` is empty, then this agent is selectable as an agent but can be invoked like a subagent through prompting with no tagging. **Expected behavior** I expected this to behave like an agent similar to plan and build mode, which cannot be invoked through a prompt or a tag. **To Reproduce** Steps to reproduce the behavior: 1. Create a new agent file like `~/.config/open-code/agent/$(agent_name).md` but with no mode. Here's mine ```agent/analysis.md --- description: Senior software engineer model: openai/gpt-5 temperature: 0 reasoningEffort: high textVerbosity: low reasoningSummary: auto --- ... some prompt ``` 3. Fire up `opencode`, then ask it something during build mode like "Please use the analysis agent to understand this codebase" 4. Opencode should delegate the task and it will label it as "@analysis subagent" (but it's not a subagent) 5. When I set `mode: primary`, I observe correct behavior. **Repo / version used** - I used a [light fork](https://github.com/kennyfrc/opencode/commit/36717c9cc9c0ad01def447e61a56cef3994ca69e) which contains a pending PR but it should not affect agent mode configuration. Edit: here are some screenshots Initial Prompt with Delegation: <img width="826" height="233" alt="Image" src="https://github.com/user-attachments/assets/0cb67018-a005-497d-a7c4-999475eece68" /> Created task (it's labeled as subagent) <img width="840" height="236" alt="Image" src="https://github.com/user-attachments/assets/fd7d980f-899b-4255-8040-30e832d7f6f1" />
yindo closed this issue 2026-02-16 17:30:34 -05:00
Author
Owner

@Javierg9n4 commented on GitHub (Aug 18, 2025):

I might be misunderstanding the issue but:

if you want a primary agent, it works by adding the mode prop as "primary"

If you want a subagent, it works by adding the mode prop as "subagent"

When no mode is specified there must be some fallback, in this case it appears to be "subagent" mode.

I fail to see the issue there.

@Javierg9n4 commented on GitHub (Aug 18, 2025): I might be misunderstanding the issue but: if you want a primary agent, it works by adding the mode prop as "primary" If you want a subagent, it works by adding the mode prop as "subagent" When no mode is specified there must be some fallback, in this case it appears to be "subagent" mode. I fail to see the issue there.
Author
Owner

@rekram1-node commented on GitHub (Aug 18, 2025):

yeah @Javierg9n4 is correct, reading this more this is expected behavior:

  • mode empty: defaults to "all" -> agent is primary & subagent
  • mode primary: agent can only behave like plan & build
  • mode subagent: agent is only subagent
@rekram1-node commented on GitHub (Aug 18, 2025): yeah @Javierg9n4 is correct, reading this more this is expected behavior: - mode empty: defaults to "all" -> agent is primary & subagent - mode primary: agent can only behave like plan & build - mode subagent: agent is only subagent
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1351