Subagents will be loaded from anywhere, not just .opencode/agent #1956

Closed
opened 2026-02-16 17:33:25 -05:00 by yindo · 6 comments
Owner

Originally created by @RuminationScape on GitHub (Oct 4, 2025).

Originally assigned to: @thdxr on GitHub.

If I write "do agent-<subagent_name>", it will look for subagent_name.md from anywhere in project folder and run it, including .claude/agents and regular project folders.

Is this desired behavior?

Originally created by @RuminationScape on GitHub (Oct 4, 2025). Originally assigned to: @thdxr on GitHub. If I write "do agent-<subagent_name>", it will look for subagent_name.md from anywhere in project folder and run it, including .claude/agents and regular project folders. Is this desired behavior?
yindo closed this issue 2026-02-16 17:33:25 -05:00
Author
Owner

@rekram1-node commented on GitHub (Oct 4, 2025):

@RuminationScape "it will look" are you saying that the llm will try to find that agent and try to behave as it? Or what do you mean?

Currently opencode only reads agent definitions from .opencode/agent/ and ~/.config/opencode/agent/. You can manually invoke them via command, switching to an agent with tab (not available for subagent), or if it is a subagent you can invoke using an @ reference

@rekram1-node commented on GitHub (Oct 4, 2025): @RuminationScape "it will look" are you saying that the llm will try to find that agent and try to behave as it? Or what do you mean? Currently opencode only reads agent definitions from `.opencode/agent/` and `~/.config/opencode/agent/`. You can manually invoke them via command, switching to an agent with tab (not available for subagent), or if it is a subagent you can invoke using an @ reference
Author
Owner

@RuminationScape commented on GitHub (Oct 4, 2025):

If .opencode/agent/ is empty, and have the following situations:

  1. have only .claude/agents/agent1.md --> invoke in shell "do agent-agent1", it will execute this agent.
  2. if have only random_folder/agent2.md --> invoke in shell "do agent-agent2", it will execute this agent.

I reloaded VSCode window, quit opencode in terminal, restart opencode when I tested etc. I also looked in the opencode shell TUI and it showed that it was reading these locations.

The subagent behavior is a little wonky (regarding parsing of file paths and effects of invocation using @agent_name).

@RuminationScape commented on GitHub (Oct 4, 2025): If .opencode/agent/ is empty, and have the following situations: 1. have only .claude/agents/agent1.md --> invoke in shell "do agent-agent1", it will execute this agent. 2. if have only random_folder/agent2.md --> invoke in shell "do agent-agent2", it will execute this agent. I reloaded VSCode window, quit opencode in terminal, restart opencode when I tested etc. I also looked in the opencode shell TUI and it showed that it was reading these locations. The subagent behavior is a little wonky (regarding parsing of file paths and effects of invocation using @agent_name).
Author
Owner

@rekram1-node commented on GitHub (Oct 4, 2025):

@RuminationScape I still don't understand here what do these things mean?

have only .claude/agents/agent1.md --> invoke in shell "do agent-agent1", it will execute this agent.
if have only random_folder/agent2.md --> invoke in shell "do agent-agent2", it will execute this agent.

When you say invoke in shell are you talking about in the tui? also what is this "do agent" syntax? I am not really sure I follow is this how you prompt to tell the agent to call subagents?

@rekram1-node commented on GitHub (Oct 4, 2025): @RuminationScape I still don't understand here what do these things mean? > have only .claude/agents/agent1.md --> invoke in shell "do agent-agent1", it will execute this agent. if have only random_folder/agent2.md --> invoke in shell "do agent-agent2", it will execute this agent. When you say invoke in shell are you talking about in the tui? also what is this "do agent" syntax? I am not really sure I follow is this how you prompt to tell the agent to call subagents?
Author
Owner

@RuminationScape commented on GitHub (Oct 4, 2025):

In the subagent file, one can enable subagent to call another subagent using the following:

tools:
  task: true

Suppose I have 3 subagents.

  • agent1.md invokes agent3.md, but does NOT have "task: true".
  • agent2.md invokes agent3.md, but does have "task: true".

What I found:

  • using @agent1 in TUI will fail. Most likely because agent1 is trying to invoke agent3, but it is not allowed to call another task.
  • using do agent-agent1 in TUI will work. I got this idea from one of the pages on Claude Code website.
  • using @agent2 in TUI will work. This is the normal way of invoking a subagent. The setting of "task: true" enables it to call agent2.

I just started playing around with subagents today and tried to work out consistent workflow. This is how it seems to work in Linux.

The TUI is terminal within VSCode.

@RuminationScape commented on GitHub (Oct 4, 2025): In the subagent file, one can enable subagent to call another subagent using the following: ``` tools: task: true ``` Suppose I have 3 subagents. - agent1.md invokes agent3.md, but does NOT have "task: true". - agent2.md invokes agent3.md, but does have "task: true". What I found: - using `@agent1` in TUI will fail. Most likely because agent1 is trying to invoke agent3, but it is not allowed to call another task. - using `do agent-agent1` in TUI will work. I got this idea from one of the pages on Claude Code website. - using `@agent2` in TUI will work. This is the normal way of invoking a subagent. The setting of "task: true" enables it to call agent2. I just started playing around with subagents today and tried to work out consistent workflow. This is how it seems to work in Linux. The TUI is terminal within VSCode.
Author
Owner

@RuminationScape commented on GitHub (Oct 4, 2025):

I guess what's going on is:

The syntax "@some_agent" is specific to Opencode. This will go through opencode's system of checking "task: true".

The syntax "do agent-some_agent" is an LLM call (ie. it's not going through opencode mechanism). This will (1) bypass check for "task: true" and (2) evaluate the contents of the file wherever it exists. The question is whether the LLM can trigger a subagent call with a new context window, etc.

I haven't seen this documented anywhere yet.

@RuminationScape commented on GitHub (Oct 4, 2025): I guess what's going on is: The syntax "@some_agent" is specific to Opencode. This will go through opencode's system of checking "task: true". The syntax "do agent-some_agent" is an LLM call (ie. it's not going through opencode mechanism). This will (1) bypass check for "task: true" and (2) evaluate the contents of the file wherever it exists. The question is whether the LLM can trigger a subagent call with a new context window, etc. I haven't seen this documented anywhere yet.
Author
Owner

@rekram1-node commented on GitHub (Oct 5, 2025):

The syntax "do agent-some_agent" is an LLM call (ie. it's not going through opencode mechanism). This will (1) bypass check for "task: true" and (2) evaluate the contents of the file wherever it exists. The question is whether the LLM can trigger a subagent call with a new context window, etc.
I haven't seen this documented anywhere yet.

We don't have documentation on do agent-some_agent, IM not really familiar with this, opencode allows you to invoke agents with the "@some_agent" or you could just say: "use <some_agent> to do <some task" and it generally works.

I don't think there is anything unexpected here tbh maybe a misunderstanding of opencode agents?

Sounds like opencode is behaving as expected

@rekram1-node commented on GitHub (Oct 5, 2025): > The syntax "do agent-some_agent" is an LLM call (ie. it's not going through opencode mechanism). This will (1) bypass check for "task: true" and (2) evaluate the contents of the file wherever it exists. The question is whether the LLM can trigger a subagent call with a new context window, etc. I haven't seen this documented anywhere yet. We don't have documentation on do agent-some_agent, IM not really familiar with this, opencode allows you to invoke agents with the "@some_agent" or you could just say: "use <some_agent> to do <some task" and it generally works. I don't think there is anything unexpected here tbh maybe a misunderstanding of opencode agents? Sounds like opencode is behaving as expected
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1956