Separate instructions for the “main” agent vs. sub-agents #1142

Closed
opened 2026-02-16 17:29:36 -05:00 by yindo · 5 comments
Owner

Originally created by @jessevdp on GitHub (Aug 7, 2025).

Originally assigned to: @thdxr on GitHub.

Currently, you can give custom instructions to opencode via the AGENTs.md file (or by specifying other instructions paths).

If I understand correctly, these instructions are passed to every new session. And since sub-agents are really just “invisible sessions” they also receive all the same instructions as the “main” session.

Sub-agents receive additional custom instructions as configured.

There seems to be no way to give specialized instructions ONLY to the “main session”.

Does that make sense?


The reason I want something like this is because I’m attempting to implement a workflow where the “main session” becomes “the orchestrator”. I’m giving it very strict instructions about the steps it should follow to drive a change through to completion. Right now I’m putting these instructions in AGENTS.md and it’s confusing (+ polluting the context of) the sub-agents.

In this context each agent takes on a “role”. The current sub-agents have roles like “test writer”, “linter fixer”. I want the main session to also take on a specialized role: “the orchestrator”.

Does that make sense?

Originally created by @jessevdp on GitHub (Aug 7, 2025). Originally assigned to: @thdxr on GitHub. Currently, you can give custom instructions to opencode via the `AGENTs.md` file (or by [specifying other `instructions` paths](https://opencode.ai/docs/rules/#custom-instructions)). If I understand correctly, these instructions are passed to every new session. And since sub-agents are really just “invisible sessions” they also receive all the same instructions as the “main” session. Sub-agents receive additional custom instructions [as configured](https://opencode.ai/docs/agents/#configuration). There seems to be no way to give specialized instructions ONLY to the “main session”. Does that make sense? --- The reason I want something like this is because I’m attempting to implement a workflow where the “main session” becomes “the orchestrator”. I’m giving it very strict instructions about the steps it should follow to drive a change through to completion. Right now I’m putting these instructions in `AGENTS.md` and it’s confusing (+ polluting the context of) the sub-agents. In this context each agent takes on a “role”. The current sub-agents have roles like “test writer”, “linter fixer”. I want the main session to also take on a specialized role: “the orchestrator”. Does that make sense?
yindo closed this issue 2026-02-16 17:29:36 -05:00
Author
Owner

@jessevdp commented on GitHub (Aug 8, 2025):

Perhaps custom slash commands (https://github.com/sst/opencode/issues/299) would be an OK fit for this? At least as a workaround. It would give me a way to easily insert a prompt into the main session to get it to take on the role of a specialized agent.

That does mean that this prompt isn't going into the system messages. Would that make a big difference?

I still think that the concept of "choosing an agent" (or personality?) to chat with is pretty cool and could be useful.

I've seen others ask about getting to "control" the sub-agents and chat with them. To use them more as separate agents that "hand off" to each other with the human still in the mix. (I'll search for and link to an issue if it exists.)

Perhaps this concept of "choosing an agent" (/personality) for the main chat combines nicely with that?

@jessevdp commented on GitHub (Aug 8, 2025): Perhaps custom slash commands (https://github.com/sst/opencode/issues/299) would be an OK fit for this? At least as a workaround. It would give me a way to easily insert a prompt into the main session to get it to take on the role of a specialized agent. That does mean that this prompt isn't going into the `system` messages. Would that make a big difference? I still think that the concept of "choosing an agent" (or personality?) to chat with is pretty cool and could be useful. I've seen others ask about getting to "control" the sub-agents and chat with them. To use them more as separate agents that "hand off" to each other with the human still in the mix. (I'll search for and link to an issue if it exists.) Perhaps this concept of "choosing an agent" (/personality) for the main chat combines nicely with that?
Author
Owner

@jessevdp commented on GitHub (Aug 8, 2025):

LMAO here I am pondering about this, and you already shipped this exact fucking thing. (https://github.com/sst/opencode/pull/1689) Way to go!

Thx @thdxr ❤️

@jessevdp commented on GitHub (Aug 8, 2025): LMAO here I am pondering about this, and you already shipped this exact fucking thing. (https://github.com/sst/opencode/pull/1689) Way to go! Thx @thdxr ❤️
Author
Owner

@JamesJosephFinn commented on GitHub (Aug 31, 2025):

Are subagents provided with a fresh context / prompt, which is constructed dynamically, on the fly, by the primary agent which spawned them? Thank you to the team for such an amazing tool!

@JamesJosephFinn commented on GitHub (Aug 31, 2025): Are subagents provided with a fresh context / prompt, which is constructed dynamically, on the fly, by the primary agent which spawned them? Thank you to the team for such an amazing tool!
Author
Owner

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

yes thats correct

@rekram1-node commented on GitHub (Aug 31, 2025): yes thats correct
Author
Owner

@bogorad commented on GitHub (Jan 16, 2026):

yes thats correct

maybe this should be reflected in the docs?

https://opencode.ai/docs/agents/#subagents

@bogorad commented on GitHub (Jan 16, 2026): > yes thats correct maybe this should be reflected in the docs? https://opencode.ai/docs/agents/#subagents
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1142