Control flow from main agent to subagent and back to main agent #1762

Closed
opened 2026-02-16 17:32:31 -05:00 by yindo · 8 comments
Owner

Originally created by @venkatr21 on GitHub (Sep 19, 2025).

Originally assigned to: @thdxr on GitHub.

Hey,
I have a main agent

Image

and a bunch of sub agents (one in the example)

Image

I use the main agent as an orchestrator, and the subagent as a specialized agent which does the atomic task. The prompts define control flow from main agent to sub agent and again back to main agent (as handover).
We see that when the main agent hands over to subagent, which might ask a user input, to accomplish its task, somehow the main agent starts over all again, this this goes into an endless loop.

Pretty confused why this is happening and how to fix this. Any help here please?

Originally created by @venkatr21 on GitHub (Sep 19, 2025). Originally assigned to: @thdxr on GitHub. Hey, I have a main agent <img width="306" height="156" alt="Image" src="https://github.com/user-attachments/assets/afbed675-df79-43eb-bb54-3781cb9823f2" /> and a bunch of sub agents (one in the example) <img width="271" height="153" alt="Image" src="https://github.com/user-attachments/assets/1ab5e39f-3106-4a3d-8389-dabcda3a8151" /> I use the main agent as an orchestrator, and the subagent as a specialized agent which does the atomic task. The prompts define control flow from main agent to sub agent and again back to main agent (as handover). We see that when the main agent hands over to subagent, which might ask a user input, to accomplish its task, somehow the main agent starts over all again, this this goes into an endless loop. Pretty confused why this is happening and how to fix this. Any help here please?
yindo closed this issue 2026-02-16 17:32:31 -05:00
Author
Owner

@venkatr21 commented on GitHub (Sep 19, 2025):

@thdxr any inputs on this?

@venkatr21 commented on GitHub (Sep 19, 2025): @thdxr any inputs on this?
Author
Owner

@rekram1-node commented on GitHub (Sep 19, 2025):

can you share a session of this? I havent seen it before

edit: nvm I misunderstood post originally

@rekram1-node commented on GitHub (Sep 19, 2025): ~~can you share a session of this? I havent seen it before~~ edit: nvm I misunderstood post originally
Author
Owner

@anuramat commented on GitHub (Sep 19, 2025):

shouldn't the description of the main agent be a prompt instead?

@anuramat commented on GitHub (Sep 19, 2025): shouldn't the `description` of the main agent be a `prompt` instead?
Author
Owner

@rekram1-node commented on GitHub (Sep 19, 2025):

just to note:

description: used so a primary agent can designate tasks to the given agent (this is basically a prompt for the main agent to know if it should call this agent or not)

prompt: this is the prompt the agent is being given

@rekram1-node commented on GitHub (Sep 19, 2025): just to note: description: used so a primary agent can designate tasks to the given agent (this is basically a prompt for the main agent to know if it should call this agent or not) prompt: this is the prompt the agent is being given
Author
Owner

@NaikSoftware commented on GitHub (Sep 21, 2025):

can you share a session of this? I havent seen it before

its the same https://github.com/sst/opencode/issues/2378

Now work with subagents almost impossible because thea are implemented just as prototype: some part of work can be delegated and that's all. You can't control anything:

  • decline some edit and guide in right path
  • queue some message to subagent to refine task details
  • ask user via subagent for some decision

Spoiler: all these points are not fantastic, already implemented in ClaudeCode and it's the reason why I switched to it.

Now Opencode subagents can just receive prompt for the subtask and return some result.

@NaikSoftware commented on GitHub (Sep 21, 2025): > can you share a session of this? I havent seen it before its the same https://github.com/sst/opencode/issues/2378 Now work with subagents almost impossible because thea are implemented just as prototype: some part of work can be delegated and that's all. You can't control anything: - decline some edit and guide in right path - queue some message to subagent to refine task details - ask user via subagent for some decision Spoiler: all these points are not fantastic, already implemented in ClaudeCode and it's the reason why I switched to it. Now Opencode subagents can just receive prompt for the subtask and return some result.
Author
Owner

@rekram1-node commented on GitHub (Sep 21, 2025):

You can navigate to the child session and communicate with the subagent directly actually but we definitely need to make that permissions feedback better

edit: my bad mistake

@rekram1-node commented on GitHub (Sep 21, 2025): ~~You can navigate to the child session and communicate with the subagent directly actually~~ but we definitely need to make that permissions feedback better edit: my bad mistake
Author
Owner

@NaikSoftware commented on GitHub (Sep 22, 2025):

You can navigate to the child session and communicate with the subagent directly actually but we definitely need to make that permissions feedback better

All messages sent to subagents are actually sent to main agent

@NaikSoftware commented on GitHub (Sep 22, 2025): > You can navigate to the child session and communicate with the subagent directly actually but we definitely need to make that permissions feedback better All messages sent to subagents are actually sent to main agent
Author
Owner

@rekram1-node commented on GitHub (Sep 22, 2025):

@NaikSoftware you're right! I missed that thanks for calling out.

I raised with the team that some of the UX for subagents isn't quite as good as CC as you have called out. Thanks for the continuous feedback here

@rekram1-node commented on GitHub (Sep 22, 2025): @NaikSoftware you're right! I missed that thanks for calling out. I raised with the team that some of the UX for subagents isn't quite as good as CC as you have called out. Thanks for the continuous feedback here
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1762