r/opencodeCLI • • 2d ago

Is the change "Background Subagents by Default" since v2.3.0 good?

Since version 2.3.0, OpenCode now runs background agents by default. As far as I know, there is no option to disable this, so this seems to be enforced.

I tried this new setup but it seems to me that it is just adding extra turns with no real value. For example, say you have an orchestrator and that orchestrator calls four different Explorer agents.

With the old way of having those sub-agents working on the foreground, the orchestrator would wait for the four different explore agents to return, it would check their outputs and then it would produce its own output having taken into account all of them.

Now what happens is that it dispatches the four sub-agents and then returns.
When the first sub-agents comes back, it checks its output and says ok, let's wait for the other three to come back.
Then the second one comes back, checks its output and says, ok, let's wait for the other two to come back.
Then the 3rd one comes, checks its output and says, let's wait for the last one to come back.
And when the 4th one comes back, it then outputs a final.

From what I understand, each time that a subagent comes back and our orchestrator checks its output, that is a request that sends the entire context to the API servers. Sure it is most probably cached, but it is still billed. Isn't that way of working very inefficient? Am I missing something?

EDIT: It looks like there is an active issue about this on GH
https://github.com/anomalyco/opencode/issues/64073

EDIT2: Apparently they closed the issue saying "We aren't bringing back blocking subagent calls, so closing as not planned."… 🤬

18 Upvotes

26 comments sorted by

6

u/look 2d ago

Add an instruction to your AGENTS.md to use foreground subagents by default. The model can still do that; it just prefers the background by default now.

2

u/miangelo 2d ago

That's not actually possible. They have fully removed the background parameter from the dispatch tool, which means that it is not possible for any agent to launch the dispatch tool with background to false.

3

u/SirRobinBlibs 2d ago

Since 2.3.0 the background option is gone: every subagent returns a session id immediately, and the parent gets a report each time the child goes idle, then again after later rounds of work. So yes, those intermediate "still running" or idle reports can start an extra parent turn, not only the final result.

I wouldn't treat every wake as a guaranteed full-price replay of the whole parent context — that depends on whether the provider cache is still warm — but it is still a model call, and the docs don't currently offer a "final report only" switch. If the orchestrator is chatting after every idle, I'd batch the child work so it reports once when it's actually done, rather than asking the parent to reconcile after each explorer.

3

u/JSA343 2d ago

No, the way it was implemented was not a good change. Background by default is fine, but completely removing real blocking/foreground behavior was a really bad move. Removing foreground execution entirely just wasn't even necessary, why take out options? I find it hard to believe no one saw any problems with removing the way it's been working all along, that no one would have any workflows and expectations based on or any uses for deterministic subagent returns?

Need to wait for all implementing subagents to return before running build checks, otherwise builds may happen while code is still being actively modified. A planner or investigator that needs all parallel recon tracks to return before making decisions or really analyzing results in the full context.

Sure, you can start adding a bunch of system prompt instructions to try to tell your agents to wait for parallel dispatch to return before acting, but the way it's currently implemented this is still an inference turn and the agent can hallucinate responses or ignore that instruction. It's not hard determinism.

Not to mention the wasted full inference turns just for the primary agent to say "still waiting on subagent X". Hopefully the cache is warm, but it's still a cost. If you have subagent depth, where subagents spawn their own subagents (think an orchestrator spawns a planner to rethink a task plan, and that planner dispatches a wave of parallel recon subagents), then every lower subagent report wakes up every parent up the chain just to say "still waiting"! In an orchestration session that can mean cascading wakes and full turns up to the higher tier/more expensive models.

This change was just really rushed and not well thought out. Even besides the foreground removal issue, there just needs to be more controls for agents to handle background status updates without wasting turns. And radio silence for almost two weeks on addressing anything isn't a good look.

1

u/rubadub69 2d ago

You are missing a lot, you are actually saving context by using subagents as you allow orchestrator to preserve most context, make less mistakes and use less tokens on debugging and figuring out what was missed.

3

u/miangelo 2d ago

My point is not whether or not subagents are good. I know they're good.

What I'm questioning is whether they should be run on the foreground or on the background.

To simplify it, what is the point of dispatching four subagents and then after each one comes back say "Oh, ok, let's wait for the rest to finish.", instead of just waiting for all four to finish and then seeing their outputs and actually giving back a useful answer?

4

u/officerblues 2d ago

In some cases it's a drag. In my cases, it's usually a gain, because I have multiple tickets running in parallel with review steps, so the orchestrator is rarely waiting. I like ot more like this.

I got your point, though. We should be able to pick the behavior.

1

u/Infinite_Grab_7315 2d ago

Let explore run while agent continue exploring something else. Or let tests and fixing tests run in background while you continue reviewing main code

Review code in background while main agent finds more things to work on

1

u/miangelo 2d ago

Aren't the agents able to figure out what they want to explore before? I mean, if an agent wants to do X and realizes that X depends on A, B, C, D, then doesn't it make sense to launch agents to check A, B, C, D and only give an answer back when it has checked all of them?

Now it will tell you, okay, we have A, but let's wait for B, okay, now we have B, let's wait for C, okay, now we have C, let's wait for D, and then give you the answer. What is the point of all the messages in between the final one?

I do get the point regarding running long tasks on the background for example, but that's why I think it should be something optional and not a hard coded configuration.

2

u/rubadub69 2d ago

What if the functionality of A,B,C depends on context of D? Would you want your agent to start working witbout gathering full context and risking to fuck up your project? Ai behaves rationally and knows its best to have all information and than continue rather than assuming and making a mistake. If you want to continue working while they are exploring, surely it isnt that hard to advise it to orchestrator?

2

u/Infinite_Grab_7315 2d ago

Point is you don't have to wait. Also consider this. You started exploring. While it works you realised you can prompt the main agent to check something out in similar you later remembered, do others in parallel.

If your aim is token management then maybe it isn't the best. But from a workflow perspective nothing beats it

2

u/candraa6 2d ago

Aren't the agents able to figure out what they want to explore before? I mean, if an agent wants to do X and realizes that X depends on A, B, C, D, then doesn't it make sense to launch agents to check A, B, C, D and only give an answer back when it has checked all of them?

I think you have wrong mental model how to use agents then.

That's orchestrator's job, not each agent job.

You run "explore agent" once, and let the orchestrator resolve all the dependencies (e.g. which task depends on which task, what task need to be grouped together (i.e. run by the same agent), etc. ahead of time . then you ask your orchestrator to maximize all these task runs (e.g. what can be parallelized, what need to be wait, etc)

Now it will tell you, okay, we have A, but let's wait for B, okay, now we have B, let's wait for C, okay, now we have C, let's wait for D, and then give you the answer. What is the point of all the messages in between the final one?

from this, you don't need that many agent, if your task depends each other and can be done by 1 subagent, then use 1 subagent? maybe don't overuse subagent?

afaik, the point of using subagent is mainly parallelization, so it mostly want to run in the background, when your main conversation can do other things

----

I agree with your last point though:

but that's why I think it should be something optional and not a hard coded configuration.

option is always good, since each people do this differently

1

u/rubadub69 2d ago

Because to get full context u have to wait on all 4 of them to finish, each subagent pings orchestrator once he finishes, he checks if the rest finished, see that they have not and notifies you that its best to wait on all 4 to continue?

2

u/bokerkebo 2d ago

i agree with you, i am also wondering if this change is good, and i am actually thinking about moving back to opencode v1. sure we can solve things faster here, but i wonder if the cost is worth it

1

u/bitzap_sr 2d ago edited 2d ago

Spawning in the background lets you continue to talk with the orchestrator.

But then I use Pi and not opencode and this just appeared in my feed. :)

1

u/DrEdmond234 2d ago

whats the point? Suppose the agents didnt finish their job and I moved on. whats the point then? i have to wait for agent to finish before moving on anyway, no?

1

u/Mister_bruhmoment 2d ago

I find it helpful when I need to ask questions about the task or work. I also think a a toggle between background and foreground agents is needed, but I got accustomed to the background agents quite fast. It lets you also steer the orchestrator and the task instead of waiting for all agents to be done and then steering

1

u/bitzap_sr 2d ago

I do this all the time so I find the question really odd. I'll tell the orchestrator -- spawn a review subagent. And then while the review is ongoing, will continue chatting with the archestrator about other parts of what we're working on, maybe even tell it to spawn a few other subagents, or tell it to steer the already-running subagents about something.

1

u/Sontemo 2d ago

I think in general the change is good. It saves you money in two ways:

Running into cold caches cause your 4 agents took a long time to run and finish. Some providers have only a 5 minute cache, so 4 small status updates against a warm cache are much much cheaper than just one request against a cold cache.

Spreading out subagent results can help with not busting the KV cache due to too big individual requests on the next turn.

What I personally like to do is not to wait, but essentially instruct my agent to review the individual slices as they come in (if applicable).

1

u/Kitchen_Fix1464 2d ago edited 2d ago

*edit - misread a comment on the issue.

2

u/sc_zi 2d ago

What commit are you referring to? I'm following https://github.com/anomalyco/opencode/issues/64073 and there hasn't been any fix yet.

1

u/Kitchen_Fix1464 2d ago

https://github.com/anomalyco/opencode/pull/63382

I did not review the details, but found this linked in a comment

1

u/sc_zi 2d ago

That is the PR that made the change this thread is about, having all subagents run in the background. It's not a fix...

1

u/Kitchen_Fix1464 2d ago

We damn, I'm sorry I misread that. I guess I won't be updating until a PR with an actual fix is merged

1

u/riktech_76 1d ago

did you notice a difference in total run time too, or mostly extra turns? curious if the parent calls make the whole thing slower when all four explorers finish close together

1

u/Future_AGI 1d ago

one traced run would settle the cost question: take a single four-explorer task on 2.3.0, count the parent LLM calls each subagent report triggers, and check how many of their input tokens came back as cache reads. The opencode plugin in traceAI (npx u/traceai/agents setup opencode, 2.x from 2.2.5) keeps background children and the continuations their completions trigger inside the original prompt's trace, with input, output, cache-read and cache-write tokens on the model calls in that trace. traceAI is linked from https://github.com/future-agi/future-agi