r/opencodeCLI • u/FallElectronic3774 • 18d ago
A subagent saves your context, not your tokens
A subagent reads the files, runs the search, and reports back one summary, so the main thread never sees the twenty files it looked at. That is the point: the win is that its context dies with it, not that the work is cheaper, and it usually costs more tokens than doing the same thing inline. If you paste the full transcript back into the main thread afterwards, you paid for the subagent and kept the cost anyway.
5
Upvotes
14
u/xRebellion_ 18d ago
Subagents is mainly about parallelism and context management to begin with, not cost saving. Especially with the fact that the gap between cache read and input is widening.
6
u/bokerkebo 18d ago
it's cheaper if you use cheaper models for the subagent. otherwise, just use the main agent and maybe one reviewer subagent
2
u/Piyh 17d ago
The agent writes your reddit posts, not your brain
1
u/sagiroth 18d ago
You not reinventing the wheel here friend. It's common sense by now to use strong model for plan/orchestration and offload to cheap models.
1
u/Early_Aardvark_4026 17d ago
I had to process tens of millions of JSON records. I tried two methods.
I agree that subagents reduce the context each agent needs. In my case, total token use went up. Cost also depends on the model. If each task has a clear scope and needs little context, a faster model with a lower price per token can cost less overall, even if the run uses more tokens.
1
u/ward2k 17d ago
Depends, high context can cost you more tokens
I'm not someone that uses sub agents for literally everything but sometimes it's nice to help keep context free
You don't need your expensive model don't searches all over your codebase. You can pass that to a smaller model sub agent
A reviewer really benefits from a subagent with a clean context
Sometimes even a separate subagent for writing tests too. Main agents have a bit of a notorious habit of writing tests that pass no matter what and not just accepting that the code might be flawed
1
u/ConspicuousPineapple 18d ago
What do you think context is made of?