We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Subagents

Subagents are specialized agents that your primary agent can spin off concurrently to tackle narrower jobs. OpenCode ships with two built-in subagents:

  • general: a general-purpose worker that can research and execute multi-step tasks
  • explore: a fast, read-only worker for codebase and web exploration

Why Bother?

The big advantage is isolation.

When a primary agent invokes a subagent, that work happens in a child session instead of cluttering the context of the parent session with every search, command, and intermediate thought.

Subagents can also be cost-efficient because the isolated session can use a different model. For example, you might want your explore subagent to use a small, cheap model for searching around the codebase, then summarize its findings and inject them back into the parent session for your expensive model to analyze.

They can also be faster because subagents can run in parallel. When it launches a subagent in the background, your primary agent can keep working and receive the result when it's ready. Foreground calls wait for the subagent to finish.

How to Use Subagents

Subagents are mostly called autonomously by your primary agent, just like any other tool. However, you can also invoke them manually with the @ symbol:

@explore go find all the files related to authentication and summarize their contents for me

I never call subagents explicitly (though my primary agent uses them invisibly, of course). Your mileage may vary.

Assignment

Have a subagent find a gap in Sloperator's lexer tests.

Tell OpenCode to run and submit the CLI tests from the project root.