---
source: https://iinventedlight.com/library/notes/ao-subagent-delegation.md
title: "Coding agents delegate isolated work to named subagents with their own context"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (google-gemini/gemini-cli (GitHub)); MIT (anomalyco/opencode (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: google-gemini/gemini-cli (GitHub), Subagents (Gemini CLI docs), Apache-2.0 (https://raw.githubusercontent.com/google-gemini/gemini-cli/main/LICENSE). Copyright (c) Google LLC; anomalyco/opencode (GitHub), Agents (OpenCode docs), MIT (https://raw.githubusercontent.com/anomalyco/opencode/dev/LICENSE). Copyright (c) 2025 opencode."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: medium
untested: "Not reproduced (2026-11-16). Official docs and source files were read; no client, server, or agent was run for this note."
category: agent-operations
topic_area: "agent operations: subagent delegation"
tags: [subagent, delegation, gemini-cli, opencode]
client: Librarian
sources:
  - id: S1
    title: "Subagents (Gemini CLI docs)"
    publisher: google-gemini/gemini-cli (GitHub)
    url: https://github.com/google-gemini/gemini-cli/blob/main/docs/core/subagents.md
    accessed: 2026-11-16
    license: "Apache-2.0"
  - id: S2
    title: "Agents (OpenCode docs)"
    publisher: anomalyco/opencode (GitHub)
    url: https://github.com/anomalyco/opencode/blob/dev/services/site/src/docs/content/agents.mdx
    accessed: 2026-11-16
    license: "MIT"
---
# Coding agents delegate isolated work to named subagents with their own context
**Answer:** Subagents are specialized agents that operate within your main Gemini CLI session. They handle specific, complex tasks without cluttering the main agent's context or toolset. Each subagent is exposed as a tool of the same name. Calling that tool is how the main agent delegates the task.

## Gemini CLI usage

You can use subagents through automatic delegation. You can explicitly direct a task to a specific subagent. Use the @ symbol followed by the subagent's name at the beginning of your prompt. Interactions with a subagent happen in a separate context loop.

## OpenCode

Create a Markdown file to add a reusable agent. Save Markdown agents under ~/.config/opencode/agents for all projects. Save them under .opencode/agents inside a project. Frontmatter can set mode: subagent. The Markdown body becomes the agent's system prompt. You can also define agents under agents in an OpenCode configuration file.

## See also

- [ao-remote-agents-a2a](https://iinventedlight.com/library/notes/ao-remote-agents-a2a/)
- [ao-tool-result-truncation](https://iinventedlight.com/library/notes/ao-tool-result-truncation/)

## Claims

- id: C1
  claim: Gemini subagents operate within the main CLI session.
  source: S1
  evidence: "Subagents are specialized agents that operate within your main Gemini CLI"

- id: C2
  claim: The main agent calls a tool of the same name to delegate.
  source: S1
  evidence: "Subagents are exposed to the main agent as a tool of the same name"

- id: C3
  claim: OpenCode adds a reusable agent as a Markdown file.
  source: S2
  evidence: "Create a Markdown file to add a reusable agent"

- id: C4
  claim: An OpenCode example sets mode to subagent in front matter.
  source: S2
  evidence: "mode: subagent"

## Sources

- [S1] Subagents (Gemini CLI docs). google-gemini/gemini-cli (GitHub). https://github.com/google-gemini/gemini-cli/blob/main/docs/core/subagents.md . License: Apache-2.0. Accessed 2026-11-16.

- [S2] Agents (OpenCode docs). anomalyco/opencode (GitHub). https://github.com/anomalyco/opencode/blob/dev/services/site/src/docs/content/agents.mdx . License: MIT. Accessed 2026-11-16.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: google-gemini/gemini-cli (GitHub), Subagents (Gemini CLI docs), Apache-2.0 (https://raw.githubusercontent.com/google-gemini/gemini-cli/main/LICENSE). Copyright (c) Google LLC; anomalyco/opencode (GitHub), Agents (OpenCode docs), MIT (https://raw.githubusercontent.com/anomalyco/opencode/dev/LICENSE). Copyright (c) 2025 opencode. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
