Skip to content

Menu

Antigravity

Which tasks to hand to subagents, and when to use /swarm and /teamwork

Decide whether a task is worth splitting across Antigravity subagents or multi-agent orchestration, understand workspace isolation and context boundaries, and write a read-only custom subagent.

min read
16
Level
Advanced
Last verified

This page answers one question: for the task in front of you, is it worth handing part of it to another agent, and if so, which kind? After reading it you can choose among “ask the main agent directly, a subagent, /swarm, or /teamwork” based on the shape of the task, and write a read-only custom subagent. The examples on this page were not run. They were only checked against the official pages for structure; try them in a synthetic repository first, then use them on a real project.

This page covers behavior in the Antigravity App and Antigravity CLI. For the IDE extensions and the standalone IDE, defer to the official pages; the differences between entry points are in Choosing an Antigravity surface. This is an independent, unofficial handbook, and features and plan restrictions can change at any time; the official pages are authoritative.

What a subagent is, and when not to use one

Section titled “What a subagent is, and when not to use one”

A subagent is another agent session that the main agent spins up on the side. Per the official page, the parent agent calls the invoke_subagent tool to create a concurrent session with a role and an initial prompt. It runs in the background and sends its result back to the parent when finished. You can open its conversation to watch progress, or message it directly.

Think of it as handing an errand to a colleague while you carry on with your own work. The colleague doesn’t know what you discussed earlier, so the errand has to be spelled out; the colleague also uses extra quota and your review attention.

Tasks that suit a subagent share these traits:

  • Self-contained: research one directory, run the test suite, check one page in a browser.
  • Easy to accept or reject: a list, a pass or fail, a conclusion with its sources.
  • No need for the judgment built up in the main conversation.

These situations are a poor fit:

Situation Why Better approach
The task depends on trade-offs settled over dozens of earlier turns A subagent doesn’t inherit the parent conversation; it only sees the prompt you give it Do it in the main agent, or first write the trade-offs into rules; see Where rules, skills, plugins, and MCP must live
The changes are tightly coupled and must move together Concurrent edits to the same files can overwrite or conflict Let the main agent work sequentially, or first carve out non-overlapping boundaries
A change to one or two files Starting a session costs more than it saves Prompt the default agent directly
You want a subagent to “think harder” to raise quality Repeating the same question doesn’t automatically improve it; the official page puts hard-but-narrow problems under /boost-style orchestration Write the acceptance criteria first, then decide whether you need orchestration
You need an enforced gate Subagent limits rest on configuration, not a hard guarantee Put it in CI and branch protection

The official page lists three subagents that ship out of the box:

Name Purpose
research Codebase research, file navigation, and structural exploration
browser Opens and interacts with web pages for UI playtesting and screenshots, and inspects the console and network
self A direct clone of the calling agent, with the same system instructions and toolset

How browser is available varies by account and surface. The official page says: on personal Google Accounts in the App (v2.30.0 and later), the main agent can launch one or several browser subagents automatically in the built-in browser, or you can invoke /browser directly; in the CLI and on business or enterprise accounts, you invoke /browser to connect to Google Chrome. For the exact conditions and versions, defer to the official Browser use page.

You can message one subagent on its own with an @ mention, for example @research:some-name also check the tests; see the official Mentions and quoting page for the syntax.

When a subagent is invoked, you can choose how its workspace relates to the parent’s. The official page gives three values:

Value Meaning Watch out for
inherit Uses the same workspace as the parent It works on the same files you and the parent do, and its changes appear directly in your workspace
branch Creates an isolated Git worktree Changes land in the isolated copy first; temporary worktrees created for a subagent are cleaned up automatically when it is killed, so land anything you want to keep first
share Shares directory storage The official page says only this much; defer to it for finer semantics

The parent agent keeps full access to its subagents’ workspaces, including isolated worktrees. On permissions, the official page says subagents inherit the parent’s safety configuration: allowed terminal command prefixes, file read/write directory scopes, and sandbox settings. When a subagent hits a tool call that needs authorization, the request bubbles up to the main UI or the subagent panel for you to approve or deny. See the official Permissions page for the rules.

Choose by asking “will it write files” and “could it collide with someone”:

  • Read-only research: inherit is enough.
  • It edits files while you are also editing: use branch, then review the diff before merging anything back.
  • Several subagents writing to the same repository at once: give them non-overlapping files first, then consider branch.

Subagents do not inherit the parent’s context

Section titled “Subagents do not inherit the parent’s context”

The official page states plainly that a subagent runs on the model tier you specify but does not inherit the parent’s existing conversation history; it starts with a clean slate. This is the most common trap, and also the reason it can save context.

In practice:

  • When you hand off a task, put the goal, scope, what must not be touched, and how to verify into the initial prompt. Don’t write “as we discussed”.
  • Put shared conventions in rule files or in the subagent’s own .md body; don’t count on the parent conversation to carry them.
  • When a subagent finishes, it becomes idle and keeps the context from its own earlier turns; a message from another agent wakes it up again automatically. A killed subagent cannot be revived, but its transcript remains readable in JSONL logs.
  • Subagents can nest. The official page states a maximum nesting depth of 10 levels, to prevent runaway recursion.

A custom subagent is a Markdown file with YAML frontmatter; everything after the frontmatter is its system prompt. The official page also mentions creating transient subagents in a session with the define_subagent tool; this page covers only the file form.

File locations (official page):

Scope Path
Workspace .agents/agents/<name>.md or .agents/agents/<name>/agent.md
Global ~/.gemini/config/agents/<name>.md or ~/.gemini/config/agents/<name>/agent.md
Plugin plugins/<plugin_name>/agents/

The CLI’s /agents command page gives the templates for new agents as {workspace}/.agents/agents/{agent_name}/agent.md and ~/.gemini/config/agents/{agent_name}/agent.md, and warns that the scanner looks only inside agents/ directories, so a file placed directly in the config root is not discovered. For the discovery rules of other customizations, see Where rules, skills, plugins, and MCP must live.

Frontmatter fields (the properties listed on the official page):

Field Type Default Description
name string required Unique identifier
description string required The planner uses it to decide when to delegate to this agent, so state the use case clearly
tools string[] [] Tools this subagent may use, such as view_file, replace_file_content, grep_search, run_command
mainAgent boolean true When true, it can be selected as the primary agent in chat interfaces
subagent boolean true When true, it can be invoked with invoke_subagent
model string inherit Model tier: inherit, flash, or pro
command execution policy string sandbox Auto-execution policy for shell commands: off, auto, eager, sandbox
mcpServers object[] [] MCP servers dedicated to this subagent
skills / plugins string[] [] Skill paths or plugin dependencies

Two points you need to confirm yourself:

  • The field name for the command execution policy. The official property table splits it into two words, while the example writes commandExecutionPolicy; the two places are not fully consistent. The minimal example below therefore does not use it. If you need it, check the official page’s current spelling first.
  • What an empty tools means. The official page gives only the default []; it doesn’t say whether an empty list means “no tools” or “the default toolset”. For a read-only subagent, list tools explicitly instead of relying on the default.

The official page also carries a known-issue note: naming a tool in tools that doesn’t exist, or misspelling one, may make the subagent process hang, and the official page says validation will be tightened in a later update. Copy tool names exactly.

When a task outgrows “send one subagent on an errand”, the official docs offer several multi-agent orchestrators. The table below combines the comparison tables on the official Swarm and Teamwork pages. /teamwork and /boost are paid-plan features; don’t present them as available to every account. /swarm is stated as available on all plans, but it is in preview, and on business and enterprise accounts it also depends on organization admin settings. The authoritative plan assignment is on the official pages; for how accounts and plans differ, see Accounts, plans, and quotas.

Subagents /boost /swarm /teamwork
Best for One self-contained side task Hard-but-narrow problems such as tough bugs Work that splits cleanly into non-overlapping pieces Multi-milestone projects spanning hours to days
How they coordinate Each runs in the background and reports to the agent that started it Iterative pipeline: implement, challenge, fix, re-verify A coordinator splits the task; named workers and a verifier talk on one shared message board A scoping interview first, then a milestone plan with review gates
Workspace Current workspace, or isolated on request Current workspace Shared by default; one working copy per worker when needed A dedicated project directory, with exclusive file ownership
Plan Listed as all plans in the official comparison Paid plans All plans (preview) Paid plans

Keep three warnings in mind when choosing:

  1. Quota use multiplies. The official page says every worker in a swarm is its own agent, so a swarm uses quota much faster than a single conversation.
  2. /swarm suits only tasks that split cleanly. The official examples give each worker its own file so that no two workers edit the same file at once. If you can’t split it, don’t use it.
  3. /teamwork assumes you’ll answer the interview. It first asks about goals, requirements, how to verify each independently, and acceptance criteria, and it works in a dedicated directory, by default ~/teamwork_projects/{PROJECT_NAME}; once you approve the prompt it runs autonomously. The official page also mentions three integrity modes (development, demo, benchmark), set by which shortcuts you rule out during the interview.

Two more things about /swarm: posts on the board are public and workers don’t message each other privately; a member that runs out of quota pauses and doesn’t restart on its own when quota refreshes, only when there is a new post, its model is switched, or you message it. To monitor, the App has a Swarm pane and the CLI has /swarm board (or Alt+S). For operating details see the official Swarm and Teamwork pages; this page doesn’t repeat them.

Every extra agent adds quota use. Waiting swarm members use no tokens, but active ones cost the same as a standalone conversation. This page gives no quota figures, refresh periods, or model lists, because they vary by plan; see Accounts, plans, and quotas and the official Plans and Models pages.

A few ways to spend less:

  • Validate the split with one subagent before scaling up to a swarm.
  • Give a subagent a bounded scope and an endpoint; don’t write “check everything”.
  • For read-only research subagents, pick a lighter tier in the model field (values in the table above) and keep the stronger tier for work that needs judgment. Whether this actually saves quota is a billing question; defer to the official documentation.
  • If a member is going in circles, terminate it (see “Failure recovery”).

Minimal example: a read-only custom subagent

Section titled “Minimal example: a read-only custom subagent”

The starting material is a synthetic repository demo-notes: a set of Markdown notes under notes/, including todo.md and ideas.md. Goal: write a read-only note-auditor so the main agent can hand it side tasks such as “check the notes for broken internal links”. Allowed changes: add one file, .agents/agents/note-auditor.md.

.agents/agents/note-auditor.md:

---
name: note-auditor
description: Read-only audit of the Markdown notes in demo-notes, reporting broken internal links and duplicate headings. Use only when asked to "check" or "audit" the notes.
tools:
- view_file
- grep_search
subagent: true
mainAgent: false
---
# Role
You are a read-only note auditor. You find problems; you never modify any file.
# How to work
1. Read the Markdown files under `notes/` using only viewing and searching tools.
2. Report each problem with its file path, line number, and a one-sentence reason.
3. If you find nothing, say "no problems found" and list which files you checked.
4. When unsure, mark the item "needs human confirmation" instead of guessing.
5. Never read or output any secret; in examples, a key is always `YOUR_API_KEY`.

It deliberately has only view_file and grep_search, with no replace_file_content or run_command, so by design it cannot write files or run commands. The field values come from the lists on the official page; check the tool names against the official page’s current list.

How to use it:

  1. After saving the file, start the CLI in the demo-notes directory.
  2. Type /agents; note-auditor should appear under Available Agents. In the App, look in Customizations; defer to the official page for the exact entry point.
  3. Give the main agent a prompt: “Have note-auditor check notes/ for broken internal links. Report only; don’t modify anything.”
  4. In the /agents panel, watch its state under the Subagents group; press Enter to open the detail view and see its tool calls.

Expected result: the subagent returns a list of problems with paths and line numbers, and git status stays clean throughout.

Verification: when the task ends, run git status and git diff and confirm there are no changes. One expected-failure check: ask the main agent to have it “fix those links while you’re at it”. It should decline or say it has no write tool. If the repository does change, the change came from the main agent or the configuration isn’t what you expected; stop and review tools and permission settings before using it any further.

Anti-pattern one: a one-line handoff.

Have the subagent tidy up the whole repository.

Problem: no scope, no endpoint, no acceptance, and the subagent can’t see your earlier conversation. Rewrite:

Have note-auditor check only the .md files under notes/ for internal links
that point to files that don't exist. List them as "path:line:reason", at
most 20 items. Do not modify any file.

Anti-pattern two: concurrent edits to one file.

/swarm Have three workers improve the headings, formatting, and wording of notes/todo.md.

Problem: three workers editing one file will overwrite each other. Rewrite: split by file, one worker per file, and have a verifier check each at the end; or recognize this isn’t worth a swarm and let the main agent do it.

Anti-pattern three: /teamwork for a small task.

/teamwork Fix the typos in todo.md.

Problem: it is built for multi-milestone projects, starts with an interview, and creates a dedicated project directory; on a small change it only burns quota. The official page mentions a lighter path for a single, self-contained change, reached by saying “keep it small” in the prompt, but a task like this usually belongs with the main agent.

Anti-pattern four: a tools list that can hang the subagent.

tools:
- view_file
- search_files

Problem: search_files is not a tool name listed on the official page, and the official page warns that a misspelled tool name may hang the subagent. Rewrite: use names from the official page, such as grep_search, and try it once in a synthetic repository first.

  • A subagent is going in circles or running longer than expected: in the CLI, open /agents, select it, and press K to terminate it; in the App, click Stop Subagent in the subagent panel. Termination also covers its child threads.
  • You want to see what it’s doing: in /agents, select it and press Enter for the detail view, which shows its thoughts, tool calls, and output; with a pending request, you can press A to approve or D to deny from the list. You can also press Alt+J at the prompt to jump to the next subagent waiting on your approval, and Ctrl+K to approve without leaving your current conversation. Read what it is asking to do before you approve.
  • A subagent seems stuck and unresponsive: first check tools for a misspelled tool name, which the official page flags as a known issue; fix it and start the task again.
  • It used a workspace mode you didn’t want, or changed files: inspect the diff with Git and git restore; if it used branch, discard that worktree, which leaves your main workspace untouched.
  • A swarm member stopped after running out of quota: the official page says it won’t restart on its own when quota refreshes. Decide whether to continue, then wake it with a new post, a model switch, or a direct message, or have the coordinator add a new worker. A removed worker cannot be restored.
  • A custom subagent doesn’t show up in the list: check that the file is under .agents/agents/ and has both name and description; for how to troubleshoot a wrong location, see Where rules, skills, plugins, and MCP must live.
  • You want automatic checks before or after tool calls: see Run automatic checks before and after tool calls with hooks.

Not covered by the official pages, or to confirm yourself

Section titled “Not covered by the official pages, or to confirm yourself”
  • The details of the share workspace option: the official page gives only one sentence.
  • The exact field name for the command execution policy, and what an empty tools does.
  • Availability of each orchestration command across plans and organization settings: the official pages state this at different levels of detail; defer to their current content, and note that /swarm on business and enterprise accounts also depends on admin settings.
  • Subagent entry points in the IDE extensions and the standalone IDE: not checked on this page.
  • The examples on this page were not run, including whether the subagent file is discovered and invoked as expected.

Next: to finish a small task with an agent first, see Your first agent task: Use execution modes and permissions as guardrails; to see where each kind of customization belongs, see Where rules, skills, plugins, and MCP must live; to add automatic checks around tool calls, see Run automatic checks before and after tool calls with hooks.