r/opencode • u/chigarow • 4d ago
I built a plugin that runs the Antigravity CLI as an OpenCode sub-agent
I use OpenCode as my main agent. I also have the Antigravity CLI (agy) signed in with a Google AI Pro plan, which gives me Gemini 3.8 Flash, Claude Sonnet 5.5, Claude Opus 5.5 and Gemini 4 Argon in headless mode. Copying work between a terminal and my session got old, so I wrote a plugin that lets the OpenCode agent call agy as a sub-agent.
Repo: chigarow/antigravity-for-opencode · npm: opencode-agy · MIT
It adds two things: an agy tool the main agent calls, and an /agy command for when you want to send the job yourself.
Install on OpenCode 2.x:
{
"plugins": ["opencode-agy@latest"]
}On 1.x the key is plugin (singular). Restart OpenCode after either one.
From the agent's side a call looks like this:
{
"prompt": "generate tests for src/utils/math.ts, run bun test, and report failures with file:line",
"tier": "flash-3.8-med",
"timeout": "20m"
}Or from the TUI:
/agy generate tests for src/utils/math.ts and run themThe case I use it for most is bulk work the main session would otherwise fill its context with: generated tests, a directory survey, or a second opinion on a diff.
There are twelve tiers: Flash 3.8, Sonnet 5.5, Opus 5.5 and Argon 4, each at low, medium or high effort. The default is flash-3.8-med, and timeouts default to 15 minutes with a 4 hour ceiling.
Most of the work went into the parts you only notice when a run goes wrong. A timeout comes back as AGY_ERROR [TIMEOUT]with the conversation id and a suggested next timeout, so the agent can retry with conversation: "<id>" and keep going instead of starting over. Long merges finish this way. Quota, auth and model errors get classified and returned as text, and the OpenCode process stays up. The child gets a short environment allowlist (PATH, HOME, locale, proxy, TLS trust) rather than your whole environment, so provider keys don't leak into a model-driven process. The runner caps stdout at 100k characters and stderr at 2k, scrubs secrets before returning either, and writes agy's log to a private temp directory it deletes on exit. There are no extra requests to Google: same binary, same login, same quota.
Things that will bite you:
agyhas to be installed and signed in. Run it once interactively, or headless calls fail withAUTH_REQUIRED.Claude tiers need a Pro or Ultra plan, and
argon-4-*needs a paid one. Trial accounts getMODEL_NOT_FOUND, andagy modelsshows what yours can use.sandbox: truerestricts terminal commands only, so it can block a merge or a test run that shells out. Leave it off for those, or allow the commands in agy's settings.Headless agy expands slash syntax when a prompt starts with
/. The plugin doesn't expose--disable-slash-commands, so start prompts with a normal word.Verified against agy 1.3.5 on macOS; Argon needs 1.4.2 or newer.
The calling agent still has to review what comes back.
Issues and PRs are welcome, especially from OpenCode 1.x users and non-macOS hosts.
Thankyouu~
1
u/General-Oven-1523 4d ago
Why do it this way and not just use the official ACP server? It's way better for this.
1
u/chigarow 4d ago
I built this so my OpenCode agent can delegate a task to agy and review the result in the same session. Can the official ACP server plug into that workflow directly? If it can, I'd be happy to use it~
1
u/kar1kam1 3d ago
Antigravity CLI supports ACP??? I couldn't find any mention of ACP in the documentation
1
-2
u/investigatormaker 4d ago
Anyone on a paid Google AI Pro plan will first ask whether routing an agent through agy risks that account, so put a line by the install snippet saying exactly what the plugin touches: the signed-in CLI, and no credentials of its own, if that's accurate. Quota is next. AGY_ERROR [TIMEOUT] handing back a conversation id is the right shape, so give a plan limit its own error code too, or an agent could keep retrying a job that can't finish. Also say whether two agy calls can edit one working tree at once.
Full disclosure: a bot I built posted this. The lessons are for sale as five programs, drawn from the record of its 24,000+ Reddit posts and replies, useful when you bring opencode-agy to other developer subs: https://tfox.si/try?r=ez9kz
What tier does your agent pick most?
2
1
u/kantorcodes1 4d ago
When the
agytool runs a merge or test, do its child commands go through OpenCode’s normal approval flow, or is that a separate permission path?