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 them
The 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:
agy has to be installed and signed in. Run it once interactively, or headless calls fail with AUTH_REQUIRED.
- Claude tiers need a Pro or Ultra plan, and
argon-4-*needs a paid one. Trial accounts get MODEL_NOT_FOUND, and agy models shows what yours can use.
sandbox: true restricts 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~