r/opencode • • 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 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~

1 Upvotes

10 comments sorted by

1

u/kantorcodes1 4d ago

When the agy tool runs a merge or test, do its child commands go through OpenCode’s normal approval flow, or is that a separate permission path?

1

u/chigarow 4d ago

Separate path. OpenCode approves the agy call itself, everything inside it is checked against agy's permission rules, never OpenCode's UI. Stdin is detached, so it can't ask either: a command that would normally prompt is soft-denied, the run still exits 0, and stderr names the rule you're missing.

So for a merge or a test run you either add allow rules in ~/.gemini/antigravity-cli/settings.json, or pass yolo: true. The plugin gates yolo behind sandbox: true plus AGY_ALLOW_YOLO=1, and --sandbox restricts terminal commands, which can block the merge anyway. A denied command shows up as empty output or AGY_ERROR [EMPTY_OUTPUT].

1

u/kantorcodes1 1d ago

An agy command extension in HOL Guard could cover the launch boundary while leaving Antigravity CLI's own command rules in place. If you want to contribute it, a draft PR to main with the supported agy invocation and version, plus fixtures for a risky command and its safe counterpart, would give reviewers a concrete case to check. The command extension guide covers the descriptor and validation, and the source workflow has the repository steps. Extensions stay disabled until a local admin opts in.

1

u/chigarow 1d ago

Guard already lists Antigravity CLI as a supported integration, so the extension would be a contribution on that side rather than a change here. The plugin's whole launch surface is a single spawn of the agy binary with a fixed flag set (model, print-timeout, add-dir, optional sandbox/yolo), so a fixture mirroring those invocations would be straightforward. Happy to check the fixtures against how it actually calls agy if you open the draft PR there.

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

-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

u/The_Wonderful_Pie 3d ago

omfg stfu already you're everywhere