Repository navigation
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
There was a problem hiding this comment.
Unit tests pass and typecheck:tsc is clean, but there are blocking problems, and I could not run it end to end (it needs the Antigravity CLI and a Google account).
Policy first: #28889, the issue this builds on, was closed by a maintainer as "not allowed". Whether driving agy acp is acceptable still needs a maintainer's answer. The description's quotes about Google's terms aren't something this review can check.
Public API: adds the antigravity provider ID to packages/schema/src/provider.ts and adds a built-in provider that turns on automatically. This doesn't break anything existing. It also adds the @agentclientprotocol/sdk dependency to @opencode/core.
Blockers (details inline):
- Turns where the agent uses a tool crash with
Duplicate tool call. - The model and effort the user picks are never sent to the CLI.
- Every OpenCode session in a directory shares one CLI conversation and one listener slot, so chats get mixed up.
- The CLI is started in the background every time OpenCode starts, which contradicts "started on first use". The process is never stopped, and it isn't restarted if it dies.
Also: permission requests are always refused (Client.start({}) passes no handler). That doesn't match your comment on #28889 that they are answered from OpenCode's permission rules. Anything the agent does without asking also skips OpenCode's rules and plan mode (compare #53530). finishReason is always stop, even for max_tokens and refusal.
The tests only check render on single updates. A test that feeds tool_call and then tool_call_update for the same id through the stream would have caught the crash.
| if (update.kind === "thought") { | ||
| return [{ type: "reasoning-delta", id: "reasoning", delta: update.text }] | ||
| } | ||
| if (update.kind === "tool-call" || update.kind === "tool-call-update") { |
There was a problem hiding this comment.
Every tool_call_update sends another tool-call and tool-result with the same toolCallId. ACP agents send tool_call first and then one or more tool_call_updates. When the same id comes twice, session/runner/publish-llm-event.ts stops the turn with Duplicate tool call / Duplicate tool result. A pending call is also settled right away with a result. The tool name can change between updates (name ?? title), which also stops the turn. Send the call once and the result once, when the status becomes completed or failed, and keep the tool name fixed.
| groups = ready.groups | ||
| return groups | ||
| }, | ||
| run: async (request, onUpdate, signal) => { |
There was a problem hiding this comment.
request.model is ignored, and resolveSlug and the variant slug/effort settings are never used outside the tests. Every turn runs on the CLI's current model, whatever the user picked. Also, opened is one CLI session for the plugin's whole lifetime. Every OpenCode session in the directory continues the same conversation, and Client.prompt stores its listener by CLI sessionId, so two turns running at once overwrite each other's listener. The Claude Agent provider keeps one session per OpenCode session and cleans up on session.deleted; this needs the same.
No permission handler is passed here, so every session/request_permission is refused. Your comment on #28889 says they are answered from OpenCode's permission rules, and this doesn't do that. If the agent can't get approval at all, normal edits and shell commands will fail. And anything the agent does without asking skips OpenCode's rules and plan mode (the problem reported in #53530).
| yield* AntigravityProvider.register(ctx, known.length > 0 ? known : session.groups()) | ||
| yield* AntigravityAISDK.register(ctx, session) | ||
|
|
||
| yield* Effect.forkScoped( |
There was a problem hiding this comment.
This runs session.refresh() while the plugin loads, so agy acp is started and a session opened every time OpenCode starts. That contradicts "started on first use", and it logs a warning for everyone who doesn't have agy installed. Nothing closes the client when the scope ends, and if the child process dies, opened stays resolved to a dead client and is never restarted.
| controller.enqueue({ | ||
| type: "finish", | ||
| usage: usage(turn.usage), | ||
| finishReason: { unified: "stop", raw: turn.stopReason }, |
There was a problem hiding this comment.
unified is always stop. Map max_tokens to length, refusal to content-filter and cancelled to other, so a cut-off or refused turn doesn't look like a normal finish.
|
Looking forward to this being merged!! |
There was a problem hiding this comment.
The new commit fixes all four earlier points: one call and one result per tool call, the model and effort switched in with session/set_model, one CLI conversation per OpenCode session closed on delete, permission requests checked against OpenCode's rules, the CLI started lazily and closed when the plugin shuts down, and the finish reason mapped from the stop reason. The 18 unit tests pass and typecheck:tsc is clean. I still couldn't run it end to end (it needs the Antigravity CLI and a Google account).
The public API is the same as before: the new antigravity provider ID and a built-in provider that turns on automatically (backwards compatible), plus the @agentclientprotocol/sdk dependency.
New: Bun.which at startup will throw under Node (inline).
Still open: a maintainer needs to decide on #28889 whether driving agy acp is acceptable. Also, plan mode and deny rules only cover what the CLI asks permission for; anything its own settings let it do without asking is not checked.
|
|
||
| // With a cached model list the CLI waits for the first turn. Without one it is asked now, and only | ||
| // when it is installed, so a machine without it logs nothing. | ||
| if (known.length > 0 || !Bun.which("agy")) return |
There was a problem hiding this comment.
@opencode/core also runs under Node and workerd (see the imports conditions in its package.json). Every other Bun-only call sits behind a .bun.ts variant. Under Node, Bun.which throws a ReferenceError the first time this runs with no saved model list, and the plugin fails to load. which from src/util/which.ts does the same job on every runtime. Along the same lines, acp.ts imports node:child_process directly, while the Claude Agent provider keeps its SDK behind a workerd stub (#claude-agent-sdk).
There was a problem hiding this comment.
Launching unmodified agy acp interactively is permitted only in a thin client where Antigravity is the agent — meaning the human sends raw prompts directly to agy acp and Antigravity owns its sign-in, system prompt, tools, and session history. Wrapping agy acp inside an outer third-party coding agent harness (such as OpenCode) that injects system instructions, serialized tool definitions, replayed cross-model context, or automated loops is not permitted on oauth-personal — even without extracting OAuth tokens — and risks automated enforcement or suspension.
Maintainer would need to get Google permission like it is done with claude sdk
OpenCode runs the Antigravity CLI on the user's machine and talks to it over the Agent Client Protocol, the way the Claude Agent provider runs Claude Code and talks to it through Anthropic's Agent SDK. The CLI's `agy acp` runtime is used, not its print mode: Google's Antigravity FAQ says wrapping `agy -p` inside a third-party coding agent is not supported on consumer plans, and section 6 of the Antigravity Additional Terms says using third-party software to access the Service is a breach. The unmodified `antigravity-acp` runtime with native `oauth-personal` sign-in is the integration Google names as usable for single-user interactive development. - The model list comes from the account, so it is never written down here. - The CLI names the reasoning effort in the model, so one model is registered per model with the effort levels as variants, the same shape the Claude Agent provider uses. - The agent runs its own tools, reported as provider-executed calls; a permission request is refused unless the host answers it. - The CLI is started on first use, and the model list is kept between starts so the picker has the models before the CLI answers. Refs anomalyco#28889
- Report each agent tool call once: a call keeps the name it first had and is emitted with its result when it completes or fails, so repeated tool_call_update events no longer stop the turn as duplicates. Calls still running when the turn ends are settled as incomplete. - Map the CLI's stop reason to the finish reason (max_tokens and max_turn_requests to length, refusal to content-filter, cancelled to other). - Give each OpenCode session its own CLI session, closed on session.deleted, and switch it to the picked model and effort level before each turn. Titles and other side requests run in a throwaway CLI session. Turns in a session are serialized, and a dead CLI is replaced on the next turn. - Answer the agent's permission requests from OpenCode's permission rules for the session and agent running the turn. - Start the CLI on first use when a model list is cached, close it when the plugin scope ends, and only probe for models at startup when agy is on PATH. The provider transform reads the current list, so a reload shows models the CLI reports later. - Trim comments that restated the code, and correct the docs and spec. Claude-Session: https://claude.ai/code/session_015bbujzQVqzVf6YWBFb95JT
`Bun.which` threw a ReferenceError under Node the first time the plugin ran without a cached model list; use the cross-runtime `which` helper instead. The ACP client, which spawns the CLI with `node:child_process`, now sits behind the `#antigravity-acp` import with a workerd stub and is loaded on first use, the way the Claude Agent SDK is. Claude-Session: https://claude.ai/code/session_015bbujzQVqzVf6YWBFb95JT
038fdc4 to
00abed1
Compare
There was a problem hiding this comment.
The Node/workerd point is fixed: Bun.which is replaced with the repo's own which(), and the code that spawns the CLI is now loaded on first use behind #antigravity-acp, with a workerd stub, the same way #claude-agent-sdk works. The 18 unit tests pass and typecheck:tsc is clean. I still couldn't run it end to end (it needs the Antigravity CLI and a Google account).
The public API is the same as before: it adds the antigravity provider ID and a built-in provider that turns on automatically (backwards compatible). The new #antigravity-acp entry in @opencode/core's imports is internal.
Nothing new to flag. Still open: a maintainer needs to decide on #28889 whether driving agy acp is acceptable.
|
@thdxr uh merge pls |
|
Hello, a quick check-in: While waiting for the merge, i cloned the fork and my agent spotted that the prompt implementation is text only. I did not verify as I instructed the agent to fix it right after. Can confirm antigravity is working with the fork, you might need to fix images ingestion. Edit 1: The context token calculator is broken for ACP tool calls (it treated tool calls as a new turn and compound cached token as total context, so the app keep compacting). This would need to be fixed in both the cli and the desktop app. I did have a working fix but quality is not ensured since it was AI generated so not submitting a PR. Just a head up for everyone. |
…vider-acp # Conflicts: # packages/core/src/plugin/provider.ts
|
Thanks @gnadlr, both reports check out. Here's what I found in the code: Images are dropped. Context size is overcounted, so it keeps compacting. The provider reports the I'll look at fixing both on this branch. Also merged the latest |
…count The prompt sent to the agent was text only, so attached images were dropped. Image parts now go as ACP image content when the agent accepts them, and the models advertise image input. The turn's ACP usage sums every model request the agent made, one per tool call, so OpenCode read it as a context many times too large and kept compacting. The context size now comes from the agent's usage_update.
|
Both are fixed in 495c8c3. Images: image parts of the user's message now go to the agent as ACP image content when it says it accepts them ( Context / compaction: the provider no longer reports the turn's summed usage as input. It takes the context size from the agent's Thanks again for the report, @gnadlr. |
|
Please merge this |
|
One more bug found: the session cannot send a "steer" message (even if the agent turn has finished chatting and only waiting for script running). It seems that connecting via ACP mean that you cannot inject a message during agent turn. Also, a cmd window pop up when initiate a conversation (closing it meaning closing the ACP connection and end the session immediately, cannot resume). I'm not sure it is because ACP does not allow it, or because current implementation. You can take a look. In Desktop UI, Orchestrator models show only 1 levels (carbon, neon,..) and thinking level not shown. In AGY, it show 2 level (model, then thinking level). This might be UI limitation |
|
Tested this on Windows with a local backport onto v2.4.3, the official 1. Console windows on Windows Adding 2. Follow-up continuity after a reload or provider switch As far as I can tell, the provider only sends the latest user prompt and keeps the ACP conversation mapping in memory. After a server restart, or after switching to another provider and back, the agent loses earlier context. I tested a change that restores a bounded, role-tagged history of user and assistant turns in two cases:
It does not replay old tool calls. What I verified:
Limits:
If it helps review, I can split these into two small patches, one for |
|
Looks like official Google OAuth announcement is imminent, but limited to Ultra ($100+) tier subs. 💀 Pure greed. |
Issue for this PR
Refs #28889 — the design question is asked there, and this is the implementation of the ACP route that question is about.
This replaces #65430, which was closed as bundling two unrelated changes; this one is only the Antigravity provider.
Type of change
What does this PR do?
Adds a built-in
antigravityprovider: OpenCode runs the Antigravity CLI on the user's machine and talks to it over the Agent Client Protocol, the way the Claude Agent provider runs Claude Code and talks to it through Anthropic's Agent SDK.Why the ACP runtime and not the print mode. The Antigravity CLI has two headless surfaces, and only one of them may be driven by another program.
agy -pis print mode, and Google's own FAQ says wrapping it inside a third-party coding agent "is not supported under consumer plans" — the Antigravity team has said it "violates Section 6 … and can trigger automated account suspension" of the Antigravity Additional Terms.agy acpis the unmodifiedantigravity-acpruntime, which Google names as usable for single-user interactive development with nativeoauth-personalsign-in. This provider drivesagy acpand neveragy -p. That is the difference between this and the requests that were closed as not planned.The model list is discovered, not pinned. The CLI reports the models the signed-in account may use when it opens a session, and OpenCode registers exactly those, so a model Google adds shows up without a change here. The CLI names the reasoning effort as part of the model —
gemini-3.8-flash-high,-mediumand-loware one model at three effort levels — so one model is registered per model, with the effort levels as variants, the same shape the Claude Agent provider uses.Sessions and models. Each OpenCode session gets its own CLI session, closed on
session.deleted, and the CLI session is switched (session/set_model) to the model and effort level the user picked before each turn. Titles and other side requests run in a throwaway CLI session. Turns in one session are serialized, and if the CLI exits the next turn starts a new one.Tools and permissions. The agent runs its own tools and reports them as tool calls. OpenCode surfaces each one as a single provider-executed call and result, emitted when the call completes or fails, so the run shows what the agent did, but OpenCode does not run them: it has no tools with those names. When the agent sends
session/request_permission, OpenCode checks it against the session's permission rules for the agent running the turn (asking the user when a rule says to): edit/delete/move map toedit, execute tobash, read toread, search togrep, fetch towebfetch. So plan mode and deny rules apply to what the agent asks about; what it asks about is set by the CLI's own permission settings.Startup. The model list is kept between starts. With a kept list the CLI is not started until the first turn; with none, it is asked for the list at startup only if
agyis onPATH, so machines without it start silently. The CLI is closed when the plugin scope ends.How did you verify your code works?
bun run checkpasses (lint and typecheck).bun test test/plugin/provider-antigravity.test.tspasses (18 tests): tool calls reported once acrosstool_call/tool_call_update, failed and incomplete calls, finish-reason mapping, one CLI session per OpenCode session withset_modelonly on a change, throwaway sessions for side requests, close on delete, replacing a dead CLI, permission mapping and option choice, and the grouping rules (three effort levels become one model with three variants; a single-level model keeps the CLI's name and has no variants; the suffix rule, soclaude-opus-4-6-thinkinggroups underclaude-opus-4-6whileclaude-sonnet-4-6does not), the slug resolution, and the stream parts for a message, a tool call and a failed tool call.Against the real CLI (Antigravity 1.5.14, a Google AI Pro account) the provider connects, opens a session, reports the account's models, and runs a turn:
The adapter's own stream, through the same session, produces the text and the finish part with the CLI's stop reason and usage.
The session layer against the same CLI: a
read_fileturn produced exactly one tool call and one tool result, a second turn in the same OpenCode session remembered the first, and a shell command whose permission check was denied (agentplan, actionbash) was refused by the CLI and the file was not created.Not tested: a full opencode run against a ChatGPT-signed-in account is not what this is; what is not tested is the provider inside a running opencode server, which needs a build of this branch.
Screenshots / recordings
Not a UI change.
Checklist
Added by the opencode bot (AI-generated).
Related: #65419, #28889, #53530
Public API: adds the
antigravityprovider ID and a built-in provider that turns on automatically (backwards compatible)