Repository navigation
feat(agent-hook-plugin): add Antigravity (app and agy CLI) as a host adapter - #7710
fancyboi999 wants to merge 4 commits into
Conversation
…adapter Antigravity runs PreInvocation before every model call, so recall runs only on a turn's first call (invocationNum 0), deduplicated per turn. Context returns as an injectSteps system message. Stop carries no text: capture reads the finished steps of transcriptPath after the last captured step, in a detached worker, and commits. Sessions are ag-. Refs volcengine#7709
|
I found a content-loss case at For example, these finished transcript steps: {"step_index":0,"status":"DONE","source":"USER_EXPLICIT","type":"USER_INPUT","content":"Explain the USER_REQUEST transcript envelope."}
{"step_index":1,"status":"DONE","source":"MODEL","type":"PLANNER_RESPONSE","content":"The transcript wraps your prompt like this:\n<USER_REQUEST>your prompt</USER_REQUEST>\nKeep the following metadata separate from the request."}cause the real I checked the requests at a loopback HTTP server, then invoked Stop again: Could the Validation: the existing Antigravity, agent-hook-runtime and import-history tests passed ( |
…input Assistant replies that quote the host's request envelope were reduced to the quoted text, or dropped when the quote was an empty template, and the capture cursor had already moved past them. Unwrap only a USER_INPUT record whose content opens with the envelope; assistant text and the recall prompt only lose injected openviking-context blocks.
|
Thanks, confirmed and fixed in fc72865.
Re-checked on a real agy 1.5.9 session against OpenViking 0.5.0. The prompt and the reply both contained |
|
Thanks for the fix. I re-ran the independent probe against I also checked nested tags inside a wrapped user request, an assistant reply beginning with This was AI-only validation on macOS/Node 26 through the real Stop hook with synthetic transcripts and a loopback HTTP server; I did not run Antigravity/agy or a real OpenViking deployment. |
… wakeups When a background task, subagent reply, timer, or Stop continuation wakes an Antigravity turn, PreInvocation runs again with invocationNum 0, a higher initialNumSteps, and lastUserInput still holding the earlier prompt. Keying prompt_id by initialNumSteps bypassed promptEventId deduplication and re-injected the cached recallBlock into the trajectory on every wakeup. Resolve the active user turn from transcriptPath instead: skip recall when a MODEL step has already run since the latest USER_EXPLICIT USER_INPUT step, and key prompt_id by that user step (step_index + 1) so each user turn injects once while still recalling on genuine repeated prompts.
…l steps Backgrounded run_command steps (MODEL/GENERIC with status RUNNING) and failed or invalid tool steps (ERROR, INVALID) stay non-DONE permanently in Antigravity transcripts. Breaking on every non-DONE step froze lastStep before all subsequent turns in that conversation. Advance lastStep past non-captured step types regardless of status. On captured turn records (USER_EXPLICIT USER_INPUT and PLANNER_RESPONSE), hold the cursor only while the step is in progress (PENDING, QUEUED, WAITING, RUNNING, GENERATING), and skip terminal non-DONE records (CANCELED, ERROR, INVALID, ...) without blocking later turns.
Description
Adds Antigravity as a host of the shared
agent-hook-plugindispatcher. One plugin covers both the Antigravity desktop app and theagyCLI, because both load plugins from~/.gemini/config/plugins/. Before this change, Antigravity sessions neither recalled OpenViking memory nor added to it. After it:Sessions are
ag-<conversationId>.The entry point is
scripts/hook.mjs <session-start|pre-invocation|stop> antigravity. The owner module isexamples/agent-hook-plugin/hosts/antigravity.mjs. The Antigravity hook contract was taken from real hook stdin and transcript files, not inferred; see #7709.PreInvocationbefore every model call, including each one in a tool loop (invocationNum> 0) and each reactive wakeup for a background task, subagent message, orStopcontinuation (invocationNum0 with a higherinitialNumStepsand the earlierlastUserInput). Recall runs only wheninvocationNumis 0 and noMODELstep has run since the latestUSER_INPUTstep intranscriptPath, keyed byconversationId:(userStepIndex + 1)so each user turn injects once while genuine repeated prompts still get their turn injection.{"injectSteps":[{"systemMessage":{"systemMessage": ...}}]}. Pass-through writes{}.Stophas no message text. Capture readstranscriptPath(transcript_full.jsonl) after the last capturedstep_index. It keeps onlyUSER_INPUTfromUSER_EXPLICIT(the text inside<USER_REQUEST>) andPLANNER_RESPONSEtext. Non-captured step types (such as backgroundedGENERICtool steps that keepRUNNING, orERROR/INVALIDtool steps) advance the cursor without blocking capture; on captured turn records, an in-progress status (PENDING,QUEUED,WAITING,RUNNING,GENERATING) holds the cursor for the nextStop, while terminal non-DONErecords (CANCELED,ERROR, …) are skipped. Tool output and injectedSYSTEM_MESSAGEsteps are never captured, and<openviking-context>blocks are stripped. The cursor moves only when every kept message was sent or queued.This supersedes #4069, which no longer fits the #4773
hosts/<host>/layout and uses the deprecatedephemeralMessagestep.Human Involvement
Related Issue
Closes #7709
Type of Change
Changes Made
hosts/antigravity.mjs: the adapter (event map, envelope, input normalisation, transcript capture).hosts/antigravity/{hooks.json,plugin.json}: the Antigravity plugin template. It uses the same__OPENVIKING_PLUGIN_ROOT__/__OPENVIKING_CLIENT_ID__placeholders as the other hosts.hosts/index.mjs,import-history.mjs: registerantigravity(ag-live ids). The existing import-history contract test iterates every registered host and requires this entry.install.sh: addantigravitytoAGENT_HOOK_HOSTSonly, so other hosts' installs do not carry its directory.--harness antigravityis left for a follow-up PR.agent-hook-pluginto 0.5.32 with the host manifests, ascheck-plugin-version-bumps.shrequires.tests/antigravity.test.mjs: the hooks.json shape, plus an end-to-end contract test against a mock server. It covers recall once per turn across concurrent calls, tool loops, and reactive wakeups (while allowing repeated user turns); capture of only user and assistant text past non-DONEtool steps andCANCELEDdrafts; and incremental capture that pauses on an in-flight turn step and resumes onceDONE.config-schema.mjsHARNESS_KEYSis intentionally unchanged. Addingantigravitythere regenerates the shared copies in the Claude Code and Codex plugins and forces their version bumps. Defaults work without it, so it can land with the installer PR.Testing
Commands run on macOS, Node 26:
node --test examples/agent-hook-plugin/tests/*.test.mjs examples/memory-plugin-shared/*.test.mjs(CI's set without the installer tests)install-tui.test.mjs› "what was asked for but not installed is listed again just before the onboarding link". It fails the same way onmain(00c8e7b) without this change.node --test --test-concurrency=1 install-agent-hooks.test.mjs release-marketplace.test.mjsbash .github/scripts/check-plugin-version-bumps.sh origin/mainnode examples/memory-plugin-shared/sync.mjsand thengit statusbash -n examples/memory-plugin-shared/install.shnode docs/scripts/check-docs-consistency.mjsinvocationNumgate, or theDONEstatus check, makes the new contract test failReal hosts, against OpenViking server 0.5.0. The plugin was installed with the documented manual steps from this branch.
promptEventIdandlastStep. The server sessionag-…holds 2 messages, and itssession_committask completed.session_commitcompleted). This app run used an earlier local build of the same adapter logic (same event handling, recall gate, transcript parsing and cursor). This branch's final form was re-verified on agy, which loads the same plugin directory.Not covered: Linux and Windows; the installer path (no
--harness antigravityyet).Checklist