The Stop hook runs when a Google Antigravity turn ends, which makes it the place for a "finished" alert, a final check, or an automatic next step. It gets JSON on stdin with terminationReason, fullyIdle, executionNum and the path to the conversation's transcript, but not Antigravity's last message: read that from transcript_full.jsonl. A Stop hook can also answer {"decision":"continue","reason":"..."} to start a new turn on the reason. continuationActive stays false after that, so a hook that always continues will loop unless it keeps its own count.
01A minimal Stop hook
Add a named group to ~/.gemini/config/hooks.json. Stop takes its handlers directly, without a matcher:
{
"my-alerts": {
"Stop": [
{ "type": "command", "command": "/Users/me/bin/agy-done.py", "timeout": 10 }
]
}
}
There is no trust step: the hook runs from the next session you start. If another tool already has a group in the file, add yours beside it. Every group's Stop hooks run.
02What the hook receives
A real Stop payload from agy 1.5.18, trimmed:
{
"hookEventName": "Stop",
"conversationId": "32fc0aec-d58e-47c7-b08c-f489e3a4644a",
"cwd": "/Users/dev/projects/demo",
"transcriptPath": "/Users/dev/.gemini/antigravity-cli/brain/32fc0aec-d58e-47c7-b08c-f489e3a4644a/.system_generated/logs/transcript_full.jsonl",
"lastUserInput": "Run the shell command 'echo first-step' and tell me what it printed.",
"terminationReason": "NO_TOOL_CALL",
"fullyIdle": true,
"executionNum": 0,
"continuationActive": false
}
terminationReasonsays why the turn ended.NO_TOOL_CALLis what an ordinary finished turn sent in our tests.fullyIdletells you whether Antigravity is fully idle. Our own hook stays quiet while it isfalse, treating that as background tasks still running.executionNumnumbers the execution. Use it withconversationIdto recognise a turn you've already handled.continuationActiveis meant to say a hook continued the turn. In practice it staysfalse, so don't rely on it.lastUserInputis your last prompt, handy for the alert's text.
Google's documentation describes this payload differently in places; the fields above are what the command line actually sent when we tested it.
03Reading the last message
The payload doesn't include what Antigravity said. It is in the transcript at transcriptPath, one JSON object per line. The last line with "type": "PLANNER_RESPONSE" and a content field is the final message (earlier PLANNER_RESPONSE lines are tool calls with no content).
04A script with the project name and message
This Python script shows a desktop notification with the folder name and the start of the last message:
#!/usr/bin/env python3
# agy-done.py: a Stop hook for Google Antigravity
import json, os, subprocess, sys
def last_message(path):
text = ""
try:
with open(path, encoding="utf-8") as f:
for line in f:
try:
step = json.loads(line)
except ValueError:
continue
if step.get("type") == "PLANNER_RESPONSE" and step.get("content"):
text = step["content"]
except OSError:
pass
return " ".join(text.split())[:150] or "Finished"
try:
event = json.load(sys.stdin)
title = "Antigravity: " + os.path.basename(event.get("cwd", ""))
body = last_message(event.get("transcriptPath", ""))
if sys.platform == "darwin":
script = 'display notification "%s" with title "%s"' % (
body.replace('"', "'"), title.replace('"', "'"))
subprocess.run(["osascript", "-e", script], capture_output=True)
elif sys.platform.startswith("linux"):
subprocess.run(["notify-send", title, body], capture_output=True)
except Exception:
pass
print("{}")
Make it executable with chmod +x agy-done.py and use its full path as the command. It covers Mac (osascript) and Linux (notify-send, part of libnotify on most desktops). On Windows you would add a branch that shows a toast through PowerShell; we haven't tested agy on Windows yet, so check that the hook fires there before you depend on it.
The script prints {} and exits 0 on every path. Unlike PreToolUse, a Stop hook has no decision to make, and an empty answer lets the turn end normally.
05Making Antigravity continue
A Stop hook can give Antigravity its next instruction. Print this:
{ "decision": "continue", "reason": "Run the test suite once more and fix anything that fails." }
Antigravity starts a new turn on the reason, as if you had typed it. That new turn ends with another Stop, and your hook runs again.
Here is the trap. Antigravity's continuationActive stays false after a continue, so a hook that checks it to avoid repeating itself never sees true, and a hook that always continues keeps Antigravity working indefinitely. Keep your own record instead:
- Store the
conversationIdandexecutionNumof each turn you continued, in a small file. - Continue at most once (or a fixed number of times) per conversation, or only when a concrete check fails.
- Never continue when the turn was stopped by you.
Make the condition concrete. "The tests fail" (checked by running them in cwd) is a good reason to continue. "Keep improving" is not.
06Common mistakes
- Expecting the message in the payload. It's in
transcript_full.jsonl, not on stdin. - Trusting
continuationActive. It staysfalse. Count continues yourself. - Slow commands. Antigravity waits for the hook. Keep
timeoutshort for an alert, and don't make network calls without a timeout of their own. - Editing the file mid-session. The current session keeps the hooks it started with. Start a new one.
- Assuming one alert per task.
Stopfires at the end of each turn, so a long conversation gives one per reply.
07Replies from your phone
Antigravity Notifier uses the same mechanism. When a turn ends while you're away, its Stop hook sends "Antigravity has finished" with the last message to your iPhone or Android phone, at most once per turn, and nothing when you stopped the turn yourself. It then waits briefly (two minutes by default, stop_hold_seconds, 0 turns it off) so you can type the next instruction on the phone, which it returns as the continue reason, at most once per turn. It is independent and not made by Google; the antigravity-notifier tool is free for Mac, Windows (beta) and Linux.
08FAQ
Does the Stop hook fire in agy -p?
Hooks load in print mode too, so a Stop hook is a simple way to learn that a scripted run has finished. See running agy -p in scripts.
Why does my Stop hook keep Antigravity running forever?
It answers continue every time, and continuationActive never turns true to stop it. Record which turns you have continued and stop after one.
Can the Stop hook see what Antigravity changed?
Not directly. It gets cwd, so your script can run git diff --stat there. The transcript also lists the tool calls of the turn.
Is there an event for "Antigravity needs approval"?
No. Antigravity has no notification or permission event. A hook sees a command before it runs through PreToolUse.
Does the Stop hook run for the desktop app?
The desktop app reads the same ~/.gemini/config/hooks.json, but we have only tested the agy command line. Check it yourself before relying on it there.