The Google Antigravity Python SDK is the agent runtime behind Antigravity 2.0 and the Antigravity CLI, packaged for Python. You script the agent instead of chatting with it, and you keep the built-in file and terminal tools.
In this Antigravity SDK tutorial, pip install google-antigravity goes into a uv project, a first agent debugs a small repo, and then you add a custom tool, a git MCP server, a skill, a screenshot and a two-agent triage and fix pipeline. Built and run on Ubuntu 26.04 in November 2026 with google-antigravity 0.1.24, auth errors included.
Know where the SDK fits
Google’s SDK launch post says it plainly: “The SDK gives you the same agent runtime that powers Antigravity 2.0 and the Antigravity CLI.” The app, the IDE and the CLI are front ends for a person. The SDK is the same loop with no front end, driven from your code.
| Surface | Who drives it | Auth | Use it for |
|---|---|---|---|
| Antigravity App and IDE | You, in a window | Google account sign-in | Interactive coding with an agent manager |
| Antigravity CLI | You, in a terminal | Google account, API key or ADC | Agent sessions over SSH or in scripts |
| Antigravity SDK | Your Python code | API key, Vertex AI or a local model | Pipelines, bots, CI jobs, custom tools |
Hooks, subagents and safety policies behave the same across the SDK, the CLI and Antigravity 2.0, according to that post, so a policy you test in Python carries over. If you only want an agent in your shell, the Antigravity CLI install guide is the faster route, and the Antigravity CLI cheat sheet covers its flags. The SDK is still a Research Preview with an Alpha classifier on PyPI, so pin the version in anything you ship.
Install the Antigravity SDK with pip
Install the google-antigravity pip package from PyPI, not from a git clone. The wheel carries a compiled Go runtime called localharness plus generated protobuf modules, and neither lives in the GitHub repo. Cloning and running pip install . looks fine until the first import:

No bin/ directory and no proto package means the clone is source only. The README says the same thing: always install from PyPI. Because there is no sdist either, only six platform wheels for Linux, macOS and Windows on x86_64 and arm64, pip cannot build the package on any other platform, so a 32-bit board is out. The Linux wheels carry both manylinux and musllinux tags, so Alpine on x86_64 or arm64 is fine. The package needs Python 3.10 or newer.
A uv project keeps the SDK and its dependencies out of the system Python. On Ubuntu 26.04, uv comes in through pipx:
sudo apt install -y pipx
pipx install uv
pipx ensurepath
Open a new shell so ~/.local/bin is on your PATH, then create the project and add the package. uv downloads its own CPython 3.13 if the system doesn’t have it:
uv init --python 3.13 ag-agent
cd ag-agent
uv add google-antigravity
The whole resolve and install took about 3 seconds on the lab VM. Check the version and confirm the runtime binary landed inside the venv:
uv pip show google-antigravity
ls -la .venv/lib/python3.13/site-packages/google/antigravity/bin/
du -sh .venv
The localharness file is the agent runtime, about 137 MB on its own, which is why the venv weighs 182 MB:

On x86_64 the binary needs a CPU with AVX (GitHub issue #147). Old virtual CPU models such as kvm64 hide that flag from the guest, so the runtime dies on a perfectly healthy host. Check with grep -c avx /proc/cpuinfo, and if it prints 0, set the VM’s CPU type to host or a modern model before you blame the SDK.
Pick an auth method
The SDK has no Google-account login. That flow belongs to the app and the CLI. LocalAgentConfig talks to Gemini in one of three ways, and LocalOpenAIAgentConfig points the same agent at any OpenAI-compatible endpoint:
- Gemini Developer API: export
GEMINI_API_KEYor passapi_key=. - Vertex AI with Application Default Credentials:
vertex=Trueplusprojectandlocation, or theGOOGLE_GENAI_USE_VERTEXAI,GOOGLE_CLOUD_PROJECTandGOOGLE_CLOUD_LOCATIONvariables. - Vertex AI express mode:
vertex=Truewith an express-mode API key. - A local model:
LocalOpenAIAgentConfig(model=..., base_url=...), for example Ollama on port 11434.
The default model in this release is gemini-4-hydrogen. Three of the four paths failed on the lab project before a single token came back, and the errors are worth knowing because they don’t say what to do.
Error 403: Permission ‘aiplatform.endpoints.predict’ denied
This is Vertex through ADC on a GCE VM whose default service account has no Vertex role. The SDK raises AntigravityConnectionError with the IAM reason at the end:
google.antigravity.types.AntigravityConnectionError: Agent execution terminated due to error. ("agent executor error: Error 403, Message: Permission 'aiplatform.endpoints.predict' denied on resource '//aiplatform.googleapis.com/projects/your-gcp-project-id/locations/global/publishers/google/models/gemini-4-hydrogen' (or it may not exist). ... Status: PERMISSION_DENIED, Details: [... reason:IAM_PERMISSION_DENIED]]
“Or it may not exist” is a red herring here, because the model is there and the principal simply has no permission to call it. The fix is IAM, not code: grant the service account roles/aiplatform.user on the project, which carries aiplatform.endpoints.predict. A VM on the default access scopes will still lack the cloud-platform scope, so check both before you start changing the SDK config.
Error 402: Your prepayment credits are depleted
A fresh Gemini API key on a project with prepaid billing at zero returns this before the agent takes a single step:
google.antigravity.types.AntigravityExecutionError: Error 402, Message: Your prepayment credits are depleted. Please go to AI Studio at https://ai.studio/projects to manage your project and billing. Learn more at https://ai.google.dev/gemini-api/docs/billing#prepay. , Status: RESOURCE_EXHAUSTED
The key itself is valid, so regenerating it changes nothing. The 402 is about the project’s billing state, which means every key from that project fails the same way until you add credit in AI Studio or switch to a key from a project that is still on the free tier. The status string says RESOURCE_EXHAUSTED, so a retry loop that treats it like a rate limit will spin forever.
Error 401: API keys are not supported by this API
A standard Google Cloud API key restricted to aiplatform.googleapis.com is not an express-mode key, and Vertex answers with “Expected OAuth2 access token or other authentication credentials that assert a principal.” Use ADC for standard Vertex, or create the key from the Vertex express-mode page.
The fourth path worked first time, so every run in this guide uses Gemma 4 26B served by Ollama on the same VM. Switching to Gemini later is one environment variable. Install Ollama, pull the model and raise the context window, because every model call carries a few thousand tokens of system prompt and tool schemas before the conversation itself:
sudo snap install ollama
ollama pull gemma4:26b
sudo snap set ollama context-length=32768
sudo snap restart ollama
The model is 18 GB on disk, and on a 32 vCPU VM with no GPU every run below took minutes, not seconds. The lab ran at 32K context. The SDK README recommends 64K for its own local Gemma 4 setup, and .lightweight() only compacts the conversation at 65,536 tokens, so set context-length=65536 if you have the memory, or long runs get truncated by Ollama before the SDK ever compacts them. Now create a small helper that picks the backend, so the rest of the scripts don’t care which one you use:
vim backend.py
Gemini wins when a key or Vertex is configured. Otherwise the agent goes to Ollama with the .lightweight() preset, which trims the tool list and the system prompt for small-context local models:
import os
from google.antigravity import LocalAgentConfig, LocalOpenAIAgentConfig
def make_config(**kwargs):
"""Gemini when a key or Vertex is configured, local Gemma 4 through Ollama otherwise."""
if os.environ.get("GEMINI_API_KEY") or os.environ.get("GOOGLE_GENAI_USE_VERTEXAI"):
return LocalAgentConfig(model="gemini-4-hydrogen", **kwargs)
return LocalOpenAIAgentConfig(
model="gemma4:26b",
base_url="http://localhost:11434/v1",
**kwargs,
).lightweight()
Every keyword you pass to make_config() lands in the config object, so tools, MCP servers, skills and policies all go through the same call. One catch: the helper only checks that GOOGLE_GENAI_USE_VERTEXAI is set, while the SDK turns Vertex on only for true or 1, so unset it rather than setting it to false.
Create a demo repo and issue tracker
The agents need something to work on: a small git repo with a real regression, a tracker entry for it and the customer’s screenshot. Every script in this guide uses absolute paths under /home/joshua/ag-agent, so replace joshua with your user name when you copy them. From inside ag-agent, create the folders and the repo:
mkdir -p demo-repo tracker
cd demo-repo
git init -b main
Start with the correct version of the invoice code. The agents only ever see this repo, so the file and its two commits are all the evidence they get.
vim invoice.py
The discount is a whole-number percentage, so it gets divided by 100:
def apply_discount(total: float, percent: float) -> float:
"""Return total after a percentage discount."""
return total - total * percent / 100
def invoice_total(lines: list[tuple[str, int, float]], discount: float = 0) -> float:
subtotal = sum(qty * price for _, qty, price in lines)
return round(apply_discount(subtotal, discount), 2)
Add two tests next to it. They give the fix agent, and you, a pass or fail signal that doesn’t depend on trusting the model’s own summary.
vim test_invoice.py
The second test is the one the bug breaks, since it expects 10% off 100.00 to leave 90.00:
import unittest
from invoice import invoice_total
class InvoiceTest(unittest.TestCase):
def test_no_discount(self):
self.assertEqual(invoice_total([("disk", 2, 50.0)]), 100.0)
def test_ten_percent(self):
self.assertEqual(invoice_total([("disk", 2, 50.0)], discount=10), 90.0)
if __name__ == "__main__":
unittest.main()
Commit the good version, then break it in a second commit the way a careless cleanup would. If git has no identity on this machine yet, set user.name and user.email with git config first, or the commit is refused:
git add .
git commit -m "Add invoice totals with percentage discount"
sed -i 's|a percentage discount|a discount (percent given as a whole number)|; s|percent / 100|percent|' invoice.py
git commit -am "Simplify discount math"
python3 -m unittest
The test run now ends with AssertionError: -900.0 != 90.0 and FAILED (failures=1). That regression is what every agent below hunts, and because it sits in the latest commit, the git history alone is enough to find it. Your commit SHAs will differ from the ones in the runs below, since git hashes your name and the commit time. Go back up to ag-agent and create the tracker entry:
cd ..
vim tracker/issues.json
It holds one issue, keyed by its number as a string. The custom tool later in the guide looks issues up by that key, so keep it a string even though the model will pass a number.
{
"14": {
"title": "Discount makes invoice negative",
"reporter": "[email protected]",
"labels": ["billing", "customer-reported"],
"body": "Customer INV-2026-0412 was billed -900.00 instead of 90.00 after a 10% discount. Screenshot attached. Started after Monday's release.",
"attachment": "invoice-INV-2026-0412.png"
}
}
The screenshot is drawn with Pillow, so you get the same picture the lab used and the agents read the same numbers off it.
vim make_screenshot.py
It renders a fake invoice with the wrong discount and total on it. The -1000.00 discount line is the clue the image step reads back, so leave the numbers as they are if you want output that matches the runs below.
from PIL import Image, ImageDraw, ImageFont
img = Image.new("RGB", (900, 420), "white")
d = ImageDraw.Draw(img)
big = ImageFont.load_default(size=34)
mid = ImageFont.load_default(size=24)
d.rectangle([0, 0, 900, 70], fill="#1f3a5f")
d.text((30, 18), "Acme Billing | Invoice INV-2026-0412", font=mid, fill="white")
rows = [("Item", "Qty", "Price"), ("disk", "2", "50.00")]
y = 100
for item, qty, price in rows:
d.text((40, y), item, font=mid, fill="black")
d.text((420, y), qty, font=mid, fill="black")
d.text((620, y), price, font=mid, fill="black")
y += 45
d.line([40, 200, 860, 200], fill="#999999", width=2)
d.text((40, 220), "Subtotal", font=mid, fill="black")
d.text((620, 220), "100.00", font=mid, fill="black")
d.text((40, 265), "Discount (10%)", font=mid, fill="black")
d.text((620, 265), "-1000.00", font=mid, fill="black")
d.text((40, 330), "TOTAL DUE", font=big, fill="black")
d.text((600, 330), "-900.00", font=big, fill="#c0392b")
img.save("/home/joshua/ag-agent/tracker/invoice-INV-2026-0412.png")
uv run --with pillow pulls Pillow in for this one run without adding it to the project:
uv run --with pillow python make_screenshot.py
ls -la tracker/
The listing should show issues.json and a 22 KB invoice-INV-2026-0412.png. That is everything the scripts below read.
Run your first agent
The first agent only needs the repo. Create the script next to backend.py:
vim first_agent.py
The workspace pins the agent to the repo, and policy.allow_all() lets it run shell commands without asking. The loop prints each tool the agent called, then the answer and the token count:
import asyncio
import time
from google.antigravity import Agent
from google.antigravity.hooks import policy
from backend import make_config
async def main():
config = make_config(
workspaces=["/home/joshua/ag-agent/demo-repo"],
policies=[policy.allow_all()],
)
start = time.monotonic()
async with Agent(config) as agent:
response = await agent.chat(
"Run `ls` in the workspace, then run the unit tests with "
"`python3 -m unittest -v` and tell me which test fails and why."
)
async for call in response.tool_calls:
print(f"[tool] {call.name}")
print(await response.text())
usage = agent.conversation.total_usage
print(f"tokens: prompt={usage.prompt_token_count} "
f"output={usage.candidates_token_count} "
f"total={usage.total_token_count} "
f"wall={time.monotonic() - start:.0f}s")
if __name__ == "__main__":
asyncio.run(main())
Run it with uv so the project venv is used. On a CPU-only box give it a couple of minutes, because every model call runs on Gemma locally and the script only prints the token totals once the whole run is done. The lab run took 104 seconds.
uv run python first_agent.py
Two run_command calls, the failing test named, and the real assertion quoted back:

That run cost 11,506 tokens and 104 seconds on CPU, and only 272 of those tokens were output. total_usage is cumulative, so the 11,234 prompt tokens are the sum of every model call in the run, and each call resends the system prompt, the tool schemas and everything said so far. Even a two-command task pays that overhead several times over. The model also invented “a disk costing 50.0” when the test has two disks at 50.0, which is why the answer is worth reading against the raw assertion it quotes. Treat an agent summary the way you would treat a junior engineer’s notes: useful, usually right, and checked.
Why the default policy refuses run_command
Drop the policies= line and the agent falls back to confirm_run_command, the default for local agents. It denies shell commands and allows every other tool. The same prompt then goes badly:

The denied agent kept retrying and burned 21,550 tokens over 408 seconds, nearly twice the tokens and four times the time of the run that worked. A denied tool stays visible to the model, so it keeps reaching for it. If an agent should never run commands, remove the tool with capabilities=types.CapabilitiesConfig(disabled_tools=[...]) instead of denying it with a policy.
Add a custom Python tool
Any typed Python function with a docstring can be a tool. The SDK builds the schema from the signature, and the docstring is what the model reads to decide when to call it. This one reads an issue from a JSON tracker file:
vim tracker_tool.py
Return a string. JSON text is fine, and the model parses it without help:
import json
import pathlib
TRACKER = pathlib.Path("/home/joshua/ag-agent/tracker/issues.json")
def get_issue(number: int) -> str:
"""Return the title, labels, body and attachment name of a tracker issue."""
issue = json.loads(TRACKER.read_text()).get(str(number))
return json.dumps(issue) if issue else f"Issue {number} not found."
Pass the function itself in tools=. No decorator, no registration step:
vim tool_agent.py
This time the loop prints the arguments too, so you can see exactly what the model sent. In the lab Gemma sent the issue number as a float, and argument types are where a custom tool tends to break first:
import asyncio
from google.antigravity import Agent
from backend import make_config
from tracker_tool import get_issue
async def main():
config = make_config(tools=[get_issue])
async with Agent(config) as agent:
response = await agent.chat(
"Fetch issue 14 and tell me what the customer saw and what they expected."
)
async for call in response.tool_calls:
print(f"[tool] {call.name} {call.args}")
print(await response.text())
if __name__ == "__main__":
asyncio.run(main())
Run uv run python tool_agent.py. The agent calls get_issue once and answers from the tracker data:

Two details in that output matter. The use_json_schema warning comes from google-genai while it parses the callable, and it is harmless. The logged argument reads 14.0, a float, because the model’s JSON has no separate integer type. The tool still found issue "14" on its one call, so the value reached the function as the int its hint asks for, since str(14.0) would have looked up "14.0" and missed. Read the tool’s return value, not the logged arguments, when you debug a tool that seems to get the wrong input.
Attach an MCP server and a skill
MCP servers give the agent tools you didn’t write, and skills give it instructions it loads only when a task matches. If you’re unsure which of the two a job needs, MCP vs RAG vs agent skills breaks the choice down. Here the git MCP server reads the repo history, and a triage skill fixes the shape of the report.
A skill is a folder with a SKILL.md file whose front matter names it and says when to use it. Create it:
mkdir -p skills/issue-triage
vim skills/issue-triage/SKILL.md
The output format at the bottom is the part that pays off later, because the next agent in the pipeline reads it:
---
name: issue-triage
description: Triage a bug report against a git repository and write a short, structured triage note. Use when asked to triage, classify or assess an issue.
---
# Issue triage
1. Read the issue with the get_issue tool and look at any attached screenshot.
2. Use the git MCP tools to find the most recent commit that touched the suspect file.
3. Do not edit any file. Triage only.
Reply with exactly these lines and nothing else:
SEVERITY: <critical|high|medium|low>
COMPONENT: <file path>
SUSPECT_COMMIT: <short sha> <commit subject>
ROOT_CAUSE: <one sentence>
FIX_HINT: <one sentence a developer can act on>
The MCP server is a types.McpStdioServer with a command and arguments. uvx fetches mcp-server-git on first use, so there’s nothing else to install:
vim mcp_skill_agent.py
Watch the capabilities line. It’s the fix for the failure described right after the script:
import asyncio
from google.antigravity import Agent, types
from backend import make_config
from tracker_tool import get_issue
REPO = "/home/joshua/ag-agent/demo-repo"
git_server = types.McpStdioServer(
name="git",
command="uvx",
args=["mcp-server-git", "--repository", REPO],
)
async def main():
config = make_config(
tools=[get_issue],
mcp_servers=[git_server],
skills_paths=["/home/joshua/ag-agent/skills/issue-triage"],
workspaces=[REPO],
capabilities=types.CapabilitiesConfig(
agent_behavior=types.AgentBehavior.AUTONOMOUS
),
)
async with Agent(config) as agent:
response = await agent.chat(
"Triage issue 14 using the issue-triage skill. The git server's "
"tools take repo_path " + repr(REPO) + "."
)
async for call in response.tool_calls:
print(f"[tool] {call.server_name or 'local'}:{call.name}")
print(await response.text())
usage = agent.conversation.total_usage
print(f"tokens: prompt={usage.prompt_token_count} "
f"output={usage.candidates_token_count}")
if __name__ == "__main__":
asyncio.run(main())
Run it with uv run python mcp_skill_agent.py. Local tools show as local:, MCP tools carry their server name, and the reply follows the skill’s format line for line:

It found the right commit, a69cd38 Simplify discount math, and the right fix. The cost is the catch: 74,723 prompt tokens for seven tool calls, because every call resends the whole growing conversation to the model. A busy repo with long git_show output makes that worse fast, so trim what the MCP server exposes with enabled_tools on McpStdioServer before you point a paid model at it.
Error: tool lookup_skill is not enabled for server skill_manager
Without the capabilities line, the same script spun until the shell’s timeout killed it with exit code 124. The model kept guessing at a skill tool that wasn’t there:
WARNING:root:System step error (HTTP 0): The model produced an invalid tool call. ("model output error: invalid tool call error (invalid_args) tool lookup_skill is not enabled for server skill_manager")
WARNING:root:System step error (HTTP 0): The model produced an invalid tool call. ("model output error: invalid tool call error (invalid_args) tool lookup_skill is not enabled for server skills")
WARNING:root:System step error (HTTP 0): The model produced an invalid tool call. ("model output error: invalid tool call error (invalid_args) tool lookup_skill is not enabled for server skills_server")
The cause is .lightweight(). It sets agent_behavior to MINIMAL, which strips the system prompt down for small models and drops the skill instructions with it. Passing agent_behavior=AUTONOMOUS in capabilities keeps the short tool list but brings skills back. On Gemini with the full config you won’t see this.
Pass an image to the agent
Issue 14 came with a screenshot of the broken invoice. types.Image.from_file() wraps it, and the prompt becomes a list of text and media. Document, Audio and Video work the same way:
vim image_agent.py
No tools this time, just the picture and a question about it. Keeping the tools out isolates the vision step, so a wrong answer can only come from how the model read the image:
import asyncio
from google.antigravity import Agent, types
from backend import make_config
async def main():
screenshot = types.Image.from_file(
"/home/joshua/ag-agent/tracker/invoice-INV-2026-0412.png"
)
async with Agent(make_config()) as agent:
response = await agent.chat([
"This screenshot came with a bug report. Read the numbers on it and "
"work out what discount formula produced the total.",
screenshot,
])
print(await response.text())
usage = agent.conversation.total_usage
print(f"tokens: prompt={usage.prompt_token_count} "
f"output={usage.candidates_token_count}")
if __name__ == "__main__":
asyncio.run(main())
Gemma 4 reads images, so the local backend handles this too. Run uv run python image_agent.py:

It read Subtotal 100.00, Discount -1000.00 and Total -900.00 off the PNG and worked back to the missing division without seeing a line of code. The run used only 3,696 prompt tokens, because it answered in a single model call: the four built-in tool schemas from .lightweight() still went with the prompt, but nothing was resent. That makes image-only triage cheap enough to run on every incoming bug report, with the expensive repo-reading agent saved for the ones that need it.
Chain two agents into a triage and fix pipeline
Google’s Gemini 4 Hydrogen demo shows the pattern: Hydrogen agents “handle triaging and coding” while a Carbon agent takes the bigger jobs. The same split works with two SDK agents in one script. The triage agent gets everything built so far but can’t edit files or run commands. The fix agent gets the triage note and full shell access.

The read-only part comes from disabled_tools, not a policy, so the triage model never sees the edit and shell tools and can’t waste turns on them. Create the pipeline script:
vim pipeline.py
It reuses git_server and REPO from the MCP script, then checks the result itself with git diff and unittest instead of trusting the fix agent’s summary:
import asyncio
import subprocess
import time
from google.antigravity import Agent, types
from google.antigravity.hooks import policy
from backend import make_config
from mcp_skill_agent import REPO, git_server
from tracker_tool import get_issue
SCREENSHOT = "/home/joshua/ag-agent/tracker/invoice-INV-2026-0412.png"
async def run(name, config, prompt):
start = time.monotonic()
async with Agent(config) as agent:
response = await agent.chat(prompt)
async for call in response.tool_calls:
print(f" [{name}] {call.server_name or 'local'}:{call.name}")
text = await response.text()
usage = agent.conversation.total_usage
print(f" [{name}] tokens={usage.total_token_count} "
f"wall={time.monotonic() - start:.0f}s")
return text
async def main():
triage_config = make_config(
tools=[get_issue],
mcp_servers=[git_server],
skills_paths=["/home/joshua/ag-agent/skills/issue-triage"],
workspaces=[REPO],
capabilities=types.CapabilitiesConfig(
agent_behavior=types.AgentBehavior.AUTONOMOUS,
disabled_tools=[types.BuiltinTools.CREATE_FILE,
types.BuiltinTools.EDIT_FILE,
types.BuiltinTools.RUN_COMMAND],
),
)
print("== triage agent ==")
note = await run("triage", triage_config, [
"Triage issue 14 using the issue-triage skill. The attached screenshot "
"is the customer's invoice. The git server's tools take repo_path "
+ repr(REPO) + ".",
types.Image.from_file(SCREENSHOT),
])
print(note)
fix_config = make_config(workspaces=[REPO], policies=[policy.allow_all()])
print("== fix agent ==")
summary = await run("fix", fix_config,
"Fix the bug described in this triage note, then run "
"`python3 -m unittest -v` and confirm every test passes. Do not commit.\n\n"
+ note)
print(summary)
print("== independent check ==")
for cmd in (["git", "diff"], ["python3", "-m", "unittest"]):
out = subprocess.run(cmd, cwd=REPO, capture_output=True, text=True)
print(out.stdout + out.stderr)
if __name__ == "__main__":
asyncio.run(main())
Run it and give it time. On CPU the two agents together take several minutes:
uv run python pipeline.py
The triage agent goes first. It read the issue, looked at the repo, then called the git server 13 times before writing its note:

Eight of those calls were git_status on a clean tree, which is a 26B model wandering, and it pushed the triage stage to 94,231 tokens and 742 seconds. The note is still right: high severity, invoice.py, the full SHA of the bad commit and a fix hint. A stronger model, or enabled_tools on the MCP server limited to git_log and git_show, cuts that waste.
The fix agent took the note, made the edit, ran the tests and reported back. Then the script ran its own git diff and unittest:
== fix agent ==
[fix] local:run_command
[fix] local:view_file
[fix] local:run_command
[fix] local:edit_file
[fix] local:run_command
[fix] tokens=27680 wall=178s
I will start by listing the files in the current directory to locate `invoice.py`.
I have fixed the bug in `invoice.py` by updating the `apply_discount` function to divide the `percent` by 100, as suggested in the triage note. I have also verified that all tests pass by running `python3 -m unittest -v`.
```bash
$ python3 -m unittest -v
test_no_discount (test_invoice.InvoiceTest.test_no_discount) ... ok
test_ten_percent (test_invoice.InvoiceTest.test_ten_percent) ... ok
----------------------------------------------------------------------
Ran 2 tests in 0.000s
OK
```
== independent check ==
diff --git a/invoice.py b/invoice.py
index c83a575..88fcaff 100644
--- a/invoice.py
+++ b/invoice.py
@@ -1,6 +1,6 @@
def apply_discount(total: float, percent: float) -> float:
"""Return total after a discount (percent given as a whole number)."""
- return total - total * percent
+ return total - total * (percent / 100)
def invoice_total(lines: list[tuple[str, int, float]], discount: float = 0) -> float:
..
----------------------------------------------------------------------
Ran 2 tests in 0.000s
OK
A one-line fix, both tests green, and nothing committed, exactly as asked. The fix agent needed only 27,680 tokens and 178 seconds, because the triage note told it which file and which commit to look at. The whole script took 921 seconds on CPU, and nearly all of that was local generation, so a hosted model is the obvious next step once the auth errors above are sorted. Keep the independent check either way: the fix agent’s own report pasted a test run as text, and only the script’s git diff proves the file changed.
Check what each run cost
agent.conversation.total_usage reports prompt, output, thinking and total tokens summed over every model call in the conversation, so it already includes the resent context. These are the numbers from the lab runs, all on gemma4:26b through Ollama on 32 vCPUs with no GPU:
| Run | Tool calls | Tokens | Wall time |
|---|---|---|---|
First agent, allow_all() | 2 | 11,506 | 104 s |
| First agent, default policy | denied retries | 21,550 | 408 s |
| MCP server plus skill | 7 | 74,723 prompt, 2,970 output | not timed |
| Image attachment | 0 | 3,696 prompt, 1,351 output | not timed |
| Pipeline, triage agent | 15 | 94,231 | 742 s |
| Pipeline, fix agent | 5 | 27,680 | 178 s |
Local tokens cost nothing but time. On Gemini the same counts become money, and prompt tokens dominate, so the levers are fewer tools per agent, tighter prompts and types.BudgetConfig(max_model_calls=...) to cap a runaway loop. If you’re weighing the SDK against the agent features of other editors, Cursor vs Windsurf vs Kiro compares those, and the Gemini CLI setup guide covers Google’s other terminal agent.
Antigravity SDK quick reference
The calls this guide used, in one place. Check the google-antigravity PyPI page for the current release before you pin it, since Alpha releases can rename things.
| Task | Code |
|---|---|
| Install | uv add google-antigravity |
| Gemini backend | LocalAgentConfig(model="gemini-4-hydrogen") with GEMINI_API_KEY |
| Vertex backend | LocalAgentConfig(vertex=True, project=..., location=...) |
| Local model | LocalOpenAIAgentConfig(model=..., base_url=...).lightweight() |
| Run a turn | async with Agent(config) as agent: await agent.chat(prompt) |
| Read the answer | await response.text() |
| See tool calls | async for call in response.tool_calls |
| Allow shell commands | policies=[policy.allow_all()] |
| Hide tools entirely | CapabilitiesConfig(disabled_tools=[...]) |
| Custom tool | tools=[my_function] |
| MCP server | mcp_servers=[types.McpStdioServer(name="git", command="uvx", args=[...])] |
| Skills | skills_paths=["skills/issue-triage"] |
| Image input | agent.chat(["text", types.Image.from_file(path)]) |
| Token usage | agent.conversation.total_usage |
| Cap model calls | types.BudgetConfig(max_model_calls=N) |
The agents in this guide shell out to ls, git and python3 -m unittest, and reading what they ran is half the job.