Antigravity Directory Tools
Use a local Antigravity agent directory through AntigravityTools.
"""
Use a local Antigravity agent directory through AntigravityTools.
Pass `agent_directory=` to the toolkit constructor and it will:
1. Parse `agent.yaml`, `AGENTS.md`, `workspace/`, and `skills/`.
2. Register the agent definition via POST /v1beta/agents (idempotent).
3. Route all subsequent `run_antigravity_task` calls at the named custom agent.
Lets a regular Agno agent (any model) delegate sub-tasks to a folder-defined
Antigravity agent without having to wire up `/agents` calls yourself.
Re-uses the example folder from
`cookbook/frameworks/antigravity/example_agent/`.
Requirements:
export GEMINI_API_KEY=...
uv pip install agno google-genai pyyaml
Usage:
.venvs/demo/bin/python cookbook/91_tools/antigravity/antigravity_directory_tools.py
"""
from pathlib import Path
from agno.agent import Agent
from agno.models.google import Gemini
from agno.tools.antigravity import AntigravityTools
AGENT_DIR = (
Path(__file__).parent.parent.parent / "frameworks" / "antigravity" / "example_agent"
)
agent = Agent(
name="Haiku Requester",
model=Gemini(id="gemini-2.5-pro"),
# Register the folder once at construction; subsequent run_antigravity_task
# calls invoke the named agent (`agno-haiku-bot-from-dir`).
tools=[AntigravityTools(agent_directory=str(AGENT_DIR))],
markdown=True,
instructions=[
"When the user asks for a haiku, delegate to the Antigravity sandbox via run_antigravity_task.",
"Pass the topic through as-is; the sandbox agent enforces house style.",
],
)
if __name__ == "__main__":
agent.print_response("Write a haiku about autumn maples.")These tools require a Gemini API key with access to the Managed Agents API. An ordinary model key alone may not have that access. Set GEMINI_API_KEY for the toolkit and GOOGLE_API_KEY for the outer Gemini model to the enrolled key. See the Managed Agents setup.
The repository checkout supplies cookbook/frameworks/antigravity/example_agent/; saving this script alone does not. Registration happens at toolkit construction. A conflict response reuses the existing definition without updating it, so changing the local instructions does not update an already registered agent.
Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno google-genaiExport your API keys
export GEMINI_API_KEY="your_gemini_api_key_here"
export GOOGLE_API_KEY="your_google_api_key_here"Clone Agno
Clone the pinned Agno source and run the remaining commands from its root:
git clone https://github.com/agno-agi/agno.git
cd agno
git checkout d703c34f3abf3c41275d3fb2da6e0518a8881f24Run the example
Run the example from the repository root:
python cookbook/91_tools/antigravity/antigravity_directory_tools.pyFull source: cookbook/91_tools/antigravity/antigravity_directory_tools.py