Agent with Antigravity tools
Use Agno's integration with Google's Gemini Agents API (Antigravity) as a tool.
Use Agno's integration with Google's Gemini Agents API (Antigravity) as a tool. The Agno agent's brain (Gemini, here) decides when to delegate a sub-task to a managed Antigravity sandbox, which runs an autonomous loop with web search, code execution, and file I/O built in.
"""
Agent with Antigravity tools
This example shows how to use Agno's integration with Google's Gemini Agents API
(Antigravity) as a tool. The Agno agent's brain (Gemini, here) decides when to
delegate a sub-task to a managed Antigravity sandbox, which runs an autonomous
loop with web search, code execution, and file I/O built in.
The sandbox persists across calls within the same Agno session, so subsequent
calls can build on prior files and state.
1. Get a Gemini API key enrolled in the Agents API EAP.
2. Set the API key as an environment variable:
export GEMINI_API_KEY=<your_api_key>
3. Install the dependencies:
uv pip install agno google-genai
"""
from agno.agent import Agent
from agno.models.google import Gemini
from agno.tools.antigravity import AntigravityTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
name="Research Assistant with Antigravity tools",
model=Gemini(id="gemini-2.5-pro"),
tools=[AntigravityTools()],
markdown=True,
instructions=[
"You have access to a managed Antigravity sandbox with web search, code execution, and file I/O.",
"When the user asks for something that benefits from those capabilities — multi-step research, "
"analysing a repo, generating files, or running code you cannot run locally — delegate the work "
"to the sandbox via the run_antigravity_task tool.",
"Otherwise, answer directly without invoking the tool.",
"The sandbox persists across calls in the same session, so follow-up tasks can build on prior state.",
],
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
agent.print_response(
"Use the Antigravity sandbox to find the latest stable Python release "
"and summarize what changed in it."
)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 toolkit reuses the environment and previous-interaction IDs held in the calling agent's session state. This single-run example has no database and does not demonstrate recovery after a process restart. The model decides whether to delegate each request.
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"Run the example
Save the code above as antigravity_tools.py, then run:
python antigravity_tools.pyFull source: cookbook/91_tools/antigravity/antigravity_tools.py