Skip to content

Antigravity SDK

The Antigravity SDK lets you build custom agents on top of Antigravity's agent harness with minimal Python code. Instead of starting from scratch with LLM APIs and tool calling, you write a short Python script that defines the agent's behavior, tools, and evaluation criteria. The SDK handles the agent loop, tool dispatch, and model interaction.

Gnome mascot

What you'll learn

  • The Antigravity SDK is a Python library for building custom coding agents
  • Simple Python scripts iterate on agentic applications using Antigravity's harness
  • The SDK includes evaluation tools to measure agent performance on software engineering tasks

The problem

You want an agent that does something specific: automatically triaging GitHub issues, generating weekly release notes from commit history, or running a security audit on every PR. You could prompt a general agent every time, but the results are inconsistent and you have to re-explain the procedure each time. A custom agent built with the SDK encodes the procedure once and runs reliably every time.

Build it

Step 1: Install the SDK

Install the SDK library via standard Python package management. This provides the classes and utilities needed to interact with the underlying agent harness.

bash
pip install antigravity-sdk

Step 2: Define a custom agent

Build the custom agent by instantiating the base class with clear instructions and specific tool bindings. The agent uses these tool decorators to autonomously interact with external APIs like GitHub.

python
# github_triager.py
from antigravity import Agent, tool

class GitHubTriager(Agent):
    """An agent that triages GitHub issues."""

    def __init__(self):
        super().__init__(
            name="github-triager",
            instructions="""You triage GitHub issues. For each issue:
            1. Classify as bug, feature, or question
            2. Assign priority: P0 (critical), P1 (high), P2 (medium), P3 (low)
            3. Suggest an appropriate label
            4. Write a helpful first response acknowledging the issue""",
            model="gemini-2.5-pro",
        )

    @tool
    def get_issue(self, issue_number: int) -> dict:
        """Fetch a GitHub issue by number."""
        # Call GitHub API
        response = self.github.get(f"/issues/{issue_number}")
        return response.json()

    @tool
    def add_labels(self, issue_number: int, labels: list[str]) -> None:
        """Add labels to a GitHub issue."""
        self.github.post(f"/issues/{issue_number}/labels", json={"labels": labels})

    @tool
    def post_comment(self, issue_number: int, body: str) -> None:
        """Post a comment on a GitHub issue."""
        self.github.post(f"/issues/{issue_number}/comments", json={"body": body})

# Run the agent
agent = GitHubTriager()
result = agent.run("Triage issue #42 in the myorg/myproject repo")

Step 3: Evaluate agent performance

Establish a structured testing framework to measure agent accuracy and latency against defined benchmarks. This evaluation suite ensures the agent consistently handles issues as expected before deployment.

python
from antigravity import Evaluation

eval = Evaluation(
    agent=GitHubTriager(),
    test_cases=[
        {"issue": 42, "expected_label": "bug", "expected_priority": "P1"},
        {"issue": 43, "expected_label": "feature", "expected_priority": "P2"},
    ],
)

results = eval.run()
print(f"Accuracy: {results.accuracy:.1%}")
print(f"Avg latency: {results.avg_latency_ms}ms")

What goes wrong

MistakeHow you notice itThe fix
Agent tool has side effects during evalReal GitHub issues get labeled during testingUse a test repo or mock the API calls during evaluation
Agent instructions too vagueAgent produces inconsistent results across runsAdd specific output formats and examples to the instructions. Test against a benchmark
SDK version incompatible with AntigravityImport errors or runtime crashesCheck SDK version compatibility with your Antigravity install. Update both together

Confirm it worked

Run a minimal agent implementation to ensure the Python runtime correctly dispatches instructions to the language model. A successful assertion guarantees the basic SDK components are fully operational.

python
# Minimal agent test
from antigravity import Agent

agent = Agent(
    name="hello-agent",
    instructions="When asked your name, respond with 'I am a test agent.'",
)
result = agent.run("What is your name?")
assert "test agent" in result.lower()

Resource links:

Next: Scheduled Messages & Automation