Day 2 of 5

Agent-First Coding Patterns

In agent-first development, you describe what you want — not how to do it. The Antigravity runtime figures out the HOW. Today you will write declarative floating specifications and let the framework optimise the trajectory.

python
# Declarative levitation specification
from antigravity.spec import LevitationSpec, Trajectory, WindModel

spec = LevitationSpec(
    payload='my-flask-api',
    destination=Trajectory(
        start=(37.7749, -122.4194, 0),   # San Francisco, ground level
        end=(37.7749, -122.4194, 9.5),   # Same coords, 9.5m up
    ),
    wind_model=WindModel.adaptive(),
    landing_protocol='graceful',         # completes requests before landing
)

# Deploy — the framework plans the optimal ascent path
deployment = spec.deploy()
print(deployment.status)   # FLOATING
print(deployment.eta_to_altitude)  # 3.2 seconds
python
# Intent-based routing — tell the agent what to do, not how
from antigravity.router import IntentRouter

router = IntentRouter()

@router.intent('process_document')
async def handle_document(payload: dict):
    # Antigravity analyses payload and routes to best handler
    return await router.dispatch(payload)

@router.handler(type='pdf', confidence_threshold=0.85)
async def handle_pdf(doc):
    return extract_text(doc)

@router.handler(type='image', confidence_threshold=0.85)
async def handle_image(img):
    return describe_image(img)

# The router decides which handler to call based on payload analysis
result = await router.process({'file': 'report.pdf', 'data': b'...'})
Tip: Real insight: The agent-first pattern is real and used in LangChain, Autogen, and Claude's tool-use API. The Antigravity branding is the joke; the patterns are production-grade.

Exercise: Build a Declarative Spec

  1. Write a LevitationSpec for a fictional microservice
  2. Add 3 @router.intent handlers for different input types
  3. Add confidence thresholds and a fallback handler
  4. Log the dispatch decision for each request
  5. Discuss: how does this map to a real LLM router?

Day 2 Summary

Finished this lesson?