| name | google-antigravity-sdk-rust |
| description | Design, implement, and debug autonomous AI agents and multi-agent systems in Rust using the Google Antigravity (AGY) Rust SDK. ACTIVATE this skill when the user wants to create, configure, or orchestrate Google Antigravity agents in Rust. |
Google Antigravity Rust SDK
This skill provides comprehensive instructions, architectural guidelines, and reference examples for building autonomous AI agents in Rust using the Google Antigravity SDK.
Installation & Setup
Ensure the following prerequisites are met before building or running agents:
- Cargo Configuration: Include the SDK dependency in your
Cargo.toml:
[dependencies]
antigravity-sdk-rust = { path = "path/to/antigravity-sdk-rust" }
tokio = { version = "1", features = ["full"] }
- API Credentials: Set the
GEMINI_API_KEY environment variable or supply it programmatically via GeminiConfig:
- Subprocess Harness: Ensure the
localharness binary is accessible either on your system PATH or configured via AgentConfig::binary_path.
WebAssembly (wasm32-wasip1) Target Guidelines
When designing and deploying agents to WebAssembly targets such as wasm32-wasip1 (e.g., inside Spin or standard WASI runtimes):
- Compilation Check: Always verify clean target compilation:
cargo check --target wasm32-wasip1
- Connection Protocol: Be aware that process spawning is not supported inside WebAssembly sandboxes. Instead of native subprocess IPC, use the direct network socket strategy (
WasmConnectionStrategy / WasmConnection) to connect to a host-side localharness WebSocket server.
- Core Async Traits: Do NOT use the
#[async_trait] attribute macro. The SDK uses native async traits (stable since Rust 1.75 / Rust 2024). Standard traits like Connection, Hook, Tool, and Trigger are implemented as native async traits (using impl Future + Send returns for trait-level Send bounds). For dynamic dispatch and runtime storage (e.g. Arc<dyn DynHook>), the SDK provides companion object-safe traits (DynHook, DynTool, DynTrigger) which are automatically implemented via blanket implementations for any type implementing the base trait.
- Mock Test Suite Guidelines: To test connection, event loops, and tool extractions under simulated WebSocket messaging, run:
cargo test wasm::tests
- Writing Mock Tests: Mock tests should spin up a local WebSocket listener, bind to port
0 to allocate a free TCP port dynamically, record that port, configure WasmConnectionStrategy to point to it, and mock standard JSON frames (StepUpdate, TrajectoryStateUpdate, etc.) to verify client state transitions.
Routing Table
Use the links below to navigate specific topics and code configurations:
References
- Architecture: Understand connection strategies, thread safety, and WebSocket handshake mechanisms.
See architecture.md.
- Agent Configuration: Detail configurations for models, workspaces, system instructions, and response schemas.
See agent_configuration.md.
- Built-in Tools: Review native tools (file IO, shell command runner, grep search) and capabilities setup.
See built_in_tools.md.
- Safety Policies: Formulate declarative middleware policies to block or confirm tool execution.
See safety_policies.md.
- Error Handling: Register hooks to catch and handle errors or redirect execution flow.
See error_handling.md.
- Observability: Extract token usage metrics and inspect thinking model trajectories.
See observability.md.
- MCP & Custom Tools: Register custom Rust tools or integrate Model Context Protocol (MCP) servers.
See mcp_integration.md.
Examples
- Hello World: Basic single-turn chat, streaming text and thoughts, and interactive loop.
See hello_world.md.
- Custom Tools: Write custom stateful and stateless tools using the
Tool trait.
See custom_tool.md.
- Persona & System Instructions: Guide the agent's identity, tone, and directives.
See persona_config.md.
- Multimodal Inputs/Outputs: Configure image generation capabilities and understand input constraints.
See multimodal.md.
- Subagent Delegation: Coordinate multi-agent tasks using subagents.
See subagents.md.
- Model Context Protocol (MCP): Integrate external MCP tools via global configuration files.
See mcp_tools.md.
- Triggers & Background Loops: Implement background workers reacting to system events.
See periodic_trigger.md.
- Lifecycle Hooks: Hook callbacks into pre-turn, tool execute, and error handling events.
See hooks.md.
- Session Persistence: Resume past execution sessions using a unique
conversation_id.
See persistence.md.
- App Data Directory Override: Override directory settings controlling log and artifact storage paths.
See app_data_dir_override.md.
- Structured Output: Direct agents to reply strictly with JSON objects adhering to a JSON schema.
See structured_output.md.
- Agent Skills: Dynamically load filesystem-based skill structures into the agent.
See agent_skills.md.
- Policies: Lock workspace directories and filter command lines.
See policies.md.
- Streaming: Stream chat responses and distinguish reasoning thoughts from response text in real time.
See streaming.md.