Power agent hubs or custom harnesses with the Antigravity SDK

The article explains how developers building custom agent hubs can use the Antigravity SDK instead of managed commercial platforms. While many teams choose turnkey options such as the Gemini Enterprise Agent Platform for deployment and governance, teams with bespoke workflows or custom execution engines often build their own lightweight agent hubs. The Antigravity SDK provides the exact runtime engine used in Antigravity 2.0 and the Antigravity CLI, adding declarative safety policies, real-time telemetry, and stateful multi-turn persistence directly into an application. When the core runtime updates, SDK agents receive those optimizations automatically.

A multi-agent control plane monitors and manages LLM workloads, showing exactly what an agent is thinking, which tools it calls, and how it stores state. It consists of two critical components: the Antigravity SDK agent core, which manages model interactions with models like Gemini 3.1 Pro and Gemini 3.8 Flash, runs tools, generates thinking traces, and executes skills; and observability and telemetry middleware powered by Antigravity SDK Lifecycle Hooks, which intercepts agent actions such as step starts, thinking updates, and tool calls, then streams telemetry over WebSockets to a dashboard.

The motivating use case is an operations engineer monitoring multiple active agents, such as gemini-pro-agent, github-agent, and email-agent, performing background research, document summarization, and task scheduling. Traditional observation requires tailing fragmented console logs across terminal windows, manually inspecting JSON transcripts to diagnose stuck or failing tool calls, and lacks visibility into which Skills or MCP connectors are loaded for a session. It also makes cumulative token usage and execution latency difficult to track. The SDK addresses this through its streaming API, lifecycle hooks, policy engine, skills, and session state, giving operators a single view into what every agent is doing.

Behind the scenes, the runtime coordinates execution through five core mechanisms. Session initialization and state attachment use save_dir and conversation_id to bind execution to a root directory, preserving multi-turn trajectory logs, tool receipts, and artifacts under traj- for persistent auditability. Skill resolution loads domain-specific capabilities from filesystem paths pointing to SKILL.md bundles, dynamically augmenting the system prompt without an external registry. Concurrent stream generation exposes three async iterators over the model response: response for visible text tokens, response.thoughts for internal chain-of-thought reasoning deltas, and response.tool_calls for typed ToolCall events with .name and .args. Declarative sandboxing confines built-in workspace tools such as list_directory, find_file, search_directory, view_file, create_file, and edit_file to configured workspaces governed by safety policies like policy.workspace_only(). Finally, telemetry interception uses decorated async hook functions such as @hooks.on_session_start, @hooks.pre_tool_call_decide, @hooks.post_tool_call, and @hooks.on_session_end to validate or modify tool calls and broadcast telemetry payloads over WebSockets.

The SDK organizes these responsibilities into four building blocks. Skills are reusable, domain-specific instruction bundles and reference assets loaded dynamically from filesystem directories containing SKILL.md. Sandboxed built-in tools and workspace scoping remove the need for custom filesystem wrappers while keeping tools confined to authorized directories. Session isolation and trajectory persistence are handled declaratively through save_dir and conversation_id rather than an external database. Real-time telemetry and interception with lifecycle hooks let dashboards and monitoring engines observe and steer every stage of execution, including enforcing human-in-the-loop approvals before tools run.

Power agent hubs or custom harnesses with the Antigravity SDK

View Original