Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
agy-bridge
Build LLM agents in Rust — with tools, hooks, streaming, and multimodal input.
Rust bridge for the Google Antigravity SDK via PyO3.
Rust's compile-time checks make it a natural fit for vibe coding agents — schema mismatches, missing parameters, and typos in tool definitions (via
#[llm_tool]) are caught at build time, not at runtime.
Installation
Option 1: Native Backend (Pure Rust, default)
Add agy-bridge to your Cargo.toml:
[]
= "0.16"
= { = "1", = ["macros", "rt-multi-thread"] }
This is the native feature, enabled by default. It talks to the
localharness binary directly over WebSocket + protobuf and needs no
Python interpreter.
Option 2: Python Backend
Drives the Python SDK in-process via PyO3. Choose this if you need features
the native harness does not implement yet (triggers, initial history):
[]
= { = "0.16", = false, = ["python"] }
= { = "1", = ["macros", "rt-multi-thread"] }
Install the Python SDK alongside it:
watchfilesis only needed for file-change triggers; timer triggers work without it.
API Key & Endpoint Setup
Set your API key (or put it in a .env file):
For custom gateways or local proxies (e.g. Beyond proxy):
Quick Start
use AgyBridge;
async
Streaming Responses
use ;
async
Features
Multimodal Content
Pass text, images, audio, video, and documents in a single chat turn:
use ;
async
Custom Tools
Define tools with the #[llm_tool] proc macro — doc comments become descriptions:
use ;
/// Gets the current weather for a city.
async
For full control, implement the RustTool trait directly:
use ;
use Deserialize;
;
let registry = new.with_tool;
assert_eq!;
Tool Discovery
After agent creation, inspect all available tools — custom Rust tools, MCP server tools, and SDK builtins — with source, description, and schema:
use AgyBridge;
async
Structured Output
Constrain agent responses to a typed Rust struct:
use ;
use JsonSchema as JsonSchemaTrait;
use Deserialize;
let schema = to_value
.expect;
let config = builder
.response_schema
.build;
// The agent's response will be valid JSON matching `Summary`.
assert!;
MCP Integration
Connect external MCP servers:
use ;
let server = stdio
.args
.build;
let config = builder.mcp_servers.build;
assert_eq!;
Hooks
Register lifecycle callbacks for logging, safety gates, and middleware:
use ;
async
Execution Budgets & Shell Safety
Enforce hard operational bounds on model calls, tool calls, and token usage, configure session continuation, and harden background shell commands:
use ;
let budget = builder
.max_model_calls
.max_tool_calls
.max_total_tokens
.build;
let shell_config = builder
.enable_daemons
.timeout_seconds
.enable_sandbox
.build;
let config = builder
.session_continuation_mode
.budget_config
.capabilities
.build;
assert!;
Policies
Declarative tool access control — first matching rule wins:
use ;
let mut policies = new;
policies.push.unwrap;
policies.push.unwrap;
policies.push.unwrap;
assert!;
assert!;
assert!;
Triggers
Run background tasks that react to timers or file changes:
use ;
async
Note:
on_file_changetriggers require thewatchfilesPython package (pip install watchfiles). Timer triggers (every) work without extra dependencies.
Subagents
Spawn child agents that share the parent's runtime:
use ;
async
Examples
The examples/ directory has runnable demos:
Getting Started
| Example | Description |
|---|---|
hello_world |
Minimal agent — create, prompt, print |
streaming |
Stream text tokens as they arrive |
custom_tools |
#[llm_tool] proc macro |
multimodal |
Text + image input |
mcp_tools |
MCP server integration |
structured_output |
JSON schema–constrained responses |
hooks |
Lifecycle hooks |
policies |
Declarative tool access control |
triggers |
Periodic and file-change triggers |
subagents |
Parent/child agent spawning |
human_in_the_loop |
Human-in-the-loop chat patterns |
persistence |
Conversation persistence |
observability |
Tracing and usage metadata |
error_handler |
Structured error handling patterns |
autonomous_shell |
Autonomous shell command execution |
persona_config |
Custom persona and model configuration |
agent_skills |
Agent skill registration |
app_data_dir_override |
Custom app data directory |
template_tools |
md-tmpl prompt/response templates |
Deep Dives
| Example | Description |
|---|---|
async_chat |
Advanced async chat patterns |
round_based_chat |
Multi-round structured conversations |
agent_middleware |
Hook-based middleware pipeline |
host_tool_hooks |
Host-side tool interception hooks |
interactive_cli |
Multi-turn CLI chat application |
multimodal_pipeline |
Multi-stage multimodal processing |
doc_maintenance_agent |
Documentation maintenance agent |
docstring_maintenance_agent |
Code docstring maintenance agent |
License
Licensed under either of:
at your option.
This is not a Google product. Use at your own risk.