What Are the Primary Dependencies for the Goose Project? A Complete Guide to the Rust AI Agent Framework
The Goose AI agent framework depends on a curated Rust ecosystem including tokio for async execution, reqwest and axum for HTTP networking, serde for serialization, sqlx for persistence, and tracing for observability, with optional support for local inference via candle and cloud providers via AWS and Google SDKs.
The aaif-goose/goose repository is a Rust-based AI agent framework that orchestrates LLM interactions, tool use, and session management. Understanding the primary dependencies for the Goose project is essential for contributors extending the core engine or debugging provider integrations. This guide breaks down the foundational crates declared in the workspace-level Cargo.toml (lines 22‑70) and the core crate’s Cargo.toml (lines 64‑112), illustrating how each category powers the runtime.
Async Runtime and HTTP Networking
The Goose engine is built on a non-blocking event loop powered by Tokio and its ecosystem. In crates/goose/src/lib.rs, the public API re-exports async traits and stream utilities that depend on tokio, async-trait, and futures.
For network operations, the framework uses Reqwest for client-side HTTP requests to LLM providers and Axum (with http and hyper internally) for the built-in goosed server. This split allows the agent to act as both a client consuming cloud APIs and a server exposing REST endpoints.
use reqwest::Client;
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
let client = Client::builder()
.user_agent("goose/1.30.0")
.build()?;
let resp = client
.post("https://api.openai.com/v1/chat/completions")
.header("Authorization", "Bearer $OPENAI_API_KEY")
.json(&serde_json::json!({
"model": "gpt-4o-mini",
"messages": [{ "role": "user", "content": "Hello!" }]
}))
.send()
.await?
.json::<serde_json::Value>()
.await?;
println!("Chat response: {:#}", resp);
Ok(())
}
Data Serialization and Configuration
Configuration parsing and provider payload handling rely heavily on Serde and its companions (serde_json, serde_yaml). The schemars and jsonschema crates enable JSON Schema generation for tool definitions that LLMs consume. For CLI parsing, Goose uses Clap combined with dotenvy and shellexpand to handle environment files and variable expansion, as seen in crates/goose/src/cli_common.rs.
use clap::Parser;
/// Goose – an AI‑agent framework
#[derive(Parser, Debug)]
#[command(author, version, about)]
struct Args {
/// Path to the recipe file
#[arg(short, long)]
recipe: String,
/// Enable verbose logging
#[arg(short, long, action = clap::ArgAction::Count)]
verbose: u8,
}
fn main() {
let args = Args::parse();
println!("Running recipe: {}", args.recipe);
}
Observability and Security
Tracing provides the structured logging infrastructure throughout Goose. The tracing-subscriber and tracing-futures crates wire into crates/goose/src/agents/extension.rs, creating spans around agent execution steps. Optional OpenTelemetry support (tracing-opentelemetry) is available behind feature flags for production telemetry export.
For authentication, Goose integrates OAuth2 flows, JSON Web Tokens via jsonwebtoken, and secure credential storage through keyring. Cryptographic primitives from sec1, pem, pkcs1, and pkcs8 handle key parsing for cloud provider authentication.
use tracing::{info, instrument};
use tracing_subscriber::{fmt, EnvFilter};
#[instrument]
fn run_agent_step(step: &str) {
info!("Running agent step {}", step);
}
fn main() {
tracing_subscriber::registry()
.with(fmt::layer())
.with(EnvFilter::from_default_env())
.init();
run_agent_step("fetch_prompt");
}
Persistence and Cloud Provider Integration
Session state and agent metadata are persisted using SQLx with SQLite, configured in crates/goose/Cargo.toml with specific database features. The tempfile crate supports transient storage for test suites and temporary model downloads.
Cloud provider integrations live in crates/goose/src/providers/mod.rs and pull in AWS SDK crates (aws-config, aws-sdk-bedrockruntime, aws-sdk-sagemakerruntime) along with Google API clients for Vertex AI. These remain optional behind feature gates but are considered primary for production deployments.
use sqlx::{sqlite::SqlitePoolOptions, Row};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let pool = SqlitePoolOptions::new()
.max_connections(5)
.connect("sqlite://goose_state.db")
.await?;
let row: (i64,) = sqlx::query_as("SELECT COUNT(*) FROM agents")
.fetch_one(&pool)
.await?;
println!("Registered agents: {}", row.0);
Ok(())
}
Optional Local Inference and Audio
When the local-inference feature is enabled, Goose pulls in Candle (candle-core, candle-nn, candle-transformers) for on-device LLM inference. The llama-cpp-2 crate provides additional local model support, while tokenizers handles text encoding. For audio processing, symphonia and rubato enable Whisper transcription workflows that run entirely offline.
Testing and Utility Crates
The test suite relies on Wiremock for HTTP stubbing, mockall for trait mocking, and insta for snapshot testing. Runtime utilities include anyhow and thiserror for error handling, chrono for timestamps, uuid for unique identifiers, and rayon for data parallelism during batch operations. The tree-sitter family of crates supports language-aware parsing for code analysis features.
Summary
- Async and HTTP:
tokio,reqwest, andaxumform the non-blocking runtime and networking layer declared in the workspaceCargo.toml. - Serialization:
serde,serde_json, andclapmanage configuration files, CLI arguments, and LLM payload conversion. - Observability:
tracingand optional OpenTelemetry crates provide structured logging and telemetry export. - Security:
oauth2,jsonwebtoken, andkeyringhandle cloud authentication and credential storage. - Persistence:
sqlxwith SQLite features stores agent state, while AWS and Google SDKs enable cloud provider access. - Local AI:
candleandllama-cpp-2support offline inference when features are enabled.
Frequently Asked Questions
What version of Tokio does Goose require?
The workspace Cargo.toml pins Tokio to the latest stable 1.x release with full features enabled, typically including rt-multi-thread and macros for the async runtime. Check the [workspace.dependencies] section at lines 22‑70 of the root Cargo.toml for the exact version constraint.
Can I use Goose without SQLx or SQLite?
Yes, while sqlx is included in the core crate’s dependencies (lines 64‑112 of crates/goose/Cargo.toml), you can disable default features or build the minimal crate if you implement a custom storage backend. The framework uses SQLx primarily for caching provider models and session metadata, but the core agent logic does not strictly require it.
Why does Goose include both Reqwest and Axum?
Reqwest serves as the HTTP client for calling remote LLM APIs (OpenAI, Anthropic, etc.), while Axum powers the optional goosed server mode that exposes agent capabilities via REST endpoints. This dual-stack approach allows Goose to function as both a client library and a standalone service, with each crate optimized for its specific role in crates/goose/src/providers/mod.rs and server initialization code.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →