Mixtape
An agentic AI framework for Rust.
Quick Start
use ;
async
Run with cargo run --example hello_world --features bedrock.
Cargo Features
Enable only what you need. All agents need mixtape-core with one of the provider features enabled ("bedrock", or
"anthropic"). Add mixtape-tools to
leverage foundational agentic tools.
# In your Cargo.toml
[]
= { = "0.3", = ["bedrock"] }
| Feature | Description |
|---|---|
bedrock |
AWS Bedrock provider |
anthropic |
Anthropic API provider |
mcp |
Connect to MCP servers |
session |
Session persistence |
Add mcp for MCP server integration, session for conversation persistence.
Workspace Crates
This repository contains five crates:
| Crate | Purpose |
|---|---|
| mixtape-core | Core agent framework |
| mixtape-tools | Pre-built filesystem, process, web, and database tools |
| mixtape-cli | Session storage and interactive REPL features |
| mixtape-server | HTTP server with AG-UI protocol support (experimental) |
| mixtape-anthropic-sdk | Low-level Anthropic API client (used internally) |
Most projects need only mixtape-core. Add mixtape-tools for ready-to-use tools.
Tools Defined in Idiomatic Rust
Define tools with Rust types. Agent tool schemas generate automatically.
use ;
use JsonSchema;
use ;
;
Doc comments on fields become descriptions in the JSON schema. The model sees these when deciding how to call your tool.
See weather_tool.rs for a complete example.
Tool Results
Tools return ToolResult, which supports several content types:
// Text - strings convert automatically
Ok
Ok
// JSON - for structured data
json?
// Images - for multimodal models
image
// Documents - PDFs, spreadsheets, etc.
document
document_with_name
Parallel Execution
When the model requests multiple tools, they run concurrently:
let agent = builder
.bedrock
.with_max_concurrent_tools
.build
.await?;
Conversations
The agent maintains conversation history in memory:
let agent = builder
.bedrock
.build
.await?;
agent.run.await?;
agent.run.await?; // Remembers "Alice"
let usage = agent.get_context_usage;
println!;
The default SlidingWindowConversationManager is token-aware. It keeps recent messages that fit within the model's
context limit, dropping older ones as needed.
Context lives in memory and disappears when the process exits. For persistence, use a session store.
Session Persistence
Save conversations to SQLite (requires session feature and mixtape-cli crate):
[]
= { = "0.3", = ["session"] }
= "0.3"
use SqliteStore;
let store = default_location?;
let agent = builder
.bedrock
.with_session_store
.build
.await?;
Streaming
Receive tokens as they arrive:
use AgentEvent;
agent.add_hook;
See streaming.rs.
Context Files
Load context from files into the system prompt at runtime:
let agent = builder
.bedrock
.with_system_prompt
.add_optional_context_file // Optional - skipped if missing
.add_context_file // Required - errors if missing
.add_context_files_glob // Glob pattern
.build
.await?;
Context files are resolved at runtime on each run() call. Path variables:
~or$HOME- user's home directory$CWD- current working directory
Inspect loaded context after a run:
if let Some = agent.last_context_info
| Method | Behavior |
|---|---|
add_context(content) |
Inline string content |
add_context_file(path) |
Required file |
add_optional_context_file(path) |
Optional file |
add_context_files([...]) |
Multiple required files |
add_optional_context_files([...]) |
Multiple optional files |
add_context_files_glob(pattern) |
Glob pattern (0 matches OK) |
MCP Client
Connect to Model Context Protocol servers (requires mcp feature):
use ;
let agent = builder
.bedrock
.with_mcp_server
.with_mcp_server
.build
.await?;
Load from Claude Desktop/Code config files:
let agent = builder
.bedrock
.with_mcp_config_file
.build
.await?;
Hierarchical Agents
Wrap agents as tools to create orchestrator patterns:
Tool Permissions
Control which tools require user approval:
use MemoryGrantStore;
// Create store and pre-approve safe tools
let store = new;
store.grant_tool.await?; // Trust entire tool
let agent = builder
.bedrock
.with_grant_store
.build
.await?;
Grant entire tool groups for convenience:
use MemoryGrantStore;
use read_only_filesystem_tools;
let store = new;
// Trust all read-only filesystem operations
for tool in read_only_filesystem_tools
let agent = builder
.bedrock
.add_tools
.with_grant_store
.build
.await?;
Tools without a matching grant emit PermissionRequired events. See
permissions.rs.
Models
Mixtape supports models through AWS Bedrock or Anthropic's API:
// AWS Bedrock (requires "bedrock" feature)
builder.bedrock.build.await?;
builder.bedrock.build.await?;
// Anthropic API (requires "anthropic" feature)
builder.anthropic.build.await?;
Bedrock supports Claude, Nova, Mistral, Llama, Cohere, DeepSeek, Qwen, Gemma, Kimi, and others.
Examples
| Example | Features | Description |
|---|---|---|
hello_world |
bedrock |
Minimal agent |
multi_turn |
bedrock |
Conversation memory |
streaming |
bedrock |
Real-time output |
parallel_tools |
bedrock |
Concurrent tools |
weather_tool |
bedrock |
HTTP API calls |
hierarchical_agents |
bedrock |
Orchestrator pattern |
interactive_agent |
bedrock,mcp,session |
Full CLI |
interactive_mcp_agent |
bedrock,mcp,session |
MCP integration |
Run any example:
Requirements
For bedrock feature:
- AWS credentials configured
- Access to AWS Bedrock with your chosen models
For anthropic feature:
ANTHROPIC_API_KEYenvironment variable
Development