A practical guide to building production-ready AI agents in Rust — written for engineers migrating from Java and the Spring AI / LangChain4j ecosystem
This book teaches experienced Java developers how to build AI agents in Rust using the four key frameworks in the Rust AI ecosystem:
- rig-core — LLM clients, tool calling, structured output, RAG, and multi-turn agents
- swiftide — Streaming document indexing and RAG query pipelines
- graph-flow — Stateful multi-step agent workflows as directed graphs with session persistence
- rmcp — Model Context Protocol (MCP) server and client implementation
Every chapter includes a Java parallel — a direct comparison showing the equivalent Spring AI, LangChain4j, or LangGraph4j pattern, so you can map what you already know to idiomatic Rust.
This book is written for experienced Java developers who:
- Are proficient in Java (11+, ideally 17+) and the Spring ecosystem
- Want to understand Rust's value proposition for AI agent development
- Are building production systems where performance, memory safety, and binary size matter
- Want to learn Rust through a lens of practical AI application development
No prior Rust knowledge required — Chapter 2 covers Rust fundamentals for Java developers.
By the end of this book, you will be able to:
- Use Rust's ownership model to build memory-safe AI agents with zero garbage collection pauses
- Integrate with LLM APIs using
rig-corefor tool calling, structured output, and multi-turn conversations - Build streaming RAG pipelines with
swiftide— chunk, embed, and query document corpora - Design stateful multi-agent workflows as directed graphs with
graph-flow - Expose and consume MCP tools using
rmcpfor cross-language agent interoperability - Implement human-in-the-loop approval gates with session persistence
- Add observability (tracing, metrics, structured logging) and security guards to production agents
- Deploy agentic Rust services as Docker containers with multi-stage builds
| Part | Title | Chapters |
|---|---|---|
| I | Foundations | 1–3 |
| II | Core Rig Capabilities | 4–7 |
| III | RAG and Memory | 8–11 |
| IV | Orchestration with graph-flow | 12–15 |
| V | Production | 16–21 |
Part I — Foundations
- Ch 1: Why Rust for Agentic AI?
- Ch 2: Rust for Java Developers
- Ch 3: LLM Basics in Rust
Part II — Core Rig Capabilities
- Ch 4: Tool Calling with rig-core
- Ch 5: Structured Output
- Ch 6: Agents and Multi-Turn Conversations
- Ch 7: Building a Streaming API with Axum
Part III — RAG and Memory
- Ch 8: RAG with rig-core
- Ch 9: Swiftide — Streaming Indexing Pipelines
- Ch 10: Memory and State
- Ch 11: MCP — Model Context Protocol
Part IV — Orchestration
- Ch 12: Graph-Based Workflows
- Ch 13: Graph Agents
- Ch 14: Stateful Workflows and Persistence
- Ch 15: Multi-Agent Pipelines
Part V — Production
- Ch 16: Observability, Security, and Cost Control
- Ch 17: Deployment — The Rust Advantage
- Ch 18: Framework Comparison
- Ch 19: Capstone — Research Agent
- Ch 20: Capstone — Multi-Agent Pipeline
- Ch 21: Production-Ready Agent
- Java 11+ familiarity (the book draws Java parallels throughout)
- Rust toolchain:
rustup+cargo(install) - An OpenAI API key (set as
OPENAI_API_KEY) - Docker (for deployment chapter)
git clone https://github.com/jackandjac/Book-Rust-Agentic-Programming.git
cd Book-Rust-Agentic-Programming/code-examples
export OPENAI_API_KEY="sk-..."
cargo run -p ch04-tool-calling
cargo run -p ch09-swiftide
cargo run -p ch14-stateful-workflows
RUST_LOG=info cargo run -p ch19-capstone-research-agentEach crate matches its chapter number. See the chapter's prose for full setup instructions.
# Requires Node.js
npm install
npx puppeteer browsers install chrome
./generate-pdf.sh
# Force regenerate
./generate-pdf.sh --forceThe generated COMPLETE_BOOK.pdf contains all 21 chapters with syntax-highlighted code blocks.
| Framework | Version | Downloads |
|---|---|---|
| rig-core | 0.37 | 772k |
| swiftide | 0.32 | 81k |
| graph-flow | 0.5.1 | 6.6k |
| rmcp | 1.6 | 9.7M |
| axum | 0.8 | 74M |
| tokio | 1 | 290M |
Version: 1.0 (May 2026)
© 2026 | Licensed under Creative Commons Attribution-NonCommercial 4.0