# Bamboo Agent π
[](https://crates.io/crates/bamboo-agent)
[](https://docs.rs/bamboo-agent)
[](https://crates.io/crates/bamboo-agent)
[](https://github.com/bigduu/Bamboo-agent/actions/workflows/ci.yml)
[](https://github.com/bigduu/Bamboo-agent/actions/workflows/docs.yml)
[](https://github.com/bigduu/Bamboo-agent)
**π A Complete, Self-Contained AI Agent Backend Framework Built with Rust** π¦
Bamboo is a **production-ready**, **high-performance** AI agent framework that runs **entirely locally** with zero external dependencies. Built from the ground up in **Rust** for maximum efficiency and safety, it provides everything you need to build, deploy, and scale AI-powered applications.
## π― Why Bamboo?
- β‘ **Blazingly Fast** - Native Rust performance with zero-cost abstractions
- π **Privacy-First** - Runs 100% locally, your data never leaves your machine
- π― **All-in-One** - Complete agent system with built-in HTTP server, no microservices needed
- π¦ **Rust-Native** - Leverages Rust's safety guarantees and async ecosystem
- π¦ **Zero Config** - Works out of the box with sensible defaults
- π **Production-Ready** - Battle-tested with 867+ tests, CORS, rate limiting, security headers
## β¨ Key Features
### π€ Complete Agent System
- **Tool Execution** π§ - Execute shell commands, read/write files, search code
- **Skill Management** π― - Create and manage reusable prompt templates
- **Workflow Engine** π - Automate complex tasks with YAML-defined workflows
- **Todo Tracking** β
- Built-in task management and progress tracking
- **External Memory** π§ - Automatic conversation summarization for long sessions
### π Built-in HTTP Server
- **Actix-web Powered** β‘ - High-performance async HTTP server
- **REST API** π - Complete RESTful API for all operations
- **Streaming Support** π‘ - Real-time event streaming via Server-Sent Events
- **CORS & Security** π - Production-ready security headers and CORS configuration
- **Rate Limiting** π‘οΈ - Built-in protection against abuse
### π§ Multi-LLM Provider Support
- **OpenAI** π¬ - Full support for GPT-4, GPT-3.5, and custom models
- **Anthropic** π - Claude 3.5 Sonnet, Claude 3 Opus, and more
- **Google Gemini** β¨ - Gemini 2.0 Flash and Pro models
- **GitHub Copilot** π¨βπ» - OAuth device flow authentication with token caching
### β‘ Performance & Efficiency
- **Native Rust** π¦ - Zero-cost abstractions, no GC pauses
- **Async/Await** π - Tokio-based async runtime for maximum concurrency
- **Connection Pooling** π - Efficient HTTP connection reuse
- **Streaming** π - Stream large responses without buffering
- **Memory Efficient** πΎ - Minimal allocations, efficient data structures
### ποΈ Architecture
- **Modular Design** π§© - Clean separation of concerns
- **Dual Mode** π - Use as standalone binary or embedded library
- **XDG-Compliant** π - Standard Linux directory layout
- **Hot Reload** π - Reload configuration without restart
- **Plugin System** π - MCP (Model Context Protocol) for external tools
### π§ͺ Quality & Testing
- **867 Tests** β
- Comprehensive test coverage with 100% pass rate
- **Unit Tests** π§ͺ - Every module thoroughly tested
- **Integration Tests** π - End-to-end API testing
- **Documentation Tests** π - Code examples verified in docs
### π Security & Privacy
- **Local-First** π - Everything runs on your machine
- **No Cloud Dependencies** βοΈ - Works offline, no API keys stored externally
- **Encrypted Storage** π - Sensitive data encrypted at rest
- **Keyword Masking** π - Automatically mask sensitive information
## π Installation & Quick Start
### π¦ Installation
#### Option 1: Install from crates.io (Recommended)
```bash
cargo install bamboo-agent
```
#### Option 2: Build from source
```bash
# Clone the repository
git clone https://github.com/bigduu/Bamboo-agent.git
cd Bamboo-agent
# Build in release mode for best performance
cargo build --release
# Install locally
cargo install --path .
```
### π― Quick Start Guide
#### π₯οΈ Binary Mode (Standalone Server)
```bash
# Start server with default settings on port 8080
bamboo serve
# Custom configuration
bamboo serve --port 9000 --bind 0.0.0.0 --data-dir /var/lib/bamboo
# With specific config file
bamboo serve --config /path/to/config.toml
# Enable debug logging
RUST_LOG=debug bamboo serve
```
#### π¦ Library Mode (Embedded in Your App)
```rust
use bamboo_agent::{BambooBuilder, BambooConfig};
#[tokio::main]
async fn main() {
// Build your custom server with fluent API
let server = BambooBuilder::new()
.port(3000)
.bind("0.0.0.0")
.data_dir(std::path::PathBuf::from("/var/lib/myapp"))
.build()
.unwrap();
// Start the server (blocking)
server.start().await.unwrap();
}
```
## βοΈ Configuration
Bamboo follows the [XDG Base Directory specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) for clean, standards-compliant configuration management.
### π Default Paths
- **Config**: `$XDG_CONFIG_HOME/bamboo/config.json` (default: `~/.config/bamboo/`)
- **Data**: `$XDG_DATA_HOME/bamboo/` (default: `~/.local/share/bamboo/`)
- **Cache**: `$XDG_CACHE_HOME/bamboo/` (default: `~/.cache/bamboo/`)
- **Runtime**: `$XDG_RUNTIME_DIR/bamboo/` (default: `/tmp/bamboo-$UID/`)
### π Configuration File
Edit `~/.config/bamboo/config.json` (JSON format):
```json
{
"http_proxy": "",
"https_proxy": "",
"provider": "anthropic",
"providers": {
"anthropic": {
"api_key": "sk-ant-...",
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 4096
},
"openai": {
"api_key": "sk-...",
"model": "gpt-4"
}
}
}
```
> **π‘ Tip**: Bamboo automatically migrates legacy `config.toml` files to the new JSON format.
### π§ Environment Variables
Override configuration with environment variables (higher priority than config file):
| `BAMBOO_PORT` | Server port | `9000` |
| `BAMBOO_BIND` | Bind address | `0.0.0.0` |
| `BAMBOO_DATA_DIR` | Data directory | `/var/lib/bamboo` |
| `BAMBOO_PROVIDER` | Default LLM provider | `anthropic` |
| `RUST_LOG` | Log level | `debug`, `info`, `warn` |
## Migration Guide
### Migrating from v0.1.x to v0.2.0
Version 0.2.0 consolidates `web_service` and `agent::server` into a unified `server` module. If you were using the library API:
#### Before v0.2.0
```rust
use bamboo_agent::agent::server::state::AppState;
use bamboo_agent::agent::server::handlers;
use bamboo_agent::web_service::WebService;
use bamboo_agent::web_service::controllers::*;
```
#### After v0.2.0
```rust
use bamboo_agent::server::AppState;
use bamboo_agent::server::handlers;
use bamboo_agent::server::WebService;
use bamboo_agent::server::controllers::*;
```
All other code works without changes. The old import paths still work but will show deprecation warnings.
### What Changed
**Consolidated Modules:**
- `agent::server::handlers` β `server::handlers`
- `agent::server::state` β `server::app_state`
- `agent::server::workflow` β `server::workflow`
- `web_service::controllers` β `server::controllers`
- `web_service::services` β `server::services`
**Unified State Management:**
- Single `AppState` with direct provider access (no more proxy pattern)
- Consolidated route definitions (eliminated 24 duplicate routes)
- Unified metrics infrastructure
**Breaking Changes:**
- None (all old import paths still work with deprecation warnings)
### Benefits
- β
**No route duplication**: Single source of truth for 100+ routes
- β
**Direct provider access**: No HTTP callbacks to self
- β
**Clearer architecture**: One server module instead of two
- β
**Better performance**: Eliminated proxy pattern
## π API Endpoints
Once running, Bamboo exposes a comprehensive REST API:
### π₯ Health & Status
```bash
# Check server health
GET /api/v1/health
```
### π¬ Chat Completions
```bash
# OpenAI-compatible chat endpoint
POST /api/v1/chat/completions
Content-Type: application/json
{
"model": "claude-3-5-sonnet-20241022",
"messages": [
{"role": "user", "content": "Hello, world!"}
],
"stream": true
}
```
### π€ Agent Execution
```bash
# Execute agent with tools
POST /api/v1/agent/run
Content-Type: application/json
{
"session_id": "my-session",
"message": "Read the README.md file and summarize it"
}
```
### π Workflows
```bash
# List all workflows
GET /api/v1/workflows
# Create new workflow
POST /api/v1/workflows
Content-Type: application/json
{
"name": "my-workflow",
"description": "Automated task",
"composition": {
"type": "sequence",
"steps": [...]
}
}
# Delete workflow
DELETE /api/v1/workflows/{name}
```
### π Sessions
```bash
# List all sessions
GET /api/v1/sessions
# Create new session
POST /api/v1/sessions
Content-Type: application/json
{
"model": "claude-3-5-sonnet-20241022"
}
```
### π Metrics & Monitoring
```bash
# Get usage metrics
GET /api/v1/metrics/summary
# Get session details
GET /api/v1/metrics/sessions/{session_id}
```
> π **Full API Documentation**: See [API.md](docs/API.md) for complete endpoint reference
## π οΈ Development
### π¨ Build & Run
```bash
# Development build (fast compile, slower runtime)
cargo build
# Release build (slower compile, fastest runtime)
cargo build --release
# Run with auto-reload on code changes
cargo watch -x run -- serve
# Run tests
cargo test
# Run tests with coverage
cargo tarpaulin
# Check code formatting
cargo fmt --check
# Fix code formatting
cargo fmt
# Run linter
cargo clippy
```
### π Debugging
```bash
# Enable debug logging
RUST_LOG=debug cargo run -- serve
# Enable trace logging (very verbose)
RUST_LOG=trace cargo run -- serve
# Run specific test
cargo test test_agent_loop
# Run tests with output
cargo test -- --nocapture
```
## ποΈ Architecture
Bamboo is built with a clean, modular architecture optimized for performance and maintainability:
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Bamboo Agent π β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β π HTTP β β π€ Agent β β π§ LLM β β
β β Server β β Loop β β Providers β β
β β β β β β β β
β β - Actix-web β β - Tools β β - OpenAI β β
β β - REST API β β - Skills β β - Anthropic β β
β β - SSE β β - Workflow β β - Gemini β β
β ββββββββββββββββ ββββββββββββββββ β - Copilot β β
β ββββββββββββββββ β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β π Metrics β β πΎ Storage β β π MCP β β
β β β β β β Protocol β β
β β - SQLite β β - JSONL β β β β
β β - Events β β - Sessions β β - Tools β β
β β - Analytics β β - History β β - Servers β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
### Core Modules
| **`config`** π | Configuration management | XDG-compliant, hot-reload, multi-format |
| **`core`** π― | Core types and utilities | Encryption, paths, todo tracking |
| **`agent`** π€ | Agent system | Loop execution, tools, skills, LLM providers |
| **`server`** π | HTTP server & controllers | REST API, streaming, handlers |
| **`process`** βοΈ | Process management | Lifecycle tracking, output buffering |
| **`claude`** π | Claude Code integration | Binary discovery, version management |
| **`commands`** π | Command system | Workflows, slash commands, keyword masking |
### Design Principles
- **π¦ Zero-Cost Abstractions** - Rust's performance guarantees
- **β‘ Async-First** - Tokio-based async runtime
- **π Memory Safe** - No data races or buffer overflows
- **π¦ Self-Contained** - No external runtime dependencies
- **π― Single Responsibility** - Each module has a clear purpose
## π Documentation
| π **[Full Documentation](docs/README.md)** | Comprehensive guides and tutorials |
| π **[API Documentation](https://docs.rs/bamboo-agent)** | Auto-generated API docs (docs.rs) |
| π **[Migration Guide](MIGRATION_GUIDE.md)** | Upgrading from v0.1.x to v0.2.x |
| π€ **[Contributing](CONTRIBUTING.md)** | How to contribute to Bamboo |
| π **[Changelog](CHANGELOG.md)** | Version history and release notes |
| π **[Security Policy](SECURITY.md)** | Security information and reporting |
## π Performance
Bamboo is designed for maximum performance:
- **β‘ Startup Time**: < 100ms to fully operational
- **πΎ Memory Usage**: ~10-30MB base, scales with workload
- **π Concurrent Requests**: 1000+ concurrent connections
- **π Throughput**: 10,000+ requests/second (depends on workload)
- **π Latency**: < 10ms for local operations
## πΊοΈ Roadmap
### Current Version (v0.2.x) β
- [x] Complete agent system
- [x] Multi-LLM provider support
- [x] Workflow automation
- [x] MCP (Model Context Protocol) integration
- [x] Comprehensive metrics & monitoring
### Upcoming Features (v0.3.x) π§
- [ ] Webhook support for external integrations
- [ ] Plugin system for custom tool extensions
- [ ] gRPC API for high-performance clients
- [ ] WebSocket support for bidirectional streaming
- [ ] Built-in web UI dashboard
### Future Plans (v1.0+) π
- [ ] Kubernetes deployment guides & Helm charts
- [ ] Distributed agent execution
- [ ] Advanced workflow visualizer
- [ ] Multi-tenant support
- [ ] Cloud deployment templates
---
## π License
This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.
## π€ Contributing
We love contributions! Whether you're fixing bugs, improving documentation, or proposing new features, your help is welcome.
**Getting Started:**
1. Read our [Contributing Guidelines](CONTRIBUTING.md)
2. Check out [Good First Issues](https://github.com/bigduu/Bamboo-agent/issues?q=is%3Aopen+is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
3. Fork the repo and create a feature branch
4. Submit a Pull Request
**Code of Conduct:** Be respectful, inclusive, and constructive. We're all here to build something great together!
## π¬ Support & Community
### π Bug Reports
Found a bug? [Open an issue](https://github.com/bigduu/Bamboo-agent/issues/new?template=bug_report.md)
### π‘ Feature Requests
Have an idea? [Start a discussion](https://github.com/bigduu/Bamboo-agent/discussions/new?category=ideas)
### π Security Issues
Found a security vulnerability? Please see [SECURITY.md](SECURITY.md) for responsible disclosure.
### π¬ Get Help
- **GitHub Discussions**: Ask questions and share knowledge
- **Documentation**: Check the [full docs](docs/README.md) first
- **Issues**: Search existing issues or create a new one
## π Star History
If you find Bamboo useful, please consider giving it a β star on GitHub! It helps the project grow and lets others discover it.
[](https://star-history.com/#bigduu/Bamboo-agent&Date)
---
<p align="center">
<strong>Made with β€οΈ by the Bamboo Contributors</strong>
</p>
<p align="center">
<sub>Built with π¦ Rust β’ Powered by β Coffee and π Bamboo</sub>
</p>