Rust-native code agent in a single binary
Open-source software engineering agent CLI.
Local startup benchmark β’ Single binary β’ Works offline with Ollama
Installation β’ Features β’ Documentation β’ Contributing
| Claude Code | Aider | Sage | |
|---|---|---|---|
| Startup Time | ~500ms | ~800ms | ~50ms |
| Binary Size | ~200MB | ~100MB | ~15MB |
| Offline Mode | β | β | β Ollama |
| Open Source | β | β | β |
| MCP Support | β | β | β |
| Memory System | β | β | β |
| Single Binary | β | β | β |
macOS / Linux:
curl -fsSL https://raw.githubusercontent.com/majiayu000/sage/main/install.sh | bashCargo (Sage CLI):
cargo install sage-cliHomebrew:
brew install majiayu000/sage/sage- Latest verified GitHub release:
v0.13.57, published on 2026-04-30. - GitHub release archives are the primary binary distribution path for macOS and Linux.
- Native Windows prebuilt release archives are not currently published; use WSL2, source builds, or
cargo install sage-cli. - Cargo installs use the
sage-clipackage (cargo install sage-cli); the root workspace package namedsageis private and is not the CLI package on crates.io. - Homebrew installs use the
majiayu000/sagetap.
# Interactive mode (default)
sage
# Execute task interactively
sage "Create a Python script that fetches GitHub trending repos"
# Print mode - execute and exit (non-interactive)
sage -p "Explain this code"
# Continue most recent session
sage -c
# Resume specific session
sage -r <session-id>- Sage can edit files and run shell commands in the current workspace; review tool requests and run in a trusted checkout.
- Cloud LLM providers require user-supplied API keys. Only Ollama-backed workflows are designed for offline use.
- Web, browser, MCP, and model-list features depend on local services or network availability and may fail when those dependencies are unavailable.
- Startup benchmark numbers measure local process startup only; they do not measure model latency, task quality, or end-to-end coding speed.
- Provider support is limited to the shipped provider set and documented OpenAI-compatible routes.
- Fast startup path - Rust-native binary with a local benchmark script for verification
- Single ~15MB binary - No dependencies, instant install
- Efficient memory - Low footprint, handles large codebases
- Anthropic - Claude-compatible models
- OpenAI - GPT-compatible models
- Google - Gemini-compatible models
- Z.AI - GLM-5.1 and GLM-5
- Moonshot AI - Kimi-compatible models
- Ollama - Llama, Mistral, CodeLlama (offline)
- Azure OpenAI - Enterprise deployments
- OpenRouter - Access 100+ models
- Doubao - ByteDance models
- GLM - Zhipu AI models
| Category | Tools |
|---|---|
| File Ops | Read, Write, Edit, Glob, Grep, NotebookEdit |
| Shell | Bash, KillShell, Task, TaskOutput |
| Web | WebSearch, WebFetch, Browser |
| Planning | TodoWrite, EnterPlanMode, ExitPlanMode |
| Git | Full Git integration |
- Memory System - Learns your coding patterns across sessions
- Checkpoints - Save and restore agent state
- Trajectory Recording - Full execution history for debugging
- MCP Protocol - Extend with Model Context Protocol servers
- Plugin System - Custom tool development
- 16+ Slash Commands -
/resume,/undo,/cost,/plan,/compact,/title, etc. - Session Resume - Continue where you left off (
sage -corsage -r <id>) - Interactive Mode - Multi-turn conversations
- File Change Tracking - Built-in undo support
# Start interactive session
sage
# Or with initial task
sage "Create a REST API with user authentication"> Create a REST API with user authentication
[Sage creates files, runs commands, shows progress...]
> /cost
βββββββββββββββββββββββββββββββββββ
β Session Cost & Usage β
βββββββββββββββββββββββββββββββββββ€
β Input tokens: 12,450 β
β Output tokens: 3,200 β
β Total cost: $0.047 β
βββββββββββββββββββββββββββββββββββ
> /resume
[Shows list of previous sessions...]
To resume: sage -r <session-id>
# Execute task and exit (non-interactive)
sage -p "Add error handling to main.rs"
# With maximum steps
sage --max-steps 30 -p "Refactor the auth module"# Continue most recent session
sage -c
# Resume specific session by ID
sage -r abc123| Command | Description |
|---|---|
/help |
Show help information |
/clear |
Clear conversation history |
/compact |
Summarize and compact context |
/resume [id] |
Resume previous session |
/cost |
Show token usage and cost |
/undo [msg-id] |
Undo file changes |
/plan [open|clear] |
View/manage execution plan |
/checkpoint [name] |
Save current state |
/restore [id] |
Restore to checkpoint |
/context |
Show context usage |
/status |
Show agent status |
/tasks |
List background tasks |
/commands |
List all slash commands |
/title <title> |
Set session title |
/init |
Initialize Sage in project |
/config |
Manage configuration |
/login |
Configure API key for provider |
/logout |
Clear stored credentials |
Create sage_config.json or use environment variables:
{
"default_provider": "anthropic",
"model_providers": {
"anthropic": {
"model": "claude-opus-4-7",
"api_key": "${ANTHROPIC_API_KEY}",
"enable_prompt_caching": true
},
"zai": {
"model": "glm-5.1",
"api_key": "${ZAI_API_KEY}",
"base_url": "https://api.z.ai/api/paas/v4"
},
"moonshot": {
"model": "kimi-k2.6",
"api_key": "${MOONSHOT_API_KEY}",
"base_url": "https://api.moonshot.ai/v1"
},
"ollama": {
"model": "codellama",
"base_url": "http://localhost:11434"
}
},
"max_steps": 20,
"memory": {
"enabled": false,
"storage_path": ".sage/memory/agent-memory.json"
},
"working_directory": "."
}Cross-session memory is opt-in. Set memory.enabled to true to inject bounded,
redacted project memories and learning patterns into future prompts.
# API Keys
export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."
export ZAI_API_KEY="..."
export MOONSHOT_API_KEY="sk-..."
# Configuration
export SAGE_DEFAULT_PROVIDER="anthropic"
export SAGE_MAX_STEPS="30"Use Sage as a library in your Rust projects:
use sage_sdk::{SageAgentSdk, RunOptions};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load from config file
let sdk = SageAgentSdk::with_config_file("sage_config.json")?;
// Or create with default config
// let sdk = SageAgentSdk::new()?;
// Run a task
let options = RunOptions::new().with_max_steps(30);
let result = sdk
.run_with_options("Create a README file", options)
.await?;
println!("Execution completed: {:?}", result.outcome());
Ok(())
}sage/
βββ crates/
β βββ sage-core/ # Core agent logic, LLM providers, session, tools
β βββ sage-cli/ # Command-line interface
β βββ sage-sdk/ # High-level SDK for embedding
β βββ sage-tools/ # Built-in tool implementations
βββ docs/ # Documentation
βββ examples/ # Usage examples
βββ benchmarks/ # Performance benchmarks
Run the startup benchmark:
./benchmarks/startup.shExample output from the benchmark script:
Code Agent Startup Benchmark
ββββββββββββββββββββββββββββ
Agent Avg (ms)
ββββββββββββββββββββββββββββ
sage 45
claude 520
aider 780
Sage is 11.5x faster than Claude Code
Benchmark results depend on hardware, shell startup cost, installed comparison tools, and the selected iteration count. Re-run the script locally before relying on the numbers.
- User Guide - Getting started, configuration, usage
- Architecture - System design, components
- Tools Reference - All available tools
- Development - Contributing, building
Contributions are welcome! Please read our Contributing Guide.
# Clone
git clone https://github.com/majiayu000/sage
cd sage
# Build
cargo build --workspace --release
# Test
cargo test --workspace --all-targets
# Run
./target/release/sage --helpLocal developer state directories such as .claude/ and .omx/ are
intentionally ignored and should not be committed.
MIT License - see LICENSE for details.
Sage is a Rust rewrite inspired by Trae Agent, which is also MIT licensed. Third-party attribution and retained original MIT notices are listed in NOTICE.
Inspired by:
- Claude Code - Anthropic's CLI tool design
- Trae Agent - ByteDance's agent architecture
- Aider - AI pair programming
β Star us on GitHub if you find Sage useful!
Made with π¦ by the Sage Team
