| Crates.io | agentsmith |
| lib.rs | agentsmith |
| version | 0.1.1 |
| created_at | 2025-11-17 12:41:00.497139+00 |
| updated_at | 2025-11-17 12:41:00.497139+00 |
| description | AI Agent forging utilities. |
| homepage | https://github.com/cryptopatrick/agentsmith |
| repository | https://github.com/cryptopatrick/agentsmith |
| max_upload_size | |
| id | 1936735 |
| size | 121,992 |
Author's bio: ๐๐ Hi, I'm CryptoPatrick! I'm currently enrolled as an
Undergraduate student in Mathematics, at Chalmers & the University of Gothenburg, Sweden.
If you have any questions or need more info, then please join my Discord Channel: AiMath
What is AgentSmith โข Features โข How To Use โข Documentation โข License
agentsmith is a Rust library that provides AI agents with persistent, fuzzy-searchable, metadata-rich memory that survives process restarts. Inspired by Atuin for shell history, AgentSmith ensures your agents never forget past conversations.
Built specifically for Rig agents, AgentSmith wraps your existing agents with a memory layer that automatically:
agentsmith provides a complete memory layer for AI agents with persistent storage and intelligent retrieval:
Add agentsmith to your Cargo.toml:
[dependencies]
agentsmith = "0.1"
Or install with cargo:
cargo add agentsmith
use agentsmith::{AgentHistory, SmartAgent};
use rig::providers::openai;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create persistent history
let history = AgentHistory::new("my_agent.db", Some("session-123")).await?;
// Create your Rig agent
let client = openai::Client::new(&std::env::var("OPENAI_API_KEY")?);
let agent = client
.agent("gpt-4")
.preamble("You are a helpful AI assistant with a perfect memory.")
.build();
// Wrap with SmartAgent for automatic memory
let mut smart_agent = SmartAgent::new(agent, history);
// Chat with automatic recall of relevant past interactions
let reply = smart_agent.chat("How did we fix the JSON parsing bug?").await?;
println!("Agent: {}", reply);
Ok(())
}
use agentsmith::{AgentHistory, Trace};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create history with custom session ID
let history = AgentHistory::new("./chat.db", Some("debug-session")).await?;
// Search past conversations
let results = history.search("bug fix", 10, false).await?;
for trace in results {
println!("[{}] {}: {}",
trace.created_at.format("%Y-%m-%d %H:%M:%S"),
trace.role,
trace.content
);
}
// Get recent messages
let recent = history.recent(5).await?;
println!("Found {} recent messages", recent.len());
// Manually add traces
history.add_trace("user", "What's the status?").await?;
history.add_trace("assistant", "All systems operational").await?;
Ok(())
}
The repository includes several examples demonstrating different features:
# Persistent chat REPL that remembers across restarts
cargo run --example persistent_chat
# Demonstrate Atuin-style search capabilities
cargo run --example atuin_search_demo
# Import conversation logs from other sources
cargo run --example import_old_logs
# Basic usage example
cargo run --example basic
Run the test suite:
# Run all tests
cargo test
# Run with output
cargo test -- --nocapture
Comprehensive documentation is available at docs.rs/agentsmith, including:
Keybase Verification: https://keybase.io/cryptopatrick/sigs/8epNh5h2FtIX1UNNmf8YQ-k33M8J-Md4LnAN
Leave a โญ if you think this project is cool.
This project is licensed under MIT. See LICENSE for details.