| Crates.io | smolagents-rs |
| lib.rs | smolagents-rs |
| version | 0.1.2 |
| created_at | 2025-02-14 22:48:17.794075+00 |
| updated_at | 2025-02-18 10:22:20.83408+00 |
| description | A rust port of the the HuggingFace smolagents library. Build LLM agents with tools and code execution. |
| homepage | |
| repository | https://github.com/akshayballal95/smolagents-rs |
| max_upload_size | |
| id | 1556103 |
| size | 245,568 |
This is a rust implementation of HF smolagents library. It provides a powerful autonomous agent framework written in Rust that solves complex tasks using tools and LLM models.

Warning: Since there is no implementation of a Sandbox environment, be careful with the tools you use. Preferrably run the agent in a controlled environment using a Docker container.
# Pull the image
docker pull your-username/smolagents-rs:latest
# Run with your OpenAI API key
docker run -e OPENAI_API_KEY=your-key-here smolagents-rs -t "What is the latest news about Rust programming?"
# Clone the repository
git clone https://github.com/yourusername/smolagents-rs.git
cd smolagents-rs
# Build the project
cargo build --release --features cli-deps
# Run the agent
OPENAI_API_KEY=your-key-here ./target/release/smolagents-rs -t "Your task here"
smolagents-rs [OPTIONS] -t TASK
Options:
-t, --task <TASK> The task to execute
-a, --agent-type <TYPE> Agent type [default: function-calling]
-l, --tools <TOOLS> Comma-separated list of tools [default: duckduckgo,visit-website]
-m, --model <TYPE> Model type [default: open-ai]
-k, --api-key <KEY> OpenAI API key (only required for OpenAI model)
--model-id <ID> Model ID (e.g., "gpt-4" for OpenAI or "qwen2.5" for Ollama) [default: gpt-4o-mini]
-u, --ollama-url <URL> Ollama server URL [default: http://localhost:11434]
-s, --stream Enable streaming output
-h, --help Print help
# Simple search task
smolagents-rs -t "What are the main features of Rust 1.75?"
# Research with multiple tools
smolagents-rs -t "Compare Rust and Go performance" -l duckduckgo,google-search,visit-website
# Stream output for real-time updates
smolagents-rs -t "Analyze the latest crypto trends" -s
OPENAI_API_KEY: Your OpenAI API key (required).SERPAPI_API_KEY: Google Search API key (optional).The project follows a modular architecture with the following components:
Agent System: Implements the ReAct framework.
Tool System: An extensible tool framework for seamless integration of new tools.
Model Integration: Robust OpenAI API integration for powerful LLM capabilities.
Rust provides critical advantages that make it the ideal choice for smolagents-rs:
⚡ High Performance:
Zero-cost abstractions and no garbage collector overhead enable smolagents-rs to handle complex agent tasks with near-native performance. This is crucial for running multiple agents and processing large amounts of data efficiently.
🛡️ Memory Safety & Security:
Rust's compile-time guarantees prevent memory-related vulnerabilities and data races - essential for an agent system that handles sensitive API keys and interacts with external resources. The ownership model ensures thread-safe concurrent operations without runtime overhead.
🔄 Powerful Concurrency:
Fearless concurrency through the ownership system enable smolagents-rs to efficiently manage multiple agents and tools in parallel, maximizing resource utilization.
💻 Universal Deployment:
Compile once, run anywhere - from high-performance servers to WebAssembly in browsers. This allows smolagents-rs to run natively on any platform or be embedded in web applications with near-native performance.
Apart from this, its essential to push new technologies around agentic systems to the Rust ecoystem and this library aims to do so.
Contributions are welcome! To contribute:
Fork the repository.
Create your feature branch (git checkout -b feature/amazing-feature).
Commit your changes (git commit -m 'Add some amazing feature').
Push to the branch (git push origin feature/amazing-feature).
Open a Pull Request.
Give a ⭐️ if this project helps you or inspires your work!