A Rust-native coding-agent runtime with composable LLM support.
Project details
This project provides a Rust-native, library-first runtime for building coding agents. With its modular architecture and support for various LLM providers, tools, and plugins, it enables developers to quickly implement complex , effective solutions. The rpi CLI makes experimentation and deployment more straightforward for users. Discover a powerful new way to develop intelligent applications.
pi-rust is a sophisticated Rust-native coding-agent runtime that emphasizes a library-first design approach, tailored for terminal CLI usage. Inspired by the Pi SDK, this multi-crate implementation enables developers to construct composable large language model (LLM) agents, integrating various providers, tools, sessions, and plugins seamlessly.
rpi command-line interface offers instantaneous access to its features, making it straightforward to test and utilize the complete coding loop.The project consists of several published crates, each prefixed with rpi-, providing distinct functionalities:
| Crate Name | Description |
|---|---|
rpi-telemetry | Manages telemetry span/event contracts with a noop default. |
rpi-ai | Implements unified multi-provider LLM types and supports streaming for various models. |
rpi-agent | The runtime for the agent's operational loop, including event handling and queues. |
rpi-tools | Offers coding tools compatible with Pi, such as read, write, and edit. |
rpi-harness | Provides session management, JSONL persistence, and a run loop for agents. |
rpi-cli | The command-line tool that serves as the primary interface for interacting with the library. |
rpi-plugin-sdk | Defines the ABI for developing Rust-native plugins, facilitating seamless extension discovery. |
rpi-extensions | Enables dynamic loading of plugins, enhancing functionality through additional tools. |
rpi-tui | Incorporates terminal UI primitives to improve the interactive CLI experience. |
Creating a coding agent with pi-rust is intuitive. A straightforward example illustrates the use of the rpi framework:
use rpi_agent::{AgentBuilder, AgentEvent};
use rpi_ai::providers::faux::{FauxProvider, FauxScript};
let provider = std::sync::Arc::new(FauxProvider::new(FauxScript::new().with_text("Hello!")));
let model = provider.default_model().clone();
let agent = AgentBuilder::new()
.model(model)
.system_prompt("You are a helpful assistant.")
.tools(vec![/* MyTool */])
.stream_fn(make_stream_fn(provider))
.build()
.unwrap();
let mut events = agent.subscribe();
tokio::spawn(async move {
while let Some(ev) = events.recv().await {
match ev { /* AgentEvent::MessageUpdate { .. }, etc. */ }
}
});
agent.prompt("Hello!").await.unwrap();
This snippet highlights the simplicity of building an agent with integrated functionalities, demonstrating the flexibility of the API.
Creating plugins is streamlined with the rpi-plugin-sdk, facilitating the publication of Rust cdylib libraries. For instance, the following command builds a simple echo tool plugin:
cargo build -p plugin-stub
This empowers developers to readily extend the agent's capabilities, linking new functionality through dynamic libraries.
Extensions can be easily managed using the rpi CLI. The system is designed to allow seamless installation of packages from crates.io, simplifying the integration of new features and functionality:
rpi install rpi-extension-example
By combining the power of Rust with a flexible coding-agent architecture, pi-rust is positioned as a valuable tool for developers looking to harness the power of LLMs in their coding or automation tasks. For full documentation, refer to the project's website and the complete design documentation.
Comments
0Start the conversation
Share the first comment.