| Crates.io | radkit |
| lib.rs | radkit |
| version | 0.0.2 |
| created_at | 2025-08-26 13:43:00.893356+00 |
| updated_at | 2025-09-08 10:23:21.987516+00 |
| description | Rust AI Agent Development Kit |
| homepage | https://radkit.dev |
| repository | https://github.com/microagents/radkit |
| max_upload_size | |
| id | 1811161 |
| size | 839,297 |
Radkit is an agent framework for building AI agents in Rust. It aims to provide comprehensive support for the A2A (Agent-to-Agent) Protocol.
Radkit offers:
[dependencies]
radkit = "0.0.2"
futures = "0.3.31"
tokio = "1.47.1"
uuid = "1.18.0"
dotenvy = "0.15.7"
Create a .env file with your Anthropic API key:
ANTHROPIC_API_KEY="YOUR_API_KEY"
Then, create an agent and send a message:
use futures::StreamExt;
use radkit::a2a::{
Message, MessageRole, MessageSendParams, Part, SendStreamingMessageResult, TaskState,
};
use radkit::agents::{Agent, AgentConfig};
use radkit::models::AnthropicLlm;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables from .env file.
dotenvy::dotenv()?;
// Create an LLM provider (supports Anthropic, Gemini, and Mock providers)
let llm = Arc::new(AnthropicLlm::new(
"claude-3-5-sonnet-20241022".to_string(),
std::env::var("ANTHROPIC_API_KEY")?,
));
// Create an agent with built-in task management tools
let agent = Agent::new(
"research_assistant".to_string(),
"Research Assistant".to_string(),
"You are a helpful research assistant. When working on tasks, \
always use update_status to indicate your progress (e.g., 'working' \
when processing, 'completed' when done). When you produce any \
results or findings, save them using save_artifact so they can be \
retrieved later."
.to_string(),
llm,
)
.with_config(AgentConfig::default().with_max_iterations(10))
.with_builtin_task_tools(); // Enables update_status and save_artifact tools
// User simply asks for research - no mention of tools
let message = Message {
kind: "message".to_string(),
message_id: uuid::Uuid::new_v4().to_string(),
role: MessageRole::User,
parts: vec![Part::Text {
text: "Can you research the Fibonacci sequence and create a \
summary of its properties and applications?"
.to_string(),
metadata: None,
}],
context_id: None, // New session will be created
task_id: None, // New task will be created
reference_task_ids: Vec::new(),
extensions: Vec::new(),
metadata: None,
};
// Stream the execution to capture real-time A2A protocol events
let mut execution = agent
.send_streaming_message(
"my_app".to_string(),
"user123".to_string(),
MessageSendParams {
message,
configuration: None,
metadata: None,
},
)
.await?;
let mut status_events = 0;
let mut artifact_events = 0;
let mut final_task = None;
// Process streaming results and capture A2A protocol events
while let Some(event) = execution.a2a_stream.next().await {
match event {
SendStreamingMessageResult::TaskStatusUpdate(status_event) => {
status_events += 1;
println!("š Status Update: {:?}", status_event.status.state);
if status_event.status.message.is_some() {
println!(
" Message: {:?}",
status_event.status.message.as_ref().unwrap()
);
}
}
SendStreamingMessageResult::TaskArtifactUpdate(artifact_event) => {
artifact_events += 1;
println!("š¾ Artifact Saved: {:?}", artifact_event.artifact.name);
}
SendStreamingMessageResult::Task(task) => {
println!("ā
Task Completed: {}", task.id);
final_task = Some(task);
break;
}
_ => {} // Handle other events as needed
}
}
// Examine the final task state
if let Some(task) = final_task {
println!("\nš Final Results:");
println!(" Task State: {:?}", task.status.state);
println!(" Messages: {}", task.history.len());
println!(" Artifacts: {}", task.artifacts.len());
// Check the saved artifact content
if let Some(artifact) = task.artifacts.first() {
if let Some(Part::Text { text, .. }) = artifact.parts.first() {
println!(
" Artifact Content Preview: {}",
&text[..text.len().min(200)]
);
}
}
}
Ok(())
}
message/send, message/stream, tasks/getTaskStatusUpdate and TaskArtifactUpdate eventsSubmitted ā Working ā [InputRequired/AuthRequired] ā Completed/Failedupdate_status and save_artifact with event emissionCurrent Version: 0.0.1 (Work in Progress - Major Architecture Complete)
ā Completed Features:
š§ Coming Soon:
Radkit is licensed under the Apache 2.0 License. See LICENSE for details.