Agent • Rust AI Agent SDK

Agent: The core Agent struct Agents are the primary execution unit in PraisonAI. They combine: – LLM provider for generating responses – Tools for…

Agent

Defined in the agent module.

Rust AI Agent SDK

The core Agent struct Agents are the primary execution unit in PraisonAI. They combine: – LLM provider for generating responses – Tools for performing actions – Memory for conversation history – Instructions for behavior

Diagram

Input Data

Agent: Agent

Output Result

Fields

NameTypeDescription
idStringUnique agent ID
nameStringAgent name
instructionsStringSystem instructions
llmArc<dyn LlmProvider>LLM provider
toolsArc<RwLock<ToolRegistry>>Tool registry
memoryArc<RwLock<Memory>>Memory
configAgentConfigConfiguration

Methods

new

rust
fn new() -> AgentBuilder

Create a new agent builder

simple

rust
fn simple(instructions: impl Into<String>) -> Result<Self>

Create an agent with minimal config

Parameters:

NameType
instructionsimpl Into&lt;String&gt;

id

rust
fn id(&self) -> &str

Get the agent ID

name

rust
fn name(&self) -> &str

Get the agent name

instructions

rust
fn instructions(&self) -> &str

Get the instructions

model

rust
fn model(&self) -> &str

Get the LLM model name

chat

rust
async fn chat(&self, prompt: &str) -> Result<String>

Chat with the agent (main entry point) This is the primary method for interacting with an agent. It handles the full conversation loop including tool calls.

Parameters:

NameType
prompt&str

start

rust
async fn start(&self, prompt: &str) -> Result<String>

Start a conversation (alias for chat)

Parameters:

NameType
prompt&str

run

rust
async fn run(&self, task: &str) -> Result<String>

Run a task (alias for chat)

Parameters:

NameType
task&str

add_tool

rust
async fn add_tool(&self, tool: impl Tool + 'static) -> ()

Add a tool to the agent

Parameters:

NameType
toolimpl Tool + 'static

tool_count

rust
async fn tool_count(&self) -> usize

Get the number of tools

clear_memory

rust
async fn clear_memory(&self) -> Result<()>

Clear conversation memory

history

rust
async fn history(&self) -> Result<Vec<Message>>

Get conversation history

Source

View on GitHub

praisonai/src/agent/mod.rs at line 39


Related Documentation