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
Fields
| Name | Type | Description |
|---|---|---|
id | String | Unique agent ID |
name | String | Agent name |
instructions | String | System instructions |
llm | Arc<dyn LlmProvider> | LLM provider |
tools | Arc<RwLock<ToolRegistry>> | Tool registry |
memory | Arc<RwLock<Memory>> | Memory |
config | AgentConfig | Configuration |
Methods
new
fn new() -> AgentBuilderCreate a new agent builder
simple
fn simple(instructions: impl Into<String>) -> Result<Self>Create an agent with minimal config
Parameters:
| Name | Type |
|---|---|
instructions | impl Into<String> |
id
fn id(&self) -> &strGet the agent ID
name
fn name(&self) -> &strGet the agent name
instructions
fn instructions(&self) -> &strGet the instructions
model
fn model(&self) -> &strGet the LLM model name
chat
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:
| Name | Type |
|---|---|
prompt | &str |
start
async fn start(&self, prompt: &str) -> Result<String>Start a conversation (alias for chat)
Parameters:
| Name | Type |
|---|---|
prompt | &str |
run
async fn run(&self, task: &str) -> Result<String>Run a task (alias for chat)
Parameters:
| Name | Type |
|---|---|
task | &str |
add_tool
async fn add_tool(&self, tool: impl Tool + 'static) -> ()Add a tool to the agent
Parameters:
| Name | Type |
|---|---|
tool | impl Tool + 'static |
tool_count
async fn tool_count(&self) -> usizeGet the number of tools
clear_memory
async fn clear_memory(&self) -> Result<()>Clear conversation memory
history
async fn history(&self) -> Result<Vec<Message>>Get conversation history
Source
View on GitHubpraisonai/src/agent/mod.rs at line 39