> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 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**](../modules/agent) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

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

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%

graph LR
    input["Input Data"] --> agent["Agent: Agent"]
    agent --> output["Output Result"]
    style agent fill:#8B0000,color:#fff
    style input fill:#8B0000,color:#fff
    style output fill:#8B0000,color:#fff
```

## Fields

| Name           | Type                                    | Description         |
| -------------- | --------------------------------------- | ------------------- |
| `id`           | `String`                                | Unique agent ID     |
| `name`         | `String`                                | Agent name          |
| `instructions` | `String`                                | System instructions |
| `llm`          | `Arc&lt;dyn LlmProvider&gt;`            | LLM provider        |
| `tools`        | `Arc&lt;RwLock&lt;ToolRegistry&gt;&gt;` | Tool registry       |
| `memory`       | `Arc&lt;RwLock&lt;Memory&gt;&gt;`       | Memory              |
| `config`       | `AgentConfig`                           | Configuration       |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new() -> AgentBuilder
```

Create a new agent builder

### `simple`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn simple(instructions: impl Into<String>) -> Result<Self>
```

Create an agent with minimal config

**Parameters:**

| Name           | Type                      |
| -------------- | ------------------------- |
| `instructions` | `impl Into&lt;String&gt;` |

### `id`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn id(&self) -> &str
```

Get the agent ID

### `name`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn name(&self) -> &str
```

Get the agent name

### `instructions`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn instructions(&self) -> &str
```

Get the instructions

### `model`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn model(&self) -> &str
```

Get the LLM model name

### `chat`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn start(&self, prompt: &str) -> Result<String>
```

Start a conversation (alias for chat)

**Parameters:**

| Name     | Type   |
| -------- | ------ |
| `prompt` | `&str` |

### `run`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn run(&self, task: &str) -> Result<String>
```

Run a task (alias for chat)

**Parameters:**

| Name   | Type   |
| ------ | ------ |
| `task` | `&str` |

### `add_tool`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn add_tool(&self, tool: impl Tool + 'static) -> ()
```

Add a tool to the agent

**Parameters:**

| Name   | Type                  |
| ------ | --------------------- |
| `tool` | `impl Tool + 'static` |

### `tool_count`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn tool_count(&self) -> usize
```

Get the number of tools

### `clear_memory`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn clear_memory(&self) -> Result<()>
```

Clear conversation memory

### `history`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn history(&self) -> Result<Vec<Message>>
```

Get conversation history

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/agent/mod.rs#L39">
  `praisonai/src/agent/mod.rs` at line 39
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Agent" icon="robot" href="/docs/rust/agent" />

  <Card title="Rust Overview" icon="book-open" href="/docs/rust/overview" />

  <Card title="Rust Quickstart" icon="rocket" href="/docs/rust/quickstart" />

  <Card title="Rust Installation" icon="download" href="/docs/rust/installation" />

  <Card title="Rust Autonomy" icon="wand-magic-sparkles" href="/docs/rust/autonomy" />
</CardGroup>
