> ## 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.

# Event • Rust AI Agent SDK

> Event: An event in the event bus.

# Event

> Defined in the [**bus**](../modules/bus) module.

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

An event in the event bus.

## Fields

| Name             | Type                   | Description                                       |
| ---------------- | ---------------------- | ------------------------------------------------- |
| `event_type`     | `EventType`            | Event type                                        |
| `source`         | `String`               | Source of the event (agent name, tool name, etc.) |
| `data`           | `serde_json::Value`    | Event data                                        |
| `timestamp`      | `u64`                  | Timestamp (Unix millis)                           |
| `correlation_id` | `Option&lt;String&gt;` | Correlation ID for tracing                        |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new(event_type: EventType, source: impl Into<String>) -> Self
```

Create a new event

**Parameters:**

| Name         | Type                      |
| ------------ | ------------------------- |
| `event_type` | `EventType`               |
| `source`     | `impl Into&lt;String&gt;` |

### `data`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn data(mut self, data: serde_json::Value) -> Self
```

Set event data

**Parameters:**

| Name   | Type                |
| ------ | ------------------- |
| `data` | `serde_json::Value` |

### `correlation_id`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn correlation_id(mut self, id: impl Into<String>) -> Self
```

Set correlation ID

**Parameters:**

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

### `agent_start`

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

Create agent start event

**Parameters:**

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

### `agent_end`

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

Create agent end event

**Parameters:**

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

### `agent_error`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn agent_error(agent_name: impl Into<String>, error: impl Into<String>) -> Self
```

Create agent error event

**Parameters:**

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

### `tool_start`

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

Create tool start event

**Parameters:**

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

### `tool_end`

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

Create tool end event

**Parameters:**

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

### `tool_error`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn tool_error(tool_name: impl Into<String>, error: impl Into<String>) -> Self
```

Create tool error event

**Parameters:**

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

### `llm_request`

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

Create LLM request event

**Parameters:**

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

### `llm_response`

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

Create LLM response event

**Parameters:**

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

### `workflow_start`

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

Create workflow start event

**Parameters:**

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

### `workflow_end`

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

Create workflow end event

**Parameters:**

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

### `handoff_start`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn handoff_start(source: impl Into<String>, target: impl Into<String>) -> Self
```

Create handoff start event

**Parameters:**

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

### `handoff_end`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn handoff_end(source: impl Into<String>, target: impl Into<String>) -> Self
```

Create handoff end event

**Parameters:**

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

### `custom`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn custom(source: impl Into<String>, data: serde_json::Value) -> Self
```

Create custom event

**Parameters:**

| Name     | Type                      |
| -------- | ------------------------- |
| `source` | `impl Into&lt;String&gt;` |
| `data`   | `serde_json::Value`       |

## Source

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