Event • Rust AI Agent SDK

Event: An event in the event bus.

Event

Defined in the bus module.

Rust AI Agent SDK

An event in the event bus.

Fields

NameTypeDescription
event_typeEventTypeEvent type
sourceStringSource of the event (agent name, tool name, etc.)
dataserde_json::ValueEvent data
timestampu64Timestamp (Unix millis)
correlation_idOption<String>Correlation ID for tracing

Methods

new

rust
fn new(event_type: EventType, source: impl Into<String>) -> Self

Create a new event

Parameters:

NameType
event_typeEventType
sourceimpl Into&lt;String&gt;

data

rust
fn data(mut self, data: serde_json::Value) -> Self

Set event data

Parameters:

NameType
dataserde_json::Value

correlation_id

rust
fn correlation_id(mut self, id: impl Into<String>) -> Self

Set correlation ID

Parameters:

NameType
idimpl Into&lt;String&gt;

agent_start

rust
fn agent_start(agent_name: impl Into<String>) -> Self

Create agent start event

Parameters:

NameType
agent_nameimpl Into&lt;String&gt;

agent_end

rust
fn agent_end(agent_name: impl Into<String>) -> Self

Create agent end event

Parameters:

NameType
agent_nameimpl Into&lt;String&gt;

agent_error

rust
fn agent_error(agent_name: impl Into<String>, error: impl Into<String>) -> Self

Create agent error event

Parameters:

NameType
agent_nameimpl Into&lt;String&gt;
errorimpl Into&lt;String&gt;

tool_start

rust
fn tool_start(tool_name: impl Into<String>) -> Self

Create tool start event

Parameters:

NameType
tool_nameimpl Into&lt;String&gt;

tool_end

rust
fn tool_end(tool_name: impl Into<String>) -> Self

Create tool end event

Parameters:

NameType
tool_nameimpl Into&lt;String&gt;

tool_error

rust
fn tool_error(tool_name: impl Into<String>, error: impl Into<String>) -> Self

Create tool error event

Parameters:

NameType
tool_nameimpl Into&lt;String&gt;
errorimpl Into&lt;String&gt;

llm_request

rust
fn llm_request(model: impl Into<String>) -> Self

Create LLM request event

Parameters:

NameType
modelimpl Into&lt;String&gt;

llm_response

rust
fn llm_response(model: impl Into<String>) -> Self

Create LLM response event

Parameters:

NameType
modelimpl Into&lt;String&gt;

workflow_start

rust
fn workflow_start(workflow_name: impl Into<String>) -> Self

Create workflow start event

Parameters:

NameType
workflow_nameimpl Into&lt;String&gt;

workflow_end

rust
fn workflow_end(workflow_name: impl Into<String>) -> Self

Create workflow end event

Parameters:

NameType
workflow_nameimpl Into&lt;String&gt;

handoff_start

rust
fn handoff_start(source: impl Into<String>, target: impl Into<String>) -> Self

Create handoff start event

Parameters:

NameType
sourceimpl Into&lt;String&gt;
targetimpl Into&lt;String&gt;

handoff_end

rust
fn handoff_end(source: impl Into<String>, target: impl Into<String>) -> Self

Create handoff end event

Parameters:

NameType
sourceimpl Into&lt;String&gt;
targetimpl Into&lt;String&gt;

custom

rust
fn custom(source: impl Into<String>, data: serde_json::Value) -> Self

Create custom event

Parameters:

NameType
sourceimpl Into&lt;String&gt;
dataserde_json::Value

Source

View on GitHub

praisonai/src/bus/mod.rs at line 73