Context Event • Rust AI Agent SDK

ContextEvent: A context event for replay/debugging.

ContextEvent

Defined in the trace module.

Rust AI Agent SDK

A context event for replay/debugging.

Fields

NameTypeDescription
event_typeContextEventTypeEvent type
nameStringEvent name
timestamp_msu64Timestamp (milliseconds since epoch)
agent_idOption<String>Agent ID (if applicable)
agent_nameOption<String>Agent name (if applicable)
tool_nameOption<String>Tool name (if applicable)
inputOption<serde_json::Value>Input data
outputOption<serde_json::Value>Output data
errorOption<String>Error message (if applicable)
duration_msOption<u64>Duration in milliseconds (if applicable)
metadataHashMap<StringAdditional metadata
serde_json:Value>Additional metadata

Methods

new

rust
fn new(event_type: ContextEventType, name: impl Into<String>) -> Self

Create a new context event.

Parameters:

NameType
event_typeContextEventType
nameimpl Into&lt;String&gt;

agent

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

Set agent info.

Parameters:

NameType
idimpl Into&lt;String&gt;
nameimpl Into&lt;String&gt;

tool

rust
fn tool(mut self, name: impl Into<String>) -> Self

Set tool name.

Parameters:

NameType
nameimpl Into&lt;String&gt;

input

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

Set input.

Parameters:

NameType
inputserde_json::Value

output

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

Set output.

Parameters:

NameType
outputserde_json::Value

error

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

Set error.

Parameters:

NameType
errorimpl Into&lt;String&gt;

duration_ms

rust
fn duration_ms(mut self, ms: u64) -> Self

Set duration.

Parameters:

NameType
msu64

metadata

rust
fn metadata(mut self, key: impl Into<String>, value: serde_json::Value) -> Self

Add metadata.

Parameters:

NameType
keyimpl Into&lt;String&gt;
valueserde_json::Value

Source

View on GitHub

praisonai/src/trace/mod.rs at line 486


Related Documentation