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
| Name | Type | Description |
|---|---|---|
event_type | ContextEventType | Event type |
name | String | Event name |
timestamp_ms | u64 | Timestamp (milliseconds since epoch) |
agent_id | Option<String> | Agent ID (if applicable) |
agent_name | Option<String> | Agent name (if applicable) |
tool_name | Option<String> | Tool name (if applicable) |
input | Option<serde_json::Value> | Input data |
output | Option<serde_json::Value> | Output data |
error | Option<String> | Error message (if applicable) |
duration_ms | Option<u64> | Duration in milliseconds (if applicable) |
metadata | HashMap<String | Additional metadata |
serde_json | :Value> | Additional metadata |
Methods
new
fn new(event_type: ContextEventType, name: impl Into<String>) -> SelfCreate a new context event.
Parameters:
| Name | Type |
|---|---|
event_type | ContextEventType |
name | impl Into<String> |
agent
fn agent(mut self, id: impl Into<String>, name: impl Into<String>) -> SelfSet agent info.
Parameters:
| Name | Type |
|---|---|
id | impl Into<String> |
name | impl Into<String> |
tool
fn tool(mut self, name: impl Into<String>) -> SelfSet tool name.
Parameters:
| Name | Type |
|---|---|
name | impl Into<String> |
input
fn input(mut self, input: serde_json::Value) -> SelfSet input.
Parameters:
| Name | Type |
|---|---|
input | serde_json::Value |
output
fn output(mut self, output: serde_json::Value) -> SelfSet output.
Parameters:
| Name | Type |
|---|---|
output | serde_json::Value |
error
fn error(mut self, error: impl Into<String>) -> SelfSet error.
Parameters:
| Name | Type |
|---|---|
error | impl Into<String> |
duration_ms
fn duration_ms(mut self, ms: u64) -> SelfSet duration.
Parameters:
| Name | Type |
|---|---|
ms | u64 |
metadata
fn metadata(mut self, key: impl Into<String>, value: serde_json::Value) -> SelfAdd metadata.
Parameters:
| Name | Type |
|---|---|
key | impl Into<String> |
value | serde_json::Value |
Source
View on GitHubpraisonai/src/trace/mod.rs at line 486