Skip to main content

AgentState

Trait AgentState 

Source
pub trait AgentState:
    'static
    + Debug
    + Clone
    + Send
    + Sync
    + for<'de> Deserialize<'de>
    + Serialize
    + Default { }
Expand description

Marker trait for types that can represent agent state.

Types implementing this trait can be used as the state type in state-related events (StateSnapshot, StateDelta, etc.).

§Bounds

  • 'static: Required for async operations
  • Debug: For debugging and logging
  • Clone: State may need to be copied
  • Send + Sync: For thread-safe async operations
  • Serialize + Deserialize: For JSON serialization
  • Default: For initializing empty state

§Example

use ag_ui_core::AgentState;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
struct MyState {
    counter: u32,
    messages: Vec<String>,
}

impl AgentState for MyState {}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl AgentState for ()

Implementors§