pub struct SessionState { /* private fields */ }Expand description
The free-form state bag of an AgentSession, shared by reference
across clones.
Upstream’s AgentSession.state is a plain Python dict, and Python
sessions are reference types: every holder of the session sees the same
dict, including the child session as_tool(propagate_session=True)
hands a sub-agent (upstream shares the dict by reference while isolating
service_session_id). A by-value HashMap cannot express that, so the
state bag is an Arc<Mutex<..>> handle: cloning an AgentSession
(or a SessionState) yields a view onto the same bag, and mutations
through any clone are visible to all of them.
Implementations§
Source§impl SessionState
impl SessionState
Sourcepub fn new() -> SessionState
pub fn new() -> SessionState
A fresh, empty state bag.
Sourcepub fn insert(&self, key: impl Into<String>, value: Value) -> Option<Value>
pub fn insert(&self, key: impl Into<String>, value: Value) -> Option<Value>
Insert value at key, returning the previous value if any.
Sourcepub fn remove(&self, key: &str) -> Option<Value>
pub fn remove(&self, key: &str) -> Option<Value>
Remove and return the value at key, if present.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Whether key is present.
Sourcepub fn snapshot(&self) -> HashMap<String, Value>
pub fn snapshot(&self) -> HashMap<String, Value>
A point-in-time copy of the whole bag (e.g. for serialization).
Whether other is a view onto the same underlying bag.
Trait Implementations§
Source§impl Clone for SessionState
impl Clone for SessionState
Source§fn clone(&self) -> SessionState
fn clone(&self) -> SessionState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more