MutableSession

Struct MutableSession 

Source
pub struct MutableSession { /* private fields */ }
Expand description

MutableSession wraps a session with shared mutable state.

This mirrors ADK-Go’s MutableSession pattern where state changes from events are immediately visible to all agents sharing the same context. This is critical for SequentialAgent/LoopAgent patterns where downstream agents need to read state set by upstream agents via output_key.

Implementations§

Source§

impl MutableSession

Source

pub fn new(session: Arc<dyn AdkSession>) -> Self

Create a new MutableSession from a session snapshot. The state is copied from the session and becomes mutable.

Source

pub fn apply_state_delta(&self, delta: &HashMap<String, Value>)

Apply state delta from an event to the mutable state. This is called by the Runner when events are yielded.

Source

pub fn append_event(&self, event: Event)

Append an event to the session’s event list. This keeps the in-memory view consistent.

Trait Implementations§

Source§

impl Session for MutableSession

Source§

fn id(&self) -> &str

Source§

fn app_name(&self) -> &str

Source§

fn user_id(&self) -> &str

Source§

fn state(&self) -> &dyn State

Source§

fn conversation_history(&self) -> Vec<Content>

Returns the conversation history from this session as Content items
Source§

impl State for MutableSession

Source§

fn get(&self, key: &str) -> Option<Value>

Source§

fn set(&mut self, key: String, value: Value)

Source§

fn all(&self) -> HashMap<String, Value>

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.