Skip to main content

Session

Trait Session 

Source
pub trait Session: Send + Sync {
    // Required methods
    fn id(&self) -> &str;
    fn app_name(&self) -> &str;
    fn user_id(&self) -> &str;
    fn state(&self) -> &dyn State;
    fn conversation_history(&self) -> Vec<Content>;

    // Provided methods
    fn conversation_history_for_agent(&self, _agent_name: &str) -> Vec<Content> { ... }
    fn append_to_history(&self, _content: Content) { ... }
    fn try_app_name(&self) -> Result<AppName, AdkError> { ... }
    fn try_user_id(&self) -> Result<UserId, AdkError> { ... }
    fn try_session_id(&self) -> Result<SessionId, AdkError> { ... }
    fn try_identity(&self) -> Result<AdkIdentity, AdkError> { ... }
}
Expand description

Represents an active conversation session with identity and state.

Required Methods§

Source

fn id(&self) -> &str

Returns the session identifier.

Source

fn app_name(&self) -> &str

Returns the application name this session belongs to.

Source

fn user_id(&self) -> &str

Returns the user identifier for this session.

Source

fn state(&self) -> &dyn State

Returns the mutable state associated with this session.

Source

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

Returns the conversation history from this session as Content items

Provided Methods§

Source

fn conversation_history_for_agent(&self, _agent_name: &str) -> Vec<Content>

Returns conversation history filtered for a specific agent.

When provided, events authored by other agents (not “user”, not the named agent, and not function/tool responses) are excluded. This prevents a transferred sub-agent from seeing the parent’s tool calls mapped as “model” role, which would cause the LLM to think work is already done.

Default implementation delegates to conversation_history.

Source

fn append_to_history(&self, _content: Content)

Append content to conversation history (for sequential agent support)

Source

fn try_app_name(&self) -> Result<AppName, AdkError>

Returns the application name as a typed AppName.

Parses the value returned by app_name(). Returns an error if the raw string fails validation (empty, null bytes, or exceeds the maximum length).

§Errors

Returns an error when the underlying string is not a valid identifier.

Source

fn try_user_id(&self) -> Result<UserId, AdkError>

Returns the user identifier as a typed UserId.

Parses the value returned by user_id(). Returns an error if the raw string fails validation.

§Errors

Returns an error when the underlying string is not a valid identifier.

Source

fn try_session_id(&self) -> Result<SessionId, AdkError>

Returns the session identifier as a typed SessionId.

Parses the value returned by id(). Returns an error if the raw string fails validation.

§Errors

Returns an error when the underlying string is not a valid identifier.

Source

fn try_identity(&self) -> Result<AdkIdentity, AdkError>

Returns the stable session-scoped AdkIdentity triple.

Combines try_app_name(), try_user_id(), and try_session_id() into a single composite identity value.

§Errors

Returns an error if any of the three constituent identifiers fail validation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§