Skip to main content

InvocationContext

Struct InvocationContext 

Source
pub struct InvocationContext { /* private fields */ }

Implementations§

Source§

impl InvocationContext

Source

pub fn new( invocation_id: String, agent: Arc<dyn Agent>, user_id: String, app_name: String, session_id: String, user_content: Content, session: Arc<dyn AdkSession>, ) -> Self

Source

pub fn with_mutable_session( invocation_id: String, agent: Arc<dyn Agent>, user_id: String, app_name: String, session_id: String, user_content: Content, session: Arc<MutableSession>, ) -> Self

Create an InvocationContext with an existing MutableSession. This allows sharing the same mutable session across multiple contexts (e.g., for agent transfers).

Source

pub fn with_branch(self, branch: String) -> Self

Source

pub fn with_artifacts(self, artifacts: Arc<dyn Artifacts>) -> Self

Source

pub fn with_memory(self, memory: Arc<dyn Memory>) -> Self

Source

pub fn with_run_config(self, config: RunConfig) -> Self

Source

pub fn with_request_context(self, ctx: RequestContext) -> Self

Set the request context from the server’s auth middleware bridge.

When set, user_id() returns request_context.user_id (overriding the session-scoped identity), and user_scopes() returns request_context.scopes. This is the explicit authenticated user override — RequestContext remains separate from ExecutionIdentity and AdkIdentity (it does not carry session or invocation IDs).

Source

pub fn mutable_session(&self) -> &Arc<MutableSession>

Get a reference to the mutable session. This allows the Runner to apply state deltas when events are processed.

Trait Implementations§

Source§

impl CallbackContext for InvocationContext

Source§

fn artifacts(&self) -> Option<Arc<dyn Artifacts>>

Source§

fn tool_outcome(&self) -> Option<ToolOutcome>

Returns structured metadata about the most recent tool execution. Available in after-tool callbacks and plugin hooks. Returns None when not in a tool execution context.
Source§

impl InvocationContext for InvocationContext

Source§

fn agent(&self) -> Arc<dyn Agent>

Source§

fn memory(&self) -> Option<Arc<dyn Memory>>

Source§

fn session(&self) -> &dyn Session

Source§

fn run_config(&self) -> &RunConfig

Source§

fn end_invocation(&self)

Source§

fn ended(&self) -> bool

Source§

fn user_scopes(&self) -> Vec<String>

Returns the scopes granted to the current user for this invocation. Read more
Source§

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

Returns the request metadata from the auth middleware bridge, if present. Read more
Source§

impl ReadonlyContext for InvocationContext

Source§

fn invocation_id(&self) -> &str

Source§

fn agent_name(&self) -> &str

Source§

fn user_id(&self) -> &str

Source§

fn app_name(&self) -> &str

Source§

fn session_id(&self) -> &str

Source§

fn branch(&self) -> &str

Source§

fn user_content(&self) -> &Content

Source§

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

Returns the application name as a typed AppName. Read more
Source§

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

Returns the user identifier as a typed UserId. Read more
Source§

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

Returns the session identifier as a typed SessionId. Read more
Source§

fn try_invocation_id(&self) -> Result<InvocationId, AdkError>

Returns the invocation identifier as a typed InvocationId. Read more
Source§

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

Returns the stable session-scoped AdkIdentity triple. Read more
Source§

fn try_execution_identity(&self) -> Result<ExecutionIdentity, AdkError>

Returns the full per-invocation ExecutionIdentity. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more