pub struct InvocationContext {
pub agent_session: AgentSession,
pub event_tx: Sender<AgentEvent>,
pub middleware: MiddlewareChain,
pub run_config: RunConfig,
pub session_id: Option<String>,
pub artifact_service: Option<Arc<dyn ArtifactService>>,
pub memory_service: Option<Arc<dyn MemoryService>>,
pub session_service: Option<Arc<dyn SessionService>>,
}Expand description
The context object that flows through agent execution. Holds everything a running agent needs.
Note: State is accessed via agent_session.state() — single source of truth.
Fields§
§agent_session: AgentSessionAgentSession wraps SessionHandle with fan-out + middleware. Replaces LiveSender — sends go directly through SessionHandle (one hop).
event_tx: Sender<AgentEvent>Event bus — agents emit events here, application code subscribes.
middleware: MiddlewareChainMiddleware chain for lifecycle hooks.
run_config: RunConfigConfiguration for this run.
session_id: Option<String>Session ID for session-aware runs.
artifact_service: Option<Arc<dyn ArtifactService>>Optional artifact service for this invocation.
memory_service: Option<Arc<dyn MemoryService>>Optional memory service for this invocation.
session_service: Option<Arc<dyn SessionService>>Optional session service for this invocation.
Implementations§
Source§impl InvocationContext
impl InvocationContext
Sourcepub fn new(agent_session: AgentSession) -> Self
pub fn new(agent_session: AgentSession) -> Self
Create a new invocation context with an empty middleware chain.
Sourcepub fn with_middleware(
agent_session: AgentSession,
middleware: MiddlewareChain,
) -> Self
pub fn with_middleware( agent_session: AgentSession, middleware: MiddlewareChain, ) -> Self
Create a new invocation context with a pre-configured middleware chain.
Sourcepub fn emit(&self, event: AgentEvent)
pub fn emit(&self, event: AgentEvent)
Emit an event to all subscribers.
Sourcepub fn subscribe(&self) -> Receiver<AgentEvent>
pub fn subscribe(&self) -> Receiver<AgentEvent>
Subscribe to agent events.
Sourcepub fn with_artifact_service(self, service: Arc<dyn ArtifactService>) -> Self
pub fn with_artifact_service(self, service: Arc<dyn ArtifactService>) -> Self
Set the artifact service for this invocation.
Sourcepub fn with_memory_service(self, service: Arc<dyn MemoryService>) -> Self
pub fn with_memory_service(self, service: Arc<dyn MemoryService>) -> Self
Set the memory service for this invocation.
Sourcepub fn with_session_service(self, service: Arc<dyn SessionService>) -> Self
pub fn with_session_service(self, service: Arc<dyn SessionService>) -> Self
Set the session service for this invocation.
Auto Trait Implementations§
impl Freeze for InvocationContext
impl !RefUnwindSafe for InvocationContext
impl Send for InvocationContext
impl Sync for InvocationContext
impl Unpin for InvocationContext
impl !UnwindSafe for InvocationContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].