pub struct Execute { /* private fields */ }Expand description
Unified agent execution service — the single place handling:
- conversation history loading (
TenantDb) - memory injection (
ContextProvider) ToolCoordinatorloop- fallback LLM chain (
Coordinator) - observability sink (
run_history+agent_runs) - usage/cost aggregation
- token budget check
- loop detection
Reachable via ctx.get::<Execute>() (see Service impl).
Implementations§
Source§impl Execute
impl Execute
Sourcepub fn new() -> Execute
pub fn new() -> Execute
Create a new service with no backing stores (useful for tests and
cargo check --no-default-features).
Sourcepub async fn emit_agent_started(
&self,
ctx: &Arc<Context>,
payload: AgentStartedPayload,
) -> Value
pub async fn emit_agent_started( &self, ctx: &Arc<Context>, payload: AgentStartedPayload, ) -> Value
Emit the agent.started event through the Cordis event bus with
Dispatch::Parallel, which fans out to every registered observer
concurrently and awaits all of them before returning (join-all).
If no EventsService is present in the context, or the dispatch
errors, the original payload is returned unchanged so callers never
lose data.
Sourcepub async fn emit_observability(
&self,
ctx: &Arc<Context>,
event: impl Into<String>,
payload: Value,
)
pub async fn emit_observability( &self, ctx: &Arc<Context>, event: impl Into<String>, payload: Value, )
Fire-and-forget observability event via Cordis Dispatch::Emit.
Returns immediately without waiting for handlers. Missing EventsService
is a no-op. Usage snapshot recording stays in server middleware
(UsageContext is not in this crate).
Sourcepub async fn emit_observability_typed<E>(
&self,
ctx: &Arc<Context>,
payload: &<E as TypedEvent>::Payload,
)where
E: TypedEvent,
pub async fn emit_observability_typed<E>(
&self,
ctx: &Arc<Context>,
payload: &<E as TypedEvent>::Payload,
)where
E: TypedEvent,
Typed fire-and-forget variant of [emit_observability]: dispatches the
payload struct for its catalog-bound event via Dispatch::Emit.
Sourcepub fn with_context_provider(
self,
provider: Arc<dyn ContextProvider>,
) -> Execute
pub fn with_context_provider( self, provider: Arc<dyn ContextProvider>, ) -> Execute
Attach a context provider for memory injection.
Sourcepub fn with_agent_registry(self, registry: Arc<AgentRegistry>) -> Execute
pub fn with_agent_registry(self, registry: Arc<AgentRegistry>) -> Execute
Attach an agent registry for creating agents from resolved configs.
Sourcepub fn with_run_tracker(self, tracker: Arc<dyn RunTracker>) -> Execute
pub fn with_run_tracker(self, tracker: Arc<dyn RunTracker>) -> Execute
Attach a run tracker for observability.
Sourcepub fn run_tracker(&self) -> Option<&Arc<dyn RunTracker>>
pub fn run_tracker(&self) -> Option<&Arc<dyn RunTracker>>
Host-injected run tracker, if any.
Sourcepub async fn run(
&self,
req: &AgentRequest,
ctx: &Arc<Context>,
) -> Result<ExecutionResult, AppError>
pub async fn run( &self, req: &AgentRequest, ctx: &Arc<Context>, ) -> Result<ExecutionResult, AppError>
Execute an agent by name using the full pipeline: resolve → create → execute.
This is the PRIMARY entry point that handlers should call. It:
- Resolves the agent via crate-private
Resolver(3-tier: tenant → community → system) - Creates the agent via
AgentRegistry::create_agent_from_config_with_fallbacks - Calls
agent.execute(message, context)with the request ctx bound - Returns
ExecutionResultwith response + resolution metadata
Run tracking (start/finish) is handled internally via RunTracker.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Execute
impl !UnwindSafe for Execute
impl Freeze for Execute
impl Send for Execute
impl Sync for Execute
impl Unpin for Execute
impl UnsafeUnpin for Execute
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 moreimpl<T> MaybeSendSync for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.