pub struct Orchestrator { /* private fields */ }Expand description
LLM orchestrator with tool loop execution.
The orchestrator wraps an LlmDriver and adds:
- Tool call detection and accumulation
- Tool execution via MCP
- Automatic tool result feeding
- Request ID tracking
Implementations§
Source§impl Orchestrator
impl Orchestrator
Sourcepub fn new(
llm_config: LlmConfig,
mcp: Arc<McpRegistry>,
native_skills: Arc<NativeSkillRegistry>,
) -> Result<Self>
pub fn new( llm_config: LlmConfig, mcp: Arc<McpRegistry>, native_skills: Arc<NativeSkillRegistry>, ) -> Result<Self>
Create a new orchestrator with the given LLM config, MCP registry, and native skill registry.
Uses LiterLlmDriver backed by liter-llm’s DefaultClient for all
142+ providers with unified tool-call normalization.
§Errors
Returns an error if the underlying LLM client cannot be constructed.
Sourcepub fn from_driver(
llm_config: LlmConfig,
mcp: Arc<McpRegistry>,
native_skills: Arc<NativeSkillRegistry>,
driver: Arc<dyn LlmDriver>,
) -> Self
pub fn from_driver( llm_config: LlmConfig, mcp: Arc<McpRegistry>, native_skills: Arc<NativeSkillRegistry>, driver: Arc<dyn LlmDriver>, ) -> Self
Create a new orchestrator with a host-supplied LLM driver.
This is the embedding seam for environments that own a local model runtime outside UAR, such as KnowMe mobile. UAR still owns the agent loop, tool governance, skills, and normalized events; the host-supplied driver only provides model streaming.
Sourcepub fn with_skill_activation(
self,
context: Arc<Mutex<ActivationContext>>,
strategy: ContextStrategy,
model: String,
context_limit: usize,
budget: SkillReattachmentBudget,
) -> Self
pub fn with_skill_activation( self, context: Arc<Mutex<ActivationContext>>, strategy: ContextStrategy, model: String, context_limit: usize, budget: SkillReattachmentBudget, ) -> Self
Share host-owned activations without persisting their reclaimable bodies in the history that compaction summarizes.
Sourcepub fn with_request_budget_contract(
self,
contract: RequestBudgetContract,
) -> Self
pub fn with_request_budget_contract( self, contract: RequestBudgetContract, ) -> Self
Attach a trusted-host-resolved final-wire budget contract to every request preparation performed by this orchestrator.
Sourcepub fn with_destination_preparations(
self,
preparations: Arc<DestinationRequestPreparations>,
canonical_history: Vec<Message>,
canonical_fragments: Vec<PromptFragment>,
) -> Self
pub fn with_destination_preparations( self, preparations: Arc<DestinationRequestPreparations>, canonical_history: Vec<Message>, canonical_fragments: Vec<PromptFragment>, ) -> Self
Attach exact destination contracts and the immutable canonical history from which every initial, retry, failover, graph, resume and loop request is prepared.
Sourcepub fn with_protected_continuity(self, continuity: ProtectedContinuity) -> Self
pub fn with_protected_continuity(self, continuity: ProtectedContinuity) -> Self
Bind opaque provider continuity retained by the trusted host.
pub fn with_resolved_turn(self, turn: Arc<ResolvedTurn>) -> Self
Sourcepub fn with_canonical_receipt_store(
self,
store: Option<Arc<dyn PersistenceLayer>>,
) -> Self
pub fn with_canonical_receipt_store( self, store: Option<Arc<dyn PersistenceLayer>>, ) -> Self
Persist pre-format tool results through the trusted host’s run store.
Sourcepub fn with_mcp_preflight(self, preflight: Arc<McpPreflight>) -> Self
pub fn with_mcp_preflight(self, preflight: Arc<McpPreflight>) -> Self
Use the host-prepared projection for all MCP advertisement and execution. Native implementations remain in their existing governed registries.
pub fn with_shadow_turn( self, turn: Arc<ResolvedTurn>, history: Vec<Message>, ) -> Self
Sourcepub fn with_world_state(self, state: Arc<WorldStateRuntime>) -> Self
pub fn with_world_state(self, state: Arc<WorldStateRuntime>) -> Self
Attach the host-owned world state for reduction and governed file reads.
Sourcepub fn with_failover(
self,
fallback_driver: Arc<dyn LlmDriver>,
failover_config: FailoverConfig,
) -> Self
pub fn with_failover( self, fallback_driver: Arc<dyn LlmDriver>, failover_config: FailoverConfig, ) -> Self
Attach one fallback driver and failover configuration.
When failover_config.enabled is true and the primary driver fails,
the orchestrator will re-try the same request against the fallback.
This compatibility helper uses the first configured fallback model.
Sourcepub fn with_failovers(
self,
fallback_drivers: Vec<(String, Arc<dyn LlmDriver>)>,
failover_config: FailoverConfig,
) -> Self
pub fn with_failovers( self, fallback_drivers: Vec<(String, Arc<dyn LlmDriver>)>, failover_config: FailoverConfig, ) -> Self
Attach an ordered set of fallback model drivers.
Sourcepub fn with_health_monitor(
self,
health_monitor: Arc<ProviderHealthMonitor>,
) -> Self
pub fn with_health_monitor( self, health_monitor: Arc<ProviderHealthMonitor>, ) -> Self
Attach the shared provider-health monitor (CH-03). Driver
successes/failures are recorded against it so ModelRouter and
ProviderRegistry::resolve_to_llm_config see the outcome on the very
next call.
Sourcepub fn build_fallback_driver(
base_llm_config: &LlmConfig,
fallback: &FallbackModel,
) -> Result<Arc<dyn LlmDriver>>
pub fn build_fallback_driver( base_llm_config: &LlmConfig, fallback: &FallbackModel, ) -> Result<Arc<dyn LlmDriver>>
Build a driver for one FailoverConfig::fallback_models entry, reusing
base_llm_config for every field except model/api_key/base_url
(CH-03). Used by callers wiring with_failover from app config.
§Errors
Returns an error if the underlying LLM client cannot be constructed.
Sourcepub fn llm_config(&self) -> &LlmConfig
pub fn llm_config(&self) -> &LlmConfig
Get the LLM configuration.
Sourcepub fn mcp(&self) -> &McpRegistry
pub fn mcp(&self) -> &McpRegistry
Get the MCP registry.
Sourcepub fn with_tool_approval_gate(self, gate: ToolApprovalGate) -> Self
pub fn with_tool_approval_gate(self, gate: ToolApprovalGate) -> Self
Set a tool approval gate that will be consulted before each tool call.
Sourcepub fn with_sandbox(
self,
runner: Arc<dyn SandboxRunner>,
mode: ToolExecutionMode,
) -> Self
pub fn with_sandbox( self, runner: Arc<dyn SandboxRunner>, mode: ToolExecutionMode, ) -> Self
Attach a sandbox runner and execution mode for tool isolation.
Sandboxed mode requires isolation for every tool; Auto requires it for code-execution tools. A descriptor’s sandbox requirement always applies. Missing isolation or an unsupported tool adapter returns a failed result and never falls through to direct native/MCP execution.
Sourcepub fn with_tool_execution_mode(self, mode: ToolExecutionMode) -> Self
pub fn with_tool_execution_mode(self, mode: ToolExecutionMode) -> Self
Apply the artifact’s execution mode even when no sandbox is available. Absence of a runner is not permission to discard an isolation policy.
Sourcepub fn with_sandbox_scope(self, scope: SandboxRun) -> Self
pub fn with_sandbox_scope(self, scope: SandboxRun) -> Self
Bind the host-owned operation scope. The host must retain its lease and drain it before terminal completion; an unowned runner cannot execute.
Sourcepub fn with_resilience_policy(self, policy: ResiliencePolicy) -> Self
pub fn with_resilience_policy(self, policy: ResiliencePolicy) -> Self
Apply bounded provider retry and stream-start policy to this run.
Sourcepub fn with_tool_output_policy(self, policy: TruncationPolicy) -> Self
pub fn with_tool_output_policy(self, policy: TruncationPolicy) -> Self
Set the bound applied to every recorded tool result.
Sourcepub fn with_cache_strategy(self, strategy: Option<CacheStrategy>) -> Self
pub fn with_cache_strategy(self, strategy: Option<CacheStrategy>) -> Self
Apply the effective prompt-caching strategy to every policy-bearing request created by this orchestrator, including retries and failover.
Sourcepub async fn chat(
&self,
user_message: &str,
) -> Result<impl Stream<Item = NormalizedEvent> + Send>
pub async fn chat( &self, user_message: &str, ) -> Result<impl Stream<Item = NormalizedEvent> + Send>
Start a chat interaction with the given user message.
Returns a stream of NormalizedEvents that includes:
StreamStartwith a unique request IDMessageDeltafor assistant textToolCallDeltaandToolCallCompletefor tool callsToolResultafter tool executionDonewhen complete
The orchestrator will automatically execute tool calls and feed results back to the LLM until a final response is produced.
Sourcepub async fn chat_with_history(
&self,
messages: Vec<Message>,
) -> Result<impl Stream<Item = NormalizedEvent> + Send + 'static + use<>>
pub async fn chat_with_history( &self, messages: Vec<Message>, ) -> Result<impl Stream<Item = NormalizedEvent> + Send + 'static + use<>>
Start a chat interaction with existing message history.
Trait Implementations§
Source§impl Clone for Orchestrator
impl Clone for Orchestrator
Source§fn clone(&self) -> Orchestrator
fn clone(&self) -> Orchestrator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for Orchestrator
impl !UnwindSafe for Orchestrator
impl Freeze for Orchestrator
impl Send for Orchestrator
impl Sync for Orchestrator
impl Unpin for Orchestrator
impl UnsafeUnpin for Orchestrator
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
U: Sized,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
U: Sized,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreimpl<T> AsyncFriendly for T
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> Conv for T
impl<T> Conv for T
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§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].impl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSend for Twhere
T: Send,
§impl<T> Message for T
impl<T> Message for T
§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
impl<T> OutputMessage for Twhere
T: Message + Clone,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§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 more§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 more§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
§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
§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.§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.§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.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Pointee for T
impl<T> Pointee for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<T> State for T
§impl<T> Tap for T
impl<T> Tap for T
§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 more§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 more§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 more§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 more§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 more§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 more§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.§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.§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.§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.§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.§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.§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.