pub struct AgentRuntime { /* private fields */ }Expand description
Shared agent state installed on AppState by the
plugin.
Handlers reach it through the
AgentHandle extractor; the background
jobs and the heartbeat read it directly.
Implementations§
Source§impl AgentRuntime
impl AgentRuntime
Sourcepub fn new(
config: AgentConfig,
client: Arc<dyn LlmClient>,
tools: Vec<Arc<dyn Tool>>,
) -> Self
pub fn new( config: AgentConfig, client: Arc<dyn LlmClient>, tools: Vec<Arc<dyn Tool>>, ) -> Self
Bundle a client, tools, and config into the shared runtime.
Starts with an in-memory session store, no memory, no skills, the
AllowAll policy, and LogDelivery. Adjust with the with_*
methods.
Sourcepub fn with_hooks(self, hooks: Vec<Arc<dyn AgentHooks>>) -> Self
pub fn with_hooks(self, hooks: Vec<Arc<dyn AgentHooks>>) -> Self
Add lifecycle hooks to every agent the runtime builds.
Sourcepub fn with_policy(self, policy: Arc<dyn ToolPolicy>) -> Self
pub fn with_policy(self, policy: Arc<dyn ToolPolicy>) -> Self
Set the tool policy for every agent the runtime builds.
Sourcepub fn with_sessions(self, sessions: Arc<dyn SessionStore>) -> Self
pub fn with_sessions(self, sessions: Arc<dyn SessionStore>) -> Self
Replace the session store.
Sourcepub fn with_memory(self, memory: Arc<dyn MemoryStore>) -> Self
pub fn with_memory(self, memory: Arc<dyn MemoryStore>) -> Self
Give every agent persistent memory in this store.
Sourcepub fn with_skills(self, skills: impl Into<Arc<[Skill]>>) -> Self
pub fn with_skills(self, skills: impl Into<Arc<[Skill]>>) -> Self
Offer these skills to every agent.
Sourcepub const fn with_compaction(self, compaction: Compaction) -> Self
pub const fn with_compaction(self, compaction: Compaction) -> Self
Compact long session transcripts.
Sourcepub fn with_delivery(self, delivery: Arc<dyn Delivery>) -> Self
pub fn with_delivery(self, delivery: Arc<dyn Delivery>) -> Self
Where background results go.
Sourcepub const fn with_followups(self, max_delay: Duration) -> Self
pub const fn with_followups(self, max_delay: Duration) -> Self
Give agents the schedule_followup tool, with this maximum delay.
Sourcepub fn agent(&self) -> Agent
pub fn agent(&self) -> Agent
Build an Agent with the runtime’s client, tools, budgets, hooks,
policy, skills, and memory (scope MemoryScope::agent).
Sourcepub fn agent_for(&self, scope: MemoryScope) -> Agent
pub fn agent_for(&self, scope: MemoryScope) -> Agent
Like AgentRuntime::agent, with memory bound to scope (for
example one scope per user).
Sourcepub const fn config(&self) -> &AgentConfig
pub const fn config(&self) -> &AgentConfig
The plugin configuration backing this runtime.
Sourcepub fn client(&self) -> Arc<dyn LlmClient> ⓘ
pub fn client(&self) -> Arc<dyn LlmClient> ⓘ
The provider client this runtime runs agents with.
The health indicator uses the same client, so /actuator/health
always reflects the provider the app actually talks to.
Sourcepub fn policy(&self) -> Arc<dyn ToolPolicy> ⓘ
pub fn policy(&self) -> Arc<dyn ToolPolicy> ⓘ
The tool policy agents run under.
Sourcepub fn sessions(&self) -> Arc<dyn SessionStore> ⓘ
pub fn sessions(&self) -> Arc<dyn SessionStore> ⓘ
The session store.
Sourcepub fn memory(&self) -> Option<Arc<dyn MemoryStore>>
pub fn memory(&self) -> Option<Arc<dyn MemoryStore>>
The memory store, when memory is on.
Sourcepub fn tool_names(&self) -> Vec<&str>
pub fn tool_names(&self) -> Vec<&str>
Names of the registered tools.
Trait Implementations§
Source§impl Clone for AgentRuntime
impl Clone for AgentRuntime
Auto Trait Implementations§
impl !RefUnwindSafe for AgentRuntime
impl !UnwindSafe for AgentRuntime
impl Forget for AgentRuntime
impl Freeze for AgentRuntime
impl Send for AgentRuntime
impl Sync for AgentRuntime
impl Unpin for AgentRuntime
impl UnsafeUnpin for AgentRuntime
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,
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.