Skip to main content

LlmAgentBehavior

Struct LlmAgentBehavior 

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

Implementations§

Source§

impl LlmAgentBehavior

Source

pub fn new(llm: Arc<dyn LlmClient>, tools: Arc<ToolRegistry>) -> Self

Source

pub fn with_reply_transformers(self, chain: OutboundReplyTransformChain) -> Self

Install the outbound reply transform chain. Replaces any previously-installed chain. Pass OutboundReplyTransformChain::empty() to disable.

Source

pub fn with_plugin_skill_roots(self, roots: Vec<PathBuf>) -> Self

Install the plugin-contributed skill roots returned by wire_plugin_registry. Empty vec preserves legacy behavior (operator’s skills_dir is the only source). Operator-priority is preserved by the loader’s search order — see SkillLoader::candidate_paths.

Source

pub fn with_mutation_hook( self, hook: Arc<dyn MemoryMutationHook>, tenant: impl Into<String>, ) -> Self

Wire the mutation observer. Successful compaction_store.insert calls fire a SqliteCompactions/Insert event onto nexo.memory.mutated.<agent_id> with the session id as the correlation key. Best-effort: hook failures are swallowed.

Source

pub fn with_memory_extractor( self, extractor: Arc<dyn MemoryExtractor>, memory_dir: PathBuf, ) -> Self

Wire post-turn memory extraction. When set, every successful run_turn ticks the extractor and fires extraction against memory_dir. Mirrors driver-loop’s per-turn wire; both engines share the same Arc<ExtractMemories> so cadence + circuit breaker + in-progress mutex stay coherent across paths.

Provider-agnostic: Arc<dyn MemoryExtractor> keeps any concrete impl pluggable (today ExtractMemories from nexo-driver-loop).

Source

pub fn with_compaction( self, summarizer: Arc<dyn LlmClient>, store: Arc<CompactionStore>, runtime: CompactionRuntime, ) -> Self

Wire the online compactor. All three handles must be supplied together; passing enabled: true in runtime without the wiring is a no-op (logged on first turn so the gap is visible). summarizer is the LLM client used to produce the summary itself — most operators reuse the agent’s main model; pass a dedicated cheaper client to save spend.

Source

pub fn with_token_counter(self, counter: Arc<dyn TokenCounter>) -> Self

Attach a TokenCounter. Boot time pick this from nexo_llm::token_counter::build() based on llm.context_optimization.token_counter.backend. When omitted, pre-flight sizing is skipped (zero metrics, zero overhead).

Source

pub fn with_workspace_cache(self, cache: Arc<WorkspaceCache>) -> Self

Attach the shared workspace cache. When set, run_turn reads the workspace bundle via WorkspaceCache::get (warm Arc, no disk I/O on the hot path); when omitted, falls back to a fresh WorkspaceLoader every turn (legacy / test path).

Source

pub fn with_prompt_cache(self, enabled: bool) -> Self

Opt the agent into provider-level prompt caching. Driven from llm.context_optimization.prompt_cache.enabled (or the per-agent override). Defaults to false so the legacy non-cached path stays the safe fallback.

Source

pub fn with_tool_policy(self, p: Arc<ToolPolicy>) -> Self

Attach a tool-execution policy. Controls caching + parallel execution of tool calls. Defaults to a no-op policy.

Pre-builds the relevance filter (if enabled) so the per-turn hot path stays O(1) instead of re-tokenizing the full tool catalog on every message.

Source

pub async fn rebuild_tool_filter(&self)

Rebuild the relevance filter index — call after the tool set changes (extension hot-reload, runtime registration). Idempotent.

Source

pub fn with_max_iterations(self, n: usize) -> Self

Source

pub fn with_hooks(self, hooks: Arc<HookRegistry>) -> Self

Attach an extension hook registry. Without this, hook fire sites are no-ops and behavior is identical to pre-11.6 operation.

Source

pub fn with_rate_limiter(self, rl: Arc<ToolRateLimiter>) -> Self

Attach per-tool rate limiter. Denied calls surface as outcome="rate_limited" and are not routed to the handler.

Source

pub fn with_schema_validator(self, v: Arc<ToolArgsValidator>) -> Self

Attach the JSON Schema args validator. Denied calls surface as outcome="invalid_args" with the path of the offending field(s) in the result, so the LLM can retry.

Trait Implementations§

Source§

impl AgentBehavior for LlmAgentBehavior

Source§

fn on_heartbeat<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 AgentContext, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn on_message_control<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 AgentContext, msg: InboundMessage, ) -> Pin<Box<dyn Future<Output = Result<AgentTurnControl>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn on_message<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 AgentContext, msg: InboundMessage, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn decide<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ctx: &'life1 AgentContext, msg: &'life2 InboundMessage, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Stub for LLM reasoning. Returns empty string by default.
Source§

fn on_event<'life0, 'life1, 'async_trait>( &'life0 self, _ctx: &'life1 AgentContext, _event: Event, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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