Skip to main content

Agent

Struct Agent 

Source
pub struct Agent { /* private fields */ }
Expand description

A configured agent ready to accept user messages and execute tool-use loops.

The agent holds a shared reference to an InferenceEngine (model + backend) and its own LlamaContext (KV cache). Multiple agents can share the same engine without loading the model multiple times.

Implementations§

Source§

impl Agent

Source

pub fn builder() -> AgentBuilder

Create an AgentBuilder for step-by-step configuration.

Source

pub fn chat( &mut self, user_message: &str, on_event: impl FnMut(AgentEvent), ) -> Result<(), AgentError>

Send a user message and run the agent loop until completion.

The on_event callback receives streaming events as the agent generates text and executes tools.

Source

pub fn chat_simple(&mut self, user_message: &str) -> Result<String, AgentError>

Send a user message and collect the full response text.

Convenience method that runs the agent loop and returns the final concatenated response text.

Source

pub fn engine(&self) -> &Arc<InferenceEngine>

Access the shared inference engine.

Source

pub fn conversation(&self) -> &Conversation

Access the conversation history.

Source

pub fn conversation_mut(&mut self) -> &mut Conversation

Mutable access to the conversation history.

Source

pub fn tools(&self) -> &ToolRegistry

Access the tool registry.

Source

pub fn register_tool(&mut self, tool: Box<dyn Tool>)

Register an additional tool at runtime.

Source

pub fn skills(&self) -> &SkillRegistry

Access the skill registry.

Source

pub fn agents_md(&self) -> &AgentsMdRegistry

Access the AGENTS.md registry.

Source

pub fn clear_history(&mut self)

Clear the conversation history (keeping the system prompt).

Auto Trait Implementations§

§

impl Freeze for Agent

§

impl !RefUnwindSafe for Agent

§

impl Send for Agent

§

impl Sync for Agent

§

impl Unpin for Agent

§

impl UnsafeUnpin for Agent

§

impl !UnwindSafe for Agent

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, 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> 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.