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
impl Agent
Sourcepub fn builder() -> AgentBuilder
pub fn builder() -> AgentBuilder
Create an AgentBuilder for step-by-step configuration.
Sourcepub fn chat(
&mut self,
user_message: &str,
on_event: impl FnMut(AgentEvent),
) -> Result<(), AgentError>
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.
Sourcepub fn chat_simple(&mut self, user_message: &str) -> Result<String, AgentError>
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.
Sourcepub fn engine(&self) -> &Arc<InferenceEngine>
pub fn engine(&self) -> &Arc<InferenceEngine>
Access the shared inference engine.
Sourcepub fn conversation(&self) -> &Conversation
pub fn conversation(&self) -> &Conversation
Access the conversation history.
Sourcepub fn conversation_mut(&mut self) -> &mut Conversation
pub fn conversation_mut(&mut self) -> &mut Conversation
Mutable access to the conversation history.
Sourcepub fn tools(&self) -> &ToolRegistry
pub fn tools(&self) -> &ToolRegistry
Access the tool registry.
Sourcepub fn register_tool(&mut self, tool: Box<dyn Tool>)
pub fn register_tool(&mut self, tool: Box<dyn Tool>)
Register an additional tool at runtime.
Sourcepub fn skills(&self) -> &SkillRegistry
pub fn skills(&self) -> &SkillRegistry
Access the skill registry.
Sourcepub fn agents_md(&self) -> &AgentsMdRegistry
pub fn agents_md(&self) -> &AgentsMdRegistry
Access the AGENTS.md registry.
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear the conversation history (keeping the system prompt).