pub struct Agent {
pub name: String,
pub llm: Arc<dyn LLM>,
pub tools: HashMap<String, Arc<dyn Tool>>,
pub system_prompt: Option<String>,
pub memory: Vec<String>,
pub max_iterations: usize,
}Expand description
High-level agent that holds an LLM and a set of tools, plus simple agent state.
Fields§
§name: StringA short, human-friendly name for the agent instance.
llm: Arc<dyn LLM>The LLM implementation used to generate responses/thoughts.
tools: HashMap<String, Arc<dyn Tool>>Registered tools the agent may call by name.
system_prompt: Option<String>Optional system prompt / instructions provided to the LLM describing the agent’s role and available behaviors.
memory: Vec<String>Simple short-term memory / conversation context kept by the agent.
We store Message objects elsewhere in the crate; for a minimal
implementation we keep user-visible strings here.
max_iterations: usizeMaximum iterations when running a looped decision process.
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn new(
name: impl Into<String>,
llm: Arc<dyn LLM>,
max_iterations: Option<usize>,
) -> Self
pub fn new( name: impl Into<String>, llm: Arc<dyn LLM>, max_iterations: Option<usize>, ) -> Self
Create a new Agent with the provided name and LLM. Tools start empty.
Sourcepub fn register_tool(
&mut self,
name: Option<&str>,
tool: Arc<dyn Tool>,
) -> &mut Self
pub fn register_tool( &mut self, name: Option<&str>, tool: Arc<dyn Tool>, ) -> &mut Self
Register a tool under the given name. Replaces any existing tool with the same name. Returns &mut Self for chaining.
Sourcepub fn change_max_iterations(&mut self, max_iterations: usize)
pub fn change_max_iterations(&mut self, max_iterations: usize)
Change the maximum iterations for the agent’s decision process.
Sourcepub fn set_system_prompt(&mut self, prompt: impl Into<String>)
pub fn set_system_prompt(&mut self, prompt: impl Into<String>)
Set or replace the agent’s system prompt.