pub struct Agent {
pub id: String,
pub persona: Persona,
pub tools: ToolRegistry,
pub memory: AgentMemory,
pub planner: Arc<dyn Planner>,
/* private fields */
}Expand description
An autonomous agent with tool use and reasoning capabilities.
Fields§
§id: StringAgent identifier.
persona: PersonaAgent persona.
tools: ToolRegistryAvailable tools.
memory: AgentMemoryAgent memory.
planner: Arc<dyn Planner>Planning strategy.
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn builder() -> AgentBuilder
pub fn builder() -> AgentBuilder
Creates a new agent builder.
Sourcepub fn system_prompt(&self) -> String
pub fn system_prompt(&self) -> String
Returns the system prompt.
Sourcepub fn set_engine(&mut self, engine: Arc<Engine>)
pub fn set_engine(&mut self, engine: Arc<Engine>)
Sets the inference engine.
Sourcepub async fn run(&mut self, objective: &str) -> Result<String>
pub async fn run(&mut self, objective: &str) -> Result<String>
Runs the agent with the given objective using ReAct-style reasoning.
§Errors
Returns an error if execution fails.
Sourcepub fn add_message(&mut self, message: Message)
pub fn add_message(&mut self, message: Message)
Adds a message to the agent’s memory.
Sourcepub fn clear_memory(&mut self)
pub fn clear_memory(&mut self)
Clears the agent’s working memory.
Sourcepub async fn step(&mut self, input: &str) -> Result<StepResult>
pub async fn step(&mut self, input: &str) -> Result<StepResult>
Runs a single step of reasoning (for streaming/interactive use).
Auto Trait Implementations§
impl Freeze for Agent
impl !RefUnwindSafe for Agent
impl Send for Agent
impl Sync for Agent
impl Unpin for Agent
impl !UnwindSafe for Agent
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
Mutably borrows from an owned value. Read more
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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