pub struct Agent { /* private fields */ }Expand description
The ReAct loop: ask LLM, execute tools, repeat.
Agent orchestrates the interaction between an LLM provider, a tool registry,
and a transcript. It drives a loop until the model stops calling tools or the
budget (steps or transcript size) is exceeded.
§Usage
ⓘ
let agent = Agent::builder()
.llm(Arc::new(provider))
.tools(registry)
.system_prompt("You are a helpful assistant")
.max_steps(32)
.build()?;
let outcome = agent.run("Help me debug this file").await?;§Events
The agent emits StepEvents through an optional channel, allowing UI layers
to observe progress without coupling to internals. See StepEvent for variants.
§Isolation
Each Agent::run() call is independent. The transcript is maintained across
steps within a single run but cleared between runs. Use seed_transcript() to
carry state between runs if needed.
Implementations§
Source§impl Agent
impl Agent
pub fn builder() -> AgentBuilder
Sourcepub fn confirm_plan(&mut self)
pub fn confirm_plan(&mut self)
Confirm a proposed plan, allowing execution to proceed.
Sourcepub fn reject_plan(&mut self, reason: &str)
pub fn reject_plan(&mut self, reason: &str)
Reject a proposed plan with a reason.
pub async fn run(&mut self, goal: impl Into<String>) -> Result<AgentOutcome>
pub fn transcript(&self) -> &[Message]
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> 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