pub struct AgentRunner<P: LlmProvider> { /* private fields */ }Expand description
Runs an agent loop: LLM call → tool execution → repeat until done.
Implementations§
Source§impl<P: LlmProvider> AgentRunner<P>
impl<P: LlmProvider> AgentRunner<P>
Sourcepub fn builder(provider: Arc<P>) -> AgentRunnerBuilder<P>
pub fn builder(provider: Arc<P>) -> AgentRunnerBuilder<P>
Create a new AgentRunnerBuilder for an agent backed by provider.
The builder uses sensible defaults (10 turns, 4096 tokens) so the minimum required configuration is just a system prompt.
§Example
use std::sync::Arc;
use heartbit_core::{AgentRunner, AnthropicProvider, BoxedProvider};
let provider = Arc::new(BoxedProvider::new(AnthropicProvider::new(
"sk-...",
"claude-sonnet-4-20250514",
)));
let agent = AgentRunner::builder(provider)
.system_prompt("You are a helpful assistant.")
.build()?;Sourcepub async fn execute(&self, task: &str) -> Result<AgentOutput, Error>
pub async fn execute(&self, task: &str) -> Result<AgentOutput, Error>
Run the agent on task and return the final output.
Sourcepub async fn execute_with_content(
&self,
content: Vec<ContentBlock>,
) -> Result<AgentOutput, Error>
pub async fn execute_with_content( &self, content: Vec<ContentBlock>, ) -> Result<AgentOutput, Error>
Execute with pre-built multimodal content blocks (e.g., text + images).
Trait Implementations§
Source§impl<P: LlmProvider> Drop for AgentRunner<P>
impl<P: LlmProvider> Drop for AgentRunner<P>
Auto Trait Implementations§
impl<P> !Freeze for AgentRunner<P>
impl<P> !RefUnwindSafe for AgentRunner<P>
impl<P> Send for AgentRunner<P>
impl<P> Sync for AgentRunner<P>
impl<P> Unpin for AgentRunner<P>
impl<P> UnsafeUnpin for AgentRunner<P>
impl<P> !UnwindSafe for AgentRunner<P>
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