pub struct AgentRunner<S: CheckpointStore> { /* private fields */ }Expand description
The robust agent runner — drives the tool call loop with retries, compaction, and multi-format parsing.
Implementations§
Source§impl<S: CheckpointStore> AgentRunner<S>
impl<S: CheckpointStore> AgentRunner<S>
Sourcepub fn new(runner: Runner<S>, config: RunnerConfig) -> Self
pub fn new(runner: Runner<S>, config: RunnerConfig) -> Self
Create a new AgentRunner wrapping an existing Runner.
Sourcepub fn with_hook_registry(self, registry: Arc<HookRegistry>) -> Self
pub fn with_hook_registry(self, registry: Arc<HookRegistry>) -> Self
Set the hook registry for lifecycle hooks (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, SessionEnd).
Sourcepub fn with_approval_checker(self, checker: Arc<dyn ApprovalChecker>) -> Self
pub fn with_approval_checker(self, checker: Arc<dyn ApprovalChecker>) -> Self
Set an approval checker (PreToolUse). When set, each tool call is checked; if false, the tool is blocked.
Sourcepub fn usage(&self) -> &UsageAccumulator
pub fn usage(&self) -> &UsageAccumulator
Get the cumulative usage statistics
Sourcepub async fn run(
&mut self,
callable: &dyn Callable,
input: &str,
project_dir: Option<&Path>,
) -> Result<LoopOutcome>
pub async fn run( &mut self, callable: &dyn Callable, input: &str, project_dir: Option<&Path>, ) -> Result<LoopOutcome>
Run the robust agent loop.
This is the core method — it replaces both AgenticLoop::run (which was
a skeleton) and LlmCallable::run (which had a basic loop but no
retries, compaction, or multi-format parsing).
§Flow
- Call the callable with current input
- Parse the response for tool calls (JSON → XML → Markdown)
- If tool calls found: execute them, append results to history, loop
- If no tool calls: return the final response
- Throughout: check limits, retry on errors, compact history, checkpoint
Source§impl AgentRunner<InMemoryCheckpointStore>
impl AgentRunner<InMemoryCheckpointStore>
Sourcepub fn default_new() -> Self
pub fn default_new() -> Self
Create a new AgentRunner with default in-memory store and default config.
Sourcepub fn with_config(config: RunnerConfig) -> Self
pub fn with_config(config: RunnerConfig) -> Self
Create with a specific config.
Auto Trait Implementations§
impl<S> !Freeze for AgentRunner<S>
impl<S> !RefUnwindSafe for AgentRunner<S>
impl<S> Send for AgentRunner<S>
impl<S> Sync for AgentRunner<S>
impl<S> Unpin for AgentRunner<S>
impl<S> UnsafeUnpin for AgentRunner<S>
impl<S> !UnwindSafe for AgentRunner<S>
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