pub struct AgentRunner { /* private fields */ }Expand description
Drives a session forward, multi-turn, until the model emits no tool call or the iteration cap is reached.
Clone is intentional: Arc<AgentRunner> is awkward because every field
is already cheaply cloneable, and the TUI spawns runner work onto its own
task which needs an owned value.
Implementations§
Source§impl AgentRunner
impl AgentRunner
Sourcepub fn new(
provider: Arc<dyn LlmProvider>,
tools: ToolRegistry,
model: impl Into<String>,
) -> Self
pub fn new( provider: Arc<dyn LlmProvider>, tools: ToolRegistry, model: impl Into<String>, ) -> Self
Construct a runner with the V1 default policy (ApprovalPolicy::DenyDestructive).
Sourcepub fn model_handle(&self) -> Arc<Mutex<String>> ⓘ
pub fn model_handle(&self) -> Arc<Mutex<String>> ⓘ
Share the live model handle so the TUI /model command can swap
the active model mid-session (Phase EE).
Sourcepub fn provider_handle(&self) -> Arc<Mutex<Arc<dyn LlmProvider>>> ⓘ
pub fn provider_handle(&self) -> Arc<Mutex<Arc<dyn LlmProvider>>> ⓘ
Share the live provider handle so the TUI /provider command
can swap the whole backend mid-session (Phase LL).
Sourcepub fn skill_toggle_handle(&self) -> Arc<Mutex<HashSet<String>>> ⓘ
pub fn skill_toggle_handle(&self) -> Arc<Mutex<HashSet<String>>> ⓘ
Share a live skill-toggle set with the caller. Skill ids present in the set are skipped during per-turn matching, letting the TUI enable / disable skills mid-session (Phase X).
Sourcepub fn last_request_handle(&self) -> Arc<Mutex<Option<String>>> ⓘ
pub fn last_request_handle(&self) -> Arc<Mutex<Option<String>>> ⓘ
Share a handle to the most-recent-request snapshot. The TUI
/inspect panel (Phase Y) reads the pretty-printed JSON written
here on every turn.
Sourcepub fn with_approval(self, policy: ApprovalPolicy) -> Self
pub fn with_approval(self, policy: ApprovalPolicy) -> Self
Override the approval policy.
Sourcepub fn with_max_iterations(self, n: usize) -> Self
pub fn with_max_iterations(self, n: usize) -> Self
Override the per-turn iteration cap.
Sourcepub fn with_skills(self, skills: Vec<Skill>) -> Self
pub fn with_skills(self, skills: Vec<Skill>) -> Self
Register a skill catalogue. Active skills are matched per turn against the latest user message + the (optional) project slug.
Sourcepub fn with_project(self, project: impl Into<String>) -> Self
pub fn with_project(self, project: impl Into<String>) -> Self
Set the project slug used for project-pattern skill triggers.
Sourcepub fn with_auto_retrieve(
self,
enabled: bool,
top_k: usize,
min_len: usize,
) -> Self
pub fn with_auto_retrieve( self, enabled: bool, top_k: usize, min_len: usize, ) -> Self
Enable retrieve-then-generate. Before each turn, pre-fetch RAG context
for the latest user message via the rag_search MCP tool and inject it
as a system block — helps weaker models that don’t reliably call the
tool themselves on interrogative messages. The agent stays free to call
read_document / find_related to dig deeper; this only pre-loads.
No-op when no …__rag_search tool is registered, on slash-commands, or
on messages shorter than min_len chars. top_k is clamped to 1..=10.
Sourcepub async fn run(&self, messages: Vec<Message>) -> Result<TurnResult>
pub async fn run(&self, messages: Vec<Message>) -> Result<TurnResult>
Run the loop and return the full transcript.
Equivalent to AgentRunner::run_streaming with a discarded event
channel — convenient for tests and batch callers that don’t need
progressive UI updates.
Sourcepub async fn run_streaming(
&self,
messages: Vec<Message>,
events: Sender<TurnEvent>,
) -> Result<TurnResult>
pub async fn run_streaming( &self, messages: Vec<Message>, events: Sender<TurnEvent>, ) -> Result<TurnResult>
Run the loop, emitting TurnEvents on events as they happen.
events is dropped when the function returns, which signals the
caller that the run is complete (a receive on the matching receiver
will then yield None).
Trait Implementations§
Source§impl Clone for AgentRunner
impl Clone for AgentRunner
Source§fn clone(&self) -> AgentRunner
fn clone(&self) -> AgentRunner
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more