Skip to main content

AgentRuntime

Struct AgentRuntime 

Source
pub struct AgentRuntime { /* private fields */ }
Expand description

Runs user turns against one provider, tool registry, and context policy.

run_turn appends the user’s input to the session history, then repeats up to max_steps times:

  1. the ContextPolicy selects the history that fits;
  2. the Provider answers, streaming text as CoreEvent::AssistantDelta;
  3. with no tool calls the turn is done; otherwise each call, in order, is checked by its tool, approved or denied by the ApprovalGate, and run, and its output is added to history for the next step.

Every step is reported to the EventSink. History stays within HistoryLimits by trimming old turns into a note. If the turn fails or is cancelled, history is restored to how it was before the turn.

Implementations§

Source§

impl AgentRuntime

Source

pub fn new( provider: Arc<dyn Provider>, tools: Arc<ToolRegistry>, context: Arc<dyn ContextPolicy>, config: AgentConfig, workspace: PathBuf, ) -> Self

Source

pub fn model(&self) -> &str

Source

pub async fn run_turn( &self, history: &mut Vec<Message>, prompt: impl Into<TurnInput>, sink: Arc<dyn EventSink>, approvals: Arc<dyn ApprovalGate>, cancellation: CancellationToken, ) -> Result<TurnOutcome, AgentError>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.