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:
- the
ContextPolicyselects the history that fits; - the
Provideranswers, streaming text asCoreEvent::AssistantDelta; - 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
impl AgentRuntime
pub fn new( provider: Arc<dyn Provider>, tools: Arc<ToolRegistry>, context: Arc<dyn ContextPolicy>, config: AgentConfig, workspace: PathBuf, ) -> Self
pub fn model(&self) -> &str
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§
impl !RefUnwindSafe for AgentRuntime
impl !UnwindSafe for AgentRuntime
impl Freeze for AgentRuntime
impl Send for AgentRuntime
impl Sync for AgentRuntime
impl Unpin for AgentRuntime
impl UnsafeUnpin for AgentRuntime
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