Skip to main content

Agent

Struct Agent 

Source
pub struct Agent { /* private fields */ }

Implementations§

Source§

impl Agent

Source

pub fn builder(name: impl Into<String>) -> AgentBuilder

Source

pub fn name(&self) -> &str

Source

pub fn to_builder(&self) -> AgentBuilder

A builder pre-filled with this agent’s configuration, for deriving variants (another model, journal or tool set).

Source

pub fn worker_id(&self) -> &str

Source

pub fn journal(&self) -> &Arc<dyn Journal> ⓘ

Source

pub async fn run( &self, input: impl Into<String>, ) -> Result<RunOutcome, AgentError>

Start a new run with a user message and drive it.

Source

pub async fn run_message( &self, input: Message, ) -> Result<RunOutcome, AgentError>

Source

pub async fn run_with_id( &self, run_id: &str, input: impl Into<String>, ) -> Result<RunOutcome, AgentError>

Start a new run under an id the caller chooses, and drive it.

For a worker serving an outside job queue: derive the id from the job (e.g. "task-42:1"), and after a crash the run can be found and resumed without having stored a generated id anywhere first. Fails with AgentError::RunExists if the id is already in the journal.

Source

pub async fn resume(&self, run_id: &str) -> Result<RunOutcome, AgentError>

Continue a run from its journal, e.g. after a crash or an approval. Completed tool calls are never re-executed; a call that was in flight during a crash runs again with the same idempotency key.

Takes the run’s lease first, so two workers never drive the same run; the loser gets AgentError::Leased.

Source

pub async fn state(&self, run_id: &str) -> Result<RunState, AgentError>

Current state of a run, rebuilt from its journal.

Source

pub async fn decide( &self, run_id: &str, call_id: &str, approved: bool, by: Option<&str>, note: Option<&str>, ) -> Result<(), AgentError>

Record a human decision for a call that is awaiting approval. Call Agent::resume afterwards to continue the run.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Agent

§

impl !UnwindSafe for Agent

§

impl Freeze for Agent

§

impl Send for Agent

§

impl Sync for Agent

§

impl Unpin for Agent

§

impl UnsafeUnpin for Agent

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more