Skip to main content

AgentSystem

Struct AgentSystem 

Source
pub struct AgentSystem<C, S, M, H>{ /* private fields */ }
Expand description

A configured system of agents sharing stores, tools, and a model source.

Analogous to an actor system: threads (root agents and their subagents) are the actors, and the InputSender is how messages are delivered to them. AgentSystem itself holds no running state — each step loads the thread’s state from the stores, runs one slice, and drops it, which is what makes the step API fit serverless platforms where nothing survives between slices.

Implementations§

Source§

impl<C, S, M, H> AgentSystem<C, S, M, H>
where C: ConversationStore + 'static, S: StateStore + 'static, M: InputSender + 'static, H: HttpClient + 'static,

Source

pub fn sender(&self) -> &M

The sender used for the system’s loopback path.

Source

pub async fn step<O: ThreadObserver, D: DeferQueue>( &mut self, inputs: Vec<(InputMessage, String)>, observer: &O, defer: &mut D, ) -> Result<Vec<(ThreadId, StepOutcome)>, Box<dyn Error + Send + Sync>>

Run one step for every thread with messages in inputs, concurrently. This is the whole per-slice job of a step-mode embedding (e.g. one Lambda invocation).

The batch may span multiple threads (InputMessage::group_id) — e.g. an SQS FIFO delivery with a batch size above 1 can interleave several message groups. step partitions the batch by thread (preserving arrival order within each), applies the deferral policy per thread, and then joins the per-thread steps: each loads the thread’s history and dedup state from the stores, prepares its inputs into history, runs at most one completion round, commits durably, and dispatches at most one asynchronous tool call. Returns each thread’s StepOutcome.

Nothing is cached between calls — the loaded thread state lives only for the duration of the call, which is what makes this fit serverless platforms. Steps must still be serialized per thread across calls: within a process the &mut self receiver enforces it (embeddings that want more in-process concurrency build one system per worker from their cloneable stores); across processes it is the transport’s job — e.g. SQS FIFO message groups.

defer is consulted once per thread in the batch; a durable DeferQueue implementation serving multi-thread batches should key its storage by InputMessage::group_id.

If any thread’s step fails, the first error is returned — but only after every thread’s step has run to completion, so one thread’s failure never aborts another’s mid-commit.

Auto Trait Implementations§

§

impl<C, S, M, H> !RefUnwindSafe for AgentSystem<C, S, M, H>

§

impl<C, S, M, H> !Send for AgentSystem<C, S, M, H>

§

impl<C, S, M, H> !Sync for AgentSystem<C, S, M, H>

§

impl<C, S, M, H> !UnwindSafe for AgentSystem<C, S, M, H>

§

impl<C, S, M, H> Freeze for AgentSystem<C, S, M, H>
where Rc<SystemInner<C, S, M, H>>: Freeze,

§

impl<C, S, M, H> Unpin for AgentSystem<C, S, M, H>
where Rc<SystemInner<C, S, M, H>>: Unpin,

§

impl<C, S, M, H> UnsafeUnpin for AgentSystem<C, S, M, H>
where Rc<SystemInner<C, S, M, H>>: UnsafeUnpin,

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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