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,
impl<C, S, M, H> AgentSystem<C, S, M, H>where
C: ConversationStore + 'static,
S: StateStore + 'static,
M: InputSender + 'static,
H: HttpClient + 'static,
Sourcepub 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>>
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.