pub struct A2aExecutor { /* private fields */ }target_family=wasm only.Expand description
A Rig Agent as an A2A AgentExecutor.
Each execution prompts the agent with the incoming message and the history
of its contextId, streams the reply’s text into one artifact, and ends the
task completed, failed, or rejected when a part has no Rig content kind or
the contextId is not 1 to 128 ASCII letters, digits, - or _. A
completed run’s messages join the context’s history; see
history_store and
history_window for where it lives and how much
of it the model sees. Cancelling a task drops its run.
Every task spends model tokens, so an executor bounds them: at most
max_concurrent_tasks run at once (more are
rejected as busy, before any model call) and each stops after
max_run_duration.
Implementations§
Source§impl A2aExecutor
impl A2aExecutor
Sourcepub fn new(agent: Agent) -> Self
pub fn new(agent: Agent) -> Self
An executor that answers every task with agent, keeping
conversations in memory.
Sourcepub fn typed<T>(self) -> Self
pub fn typed<T>(self) -> Self
Answer every task with a T, as one JSON data part: the agent runs
as Agent::prompt_typed does (with the conversation’s history, and
two retries when the model’s JSON does not parse as T). Use it to
serve an extractor or any agent whose callers want data, not prose.
Sourcepub fn max_concurrent_tasks(self, max: usize) -> Self
pub fn max_concurrent_tasks(self, max: usize) -> Self
Run at most max tasks at once (at least one); a task beyond that is
rejected as busy before it reaches the model. Defaults to
DEFAULT_MAX_CONCURRENT_TASKS.
Sourcepub fn max_run_duration(self, max: Duration) -> Self
pub fn max_run_duration(self, max: Duration) -> Self
Stop a run that takes longer than max, failing its task. Defaults to
DEFAULT_MAX_RUN_DURATION.
Sourcepub fn max_contexts(self, max: usize) -> Self
pub fn max_contexts(self, max: usize) -> Self
Keep conversations in memory, at most max of them (at least one);
the oldest one started is forgotten first. This is the default, with
DEFAULT_MAX_CONTEXTS; it replaces a history_store.
Sourcepub fn history_store<S>(self, store: S) -> Self
pub fn history_store<S>(self, store: S) -> Self
Keep conversations in store, one session log per contextId, so
they survive restarts and several servers can share them: any
rig_memory store, such as rig_memory::DirStore (feature fs)
or the rig-sqlite and rig-postgres stores. Two servers saving one
conversation at once do not lose either turn.
Sourcepub fn history_window(self, window: impl Recent + 'static) -> Self
pub fn history_window(self, window: impl Recent + 'static) -> Self
Which newest messages of a conversation each request sends the
model, such as rig_memory::recent::TokenBudget::new(8_000) or
LastMessages(20). Defaults to DEFAULT_HISTORY_TOKENS tokens. A
tool result is never sent without its call.
Trait Implementations§
Source§impl AgentExecutor for A2aExecutor
impl AgentExecutor for A2aExecutor
Source§fn execute(
&self,
ctx: ExecutorContext,
) -> BoxStream<'static, Result<StreamResponse, A2AError>>
fn execute( &self, ctx: ExecutorContext, ) -> BoxStream<'static, Result<StreamResponse, A2AError>>
Source§fn cancel(
&self,
ctx: ExecutorContext,
) -> BoxStream<'static, Result<StreamResponse, A2AError>>
fn cancel( &self, ctx: ExecutorContext, ) -> BoxStream<'static, Result<StreamResponse, A2AError>>
Auto Trait Implementations§
impl !RefUnwindSafe for A2aExecutor
impl !UnwindSafe for A2aExecutor
impl Forget for A2aExecutor
impl Freeze for A2aExecutor
impl Move for A2aExecutor
impl Send for A2aExecutor
impl Sync for A2aExecutor
impl Unpin for A2aExecutor
impl UnsafeUnpin for A2aExecutor
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request