pub struct Agent<H> {Show 28 fields
pub id: AgentId,
pub consumer_group: Option<ConsumerGroupName>,
pub listen_on: AgentTopic<'static>,
pub handler: H,
pub respond_on: Option<AgentTopic<'static>>,
pub inbox_route: InboxRoute,
pub poll_interval: Option<Duration>,
pub shutdown_grace: Option<Duration>,
pub concurrency: Option<ConcurrencyPolicy>,
pub max_queued_records: Option<usize>,
pub max_queued_bytes: Option<usize>,
pub warm_dedup: bool,
pub middleware: Vec<Arc<dyn AgentMiddleware>>,
pub on_dead_letter: Option<Arc<dyn DeadLetterSink>>,
pub operations: Option<Vec<String>>,
pub sessions: Option<SessionConfig>,
pub dedup_window: Option<usize>,
pub retry: Option<RetryPolicy>,
pub understood_features: u64,
pub deduplicator: Option<Box<dyn Deduplicator>>,
pub verifier: Option<Arc<KeyRegistry>>,
pub signing_key: Option<Arc<SigningKey>>,
pub capabilities: Vec<CapabilityDescriptor>,
pub ack_on_pickup: bool,
pub consolidate_every: Option<Duration>,
pub consolidator: Option<SharedConsolidator>,
pub governor: Option<(Arc<dyn ActionGovernor>, GovernorMode)>,
pub governor_retention: Option<GovernorRetention>,
}Expand description
One logical agent defaults to one Iggy consumer group.
spawn derives the group name from id unless consumer_group is set. Horizontal
scaling (multiple replicas of the same agent) means multiple processes
joining that group, and Iggy load-balances messages across them.
Do NOT put two different agent ids in the same group. The
ReliableConsumer skips messages whose agdx.to does not
match its own id, which is the right behavior when a publisher
addresses a specific agent on a shared topic. If two agents shared
a group, Iggy would still deliver each message to exactly one member,
and if it landed on the wrong one the filter would drop it and the
intended agent would never see it. Each Agent::builder().id(...).spawn(..)
call is its own consumer group. Do not bypass that by reusing the
consumer group name across distinct agent ids.
Fields§
§id: AgentIdThe agent’s stable logical identity.
consumer_group: Option<ConsumerGroupName>Deployment group for load balancing replicas. Defaults to the agent id’s spelling but remains a distinct type and may be overridden explicitly.
listen_on: AgentTopic<'static>The topic this agent consumes.
handler: HThe handler invoked for each message.
respond_on: Option<AgentTopic<'static>>Default reply topic for AgentCtx::respond (none = respond errors).
inbox_route: InboxRouteDefault route from a resolved target agent to the topic its work is sent
on, used by AgentCtx::fan_out and the
directed-send helpers. Sticks as this agent’s routing convention. Defaults
to InboxRoute::Advertised (resolve each target to its live-presence
inbox). Set InboxRoute::Fixed for a workflow topic the caller owns.
poll_interval: Option<Duration>Override the consumer poll interval (default: the runtime’s reactive 10ms).
shutdown_grace: Option<Duration>How long AgentHandle::shutdown waits for the in-flight message to
finish draining before the consumer is dropped. AgentHandle::abort is
the unconditional hard stop. Defaults to the consumer’s 30s grace.
concurrency: Option<ConcurrencyPolicy>How message handling is scheduled across the partitions this agent is
assigned. Defaults to ConcurrencyPolicy::Serial. Set
ConcurrencyPolicy::SerialPerPartition so a slow or retrying message on
one partition does not stall the others.
max_queued_records: Option<usize>Override the total records buffered across partition lanes.
max_queued_bytes: Option<usize>Override the total payload and header bytes buffered across partition lanes.
warm_dedup: bool§middleware: Vec<Arc<dyn AgentMiddleware>>Cross-cutting hooks wrapped around each handler dispatch, in order, for auth, metrics, and tracing without touching the handler.
on_dead_letter: Option<Arc<dyn DeadLetterSink>>Notified on every dead-letter with the result of publishing it, so a lost poison message is an observable event rather than only a log line.
operations: Option<Vec<String>>The command operations the handler serves. Unset serves every operation. A command for another operation is skipped.
sessions: Option<SessionConfig>The session configuration the agent’s runtime applies: the lens
AgentCtx::session opens and
SessionConfig::fail_on_dead_letter.
Defaults to SessionConfig::default.
dedup_window: Option<usize>Override the dedup window size (recent idempotency keys kept in memory).
Defaults to the ReliableConsumer default when unset.
retry: Option<RetryPolicy>Override the handler retry policy (attempts + backoff for a retryable
handler error). Defaults to the RetryPolicy default when unset.
understood_features: u64Must-understand AGDX feature bits implemented by this agent. A message requiring any other bit is dead-lettered before the handler runs.
deduplicator: Option<Box<dyn Deduplicator>>Override the dedup backend (e.g. a durable StateStore-backed one). Defaults
to the in-memory sliding window.
verifier: Option<Arc<KeyRegistry>>The signature verifier for control and effect topics: when set, every message’s envelope signature is verified against this registry before dispatch, and an unsigned or unverified record is dead-lettered. This is the enforcement gate for authorship and authorization, so it is reachable from the primary builder rather than only the lower-level consumer.
signing_key: Option<Arc<SigningKey>>This agent’s signing identity: when set, AgentCtx::respond answers a
correlated command with a signed AGDX response instead of a plain reply,
so a caller holding a verifier (and the contract path’s signer binding)
can accept this agent’s terminals and no one else’s.
capabilities: Vec<CapabilityDescriptor>What this agent serves. When non-empty, on spawn the agent publishes a
capability card to the registry (so capability routing can discover it) and
advertises its inbox (its listen_on topic) as live presence (so a fan-out
resolves where to send it work). Empty means a private agent that does not
advertise, the prior behavior.
ack_on_pickup: boolEmit a Working status the moment an AGDX command is picked up, before the
handler runs, so a Laser::contract caller
can tell the command was consumed. Off by default. Enable it on agents that
take contracted work, with a respond_on set.
consolidate_every: Option<Duration>Run consolidator every consolidate_every off the handler loop (its
own task, stopped with the agent). Both must be set for the tick to
exist. Absent means no background consolidation, ever. Each pass runs
over this agent’s own memory: the scope carries the agent id and
nothing else. A zero period fails the agent with
LaserError::Config instead of starting.
consolidator: Option<SharedConsolidator>The consolidation pass the periodic tick runs (see
consolidate_every).
governor: Option<(Arc<dyn ActionGovernor>, GovernorMode)>The pre-effect policy hook applied to everything this agent’s handler
publishes (ctx.send/respond/request/fan_out, AGDX verbs, memory
writes), with the GovernorMode it runs
under. Spawn re-scopes the agent’s Laser with it, so a governor set on
the connection is replaced for this agent. See
Laser::with_governor.
governor_retention: Option<GovernorRetention>Process-local evidence-chain retention for this agent’s governor. A restart or eviction begins a new local chain for the conversation.
Implementations§
Auto Trait Implementations§
impl<H> !RefUnwindSafe for Agent<H>
impl<H> !UnwindSafe for Agent<H>
impl<H> Freeze for Agent<H>where
H: Freeze,
impl<H> Send for Agent<H>where
H: Send,
impl<H> Sync for Agent<H>where
H: Sync,
impl<H> Unpin for Agent<H>where
H: Unpin,
impl<H> UnsafeUnpin for Agent<H>where
H: UnsafeUnpin,
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.