pub struct WorkerResult {
pub value: Value,
pub ok: bool,
pub stats: Option<WorkerStats>,
}Expand description
The value a WorkerFn hands back on success, folded into an
OutputEvent::Final by the spawner.
Fields§
§value: ValueThe worker fn’s output payload.
ok: boolWhether the agent itself considers this a successful result
(distinct from Result::Err — a worker fn can return Ok(..)
with ok: false to signal an agent-level failure).
stats: Option<WorkerStats>Optional normalized per-attempt stats sidecar (token usage /
model / num_turns / adapter-specific raw data), produced by the
worker boundary that knows them (agent-block result captor,
subprocess stdout normalization, …). The spawner’s fold site
forwards it to Engine::record_worker_stats; it never rides
into OutputEvent::Final (the BP-chain value stays stats-free).
None = no stats reported — every pre-stats worker fn is
unaffected (#[serde(default)] keeps wire compat).
Implementations§
Source§impl WorkerResult
impl WorkerResult
Sourcepub fn ensure_worker_kind(self, kind: &str) -> Self
pub fn ensure_worker_kind(self, kind: &str) -> Self
Ensure stats.worker_kind is set — the design invariant that
every dispatched step’s terminal StepEntry carries at least
its worker kind label (“rust_fn” / “lua” / “agent_block” /
“subprocess” / “operator” / …), even when no LLM-shaped stats
(usage / model / num_turns) apply. Idempotent: if a boundary
already reported a worker_kind (agent_block / subprocess
stats sidecar, operator ack), that value wins; otherwise the
fold site’s kind becomes the value. Called at every worker
fold site (InProcSpawner spawn task, subprocess spawn task,
OperatorDelegateMiddleware).
Trait Implementations§
Source§impl Clone for WorkerResult
impl Clone for WorkerResult
Source§fn clone(&self) -> WorkerResult
fn clone(&self) -> WorkerResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WorkerResult
impl Debug for WorkerResult
Source§impl<'de> Deserialize<'de> for WorkerResult
impl<'de> Deserialize<'de> for WorkerResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for WorkerResult
impl RefUnwindSafe for WorkerResult
impl Send for WorkerResult
impl Sync for WorkerResult
impl Unpin for WorkerResult
impl UnsafeUnpin for WorkerResult
impl UnwindSafe for WorkerResult
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 more