pub struct WorkerInvocation {
pub token: CapToken,
pub task_id: TaskId,
pub attempt: u32,
pub agent: String,
pub prompt: String,
pub sink: Option<Arc<dyn OutputSink>>,
pub cancel_token: Option<CancellationToken>,
}Expand description
Invocation context handed to a Worker fn. Bundles token +
task_id + prompt + sink.
The prompt field was added in design intent, folding the old
Fn(inv, directive) directive argument into the invocation. The
spawner is expected to call
engine.fetch_prompt(token, task_id, attempt) in its prep step and
inject the snapshot into the invocation (push form). The WorkerFn
side may still re-pull if it needs to — for example to fetch the
prompt for a different attempt.
The sink field was added in design intent as the formal contract for
the spawner’s intake surface. A worker fn can stream intermediate
events with things like
inv.sink.emit(OutputEvent::Progress { .. }). Child-process
spawners (ProcessSpawner, etc.) do not use sink — the child
speaks the stdout protocol; InProcSpawner injects one. Even
without sink, the WorkerResult returned by the fn is still
folded into a Final event on the spawner side, running alongside
the older return-value path.
Fields§
§token: CapTokenCapability token authorizing this attempt.
task_id: TaskIdThe task this invocation belongs to.
attempt: u32Attempt number within the task (used to key output events).
agent: StringRegistered agent name the WorkerFn was looked up under.
prompt: StringThe prompt/prep snapshot pulled via engine.fetch_prompt,
injected here (push form) so the worker fn does not need to call
back into the engine for the common case.
sink: Option<Arc<dyn OutputSink>>Intake: sink the worker fn uses to emit intermediate
OutputEvents. Injected by InProcSpawner. None means the
sink path is not wired for this invocation.
cancel_token: Option<CancellationToken>Upstream task cancel token — the clone of cancel_inner
generated by InProcSpawner for JoinHandleWorker. Worker fns
bridge this to their child futures or their SDK’s
shutdown_token, propagating external cancellation all the way
down. None — like sink above — means the caller path is not
carrying the cancel channel.
Trait Implementations§
Source§impl Clone for WorkerInvocation
impl Clone for WorkerInvocation
Source§fn clone(&self) -> WorkerInvocation
fn clone(&self) -> WorkerInvocation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for WorkerInvocation
impl !UnwindSafe for WorkerInvocation
impl Freeze for WorkerInvocation
impl Send for WorkerInvocation
impl Sync for WorkerInvocation
impl Unpin for WorkerInvocation
impl UnsafeUnpin for WorkerInvocation
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> 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