pub trait Operator: Send + Sync {
// Required method
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 Ctx,
system: Option<String>,
prompt: String,
worker: Option<WorkerBinding>,
worker_token: CapToken,
) -> Pin<Box<dyn Future<Output = Result<WorkerResult, WorkerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn requires_worker_binding(&self) -> bool { ... }
}Expand description
The Operator trait: takes a spawn request and returns a
WorkerResult. The backend for OperatorSpawner. Implementations
are free to differ per kind; the spawner just calls execute and
stays out of the internals.
Arguments — a two-slot payload plus worker_token (the thin path
was added later) plus worker (the Blueprint-baked binding, added
later still):
system: the agent persona — the rendered value ofAgentDef.profile.system_promptafter template expansion.Nonemeans no profile. Expected to map straight onto the LLM API’s system message; direct-LLM operators consume this.prompt: task-specific intent —TaskSpec.initial_directive, pulled server-side viaengine.fetch_prompt. Expected to map straight onto the LLM API’s user message.worker: the compile-time-bakedWorkerBinding(subagent type + declared tools) resolved fromAgentDef.profile.worker_binding.Nonefor agents whose profile has noworker_bindingset. Backends that require one (seeOperator::requires_worker_binding) must fail loud rather than silently degrade when this isNone.worker_token: a capability token (Role::Worker, 600s TTL,scopes = ["*"]). Thin-path operators (aa WebSocket-backed operator session, for instance)encode()this token and hand it to the MainAI WebSocket client, so the SubAgent can hit/v1/worker/prompt+/v1/worker/resultwithAuthorization: Bearer <encoded>. Direct-LLM operators may ignore it.
The trait passes both slots so the same signature works for the
thin path and the direct path; the implementation picks which one
it takes (consume the server-rendered system directly, or forward
the token and let the client fetch).
Required Methods§
Sourcefn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 Ctx,
system: Option<String>,
prompt: String,
worker: Option<WorkerBinding>,
worker_token: CapToken,
) -> Pin<Box<dyn Future<Output = Result<WorkerResult, WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 Ctx,
system: Option<String>,
prompt: String,
worker: Option<WorkerBinding>,
worker_token: CapToken,
) -> Pin<Box<dyn Future<Output = Result<WorkerResult, WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Executes one spawn request against this operator’s backend and
returns the resulting WorkerResult (or a WorkerError if the
backend failed). See the trait doc above for the meaning of each
argument.
Provided Methods§
Sourcefn requires_worker_binding(&self) -> bool
fn requires_worker_binding(&self) -> bool
Whether this operator backend requires a non-None worker
binding to execute at all. false by default (direct-LLM
operators consume system / prompt directly and have no
SubAgent to dispatch). WS thin-path operators override this to
true — the compiler uses it to fail loud at compile() time
when AgentDef.profile.worker_binding is absent, rather than
silently degrading at dispatch time.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".