pub trait Operator: Send + Sync {
// Required method
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 Ctx,
system: Option<String>,
prompt: String,
worker_token: CapToken,
) -> Pin<Box<dyn Future<Output = Result<WorkerResult, WorkerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}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):
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_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_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_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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".