pub struct WorkflowNode {
pub task: RuntimeTask,
pub role: AgentRole,
pub isolation: AgentIsolation,
pub context_inheritance: ContextInheritance,
pub model_hint: Option<String>,
pub trust: NodeTrust,
pub output_schema: Option<Value>,
pub kind: NodeKind,
pub token_budget: Option<u64>,
pub depends_on: Vec<usize>,
}Expand description
One node in a workflow DAG: a task plus the contract its agent runs under.
Fields§
§task: RuntimeTask§role: AgentRole§isolation: AgentIsolation§context_inheritance: ContextInheritance§model_hint: Option<String>Optional model preference (e.g. “opus” / “sonnet”); the SDK resolves it. See W4.
trust: NodeTrustW3 trust level. Default Trusted.
output_schema: Option<Value>G3 structured output: an optional JSON Schema the node’s agent output must conform to. The kernel is zero-I/O and never validates it — it carries the schema verbatim to the spawn descriptor so the SDK can instruct the agent and validate/retry on its result (the structured “summary only” contract from image 8 is enforced SDK-side; the kernel owns the contract). Additive: omitted on the wire when absent.
kind: NodeKindControl-flow kind. Default Spawn (run once).
token_budget: Option<u64>M4/G5: optional per-node cumulative token cap. The kernel carries it to the spawn descriptor;
the SDK sets the node’s child-run max_total_tokens to it, so an expensive node self-terminates
at the cap (the “use N tokens” budget, applied per node). Additive: omitted on the wire when
None.
depends_on: Vec<usize>Indices into WorkflowSpec::nodes this node depends on.
Implementations§
Source§impl WorkflowNode
impl WorkflowNode
Sourcepub fn new(task: RuntimeTask, role: AgentRole) -> Self
pub fn new(task: RuntimeTask, role: AgentRole) -> Self
A node with role-default isolation/inheritance and no dependencies.
Sourcepub fn with_token_budget(self, tokens: u64) -> Self
pub fn with_token_budget(self, tokens: u64) -> Self
M4/G5: cap this node’s child run at tokens cumulative tokens.
Sourcepub fn with_loop(self, max_iters: usize) -> Self
pub fn with_loop(self, max_iters: usize) -> Self
Make this a loop node: re-run the agent up to max_iters times before completing.
Dependents wait for the whole loop to finish.
Sourcepub fn with_classify(self, branches: Vec<ClassifyBranch>) -> Self
pub fn with_classify(self, branches: Vec<ClassifyBranch>) -> Self
Make this a classify node: its result selects one of branches to run; the rest are pruned.
Sourcepub fn with_tournament(self, entrants: Vec<RuntimeTask>) -> Self
pub fn with_tournament(self, entrants: Vec<RuntimeTask>) -> Self
Make this a tournament controller node: it spawns no agent of its own but generates each
of entrants (in parallel), then pairwise-judges them to a single winner. The node’s own
task.goal is the judging criterion handed to every judge. Requires ≥2 entrants.
Sourcepub fn with_reduce(self, reducer: impl Into<String>) -> Self
pub fn with_reduce(self, reducer: impl Into<String>) -> Self
G2: make this a deterministic reduce node — it runs no LLM agent; the SDK routes it to the
registered reducer function over its dependencies’ outputs (dedupe / filter / merge). Give
it depends_on the nodes whose outputs it consumes.
pub fn with_depends_on(self, depends_on: Vec<usize>) -> Self
pub fn with_isolation(self, isolation: AgentIsolation) -> Self
pub fn with_context_inheritance(self, inheritance: ContextInheritance) -> Self
pub fn with_model_hint(self, hint: impl Into<String>) -> Self
Sourcepub fn with_trust(self, trust: NodeTrust) -> Self
pub fn with_trust(self, trust: NodeTrust) -> Self
W3: mark this node’s trust level. Quarantined nodes read untrusted content and are
kernel-enforced to read-only (a quarantined node declaring write isolation is denied).
Sourcepub fn quarantined(self) -> Self
pub fn quarantined(self) -> Self
Mark this node as quarantined (reads untrusted content, runs without privileges).
Sourcepub fn with_output_schema(self, schema: Value) -> Self
pub fn with_output_schema(self, schema: Value) -> Self
G3: require this node’s output to conform to a JSON Schema. The kernel carries it verbatim to the spawn descriptor; the SDK instructs the agent and validates/retries on its result.
Trait Implementations§
Source§impl Clone for WorkflowNode
impl Clone for WorkflowNode
Source§fn clone(&self) -> WorkflowNode
fn clone(&self) -> WorkflowNode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more