Appearance
State
Each subroutine invocation has a payload, invocation parameters, node-local state, and feature state. These values differ in ownership and lifetime:
| Value | Owner and lifetime | Access |
|---|---|---|
| Payload | Flows from the subroutine Input through visits to its Output. | A visit receives its edge-specific Input and, except for a Feature visit, returns Success.output. |
Params | Selected for one subroutine invocation. | Visits read context.params. |
Node-local State | One value per non-Feature executable node, initialized at graph entry and retained across revisits. | Each visit receives its target node's state and returns a replacement through Success.state. |
| Feature state | One value per declared feature, initially None in each graph invocation. | Edge conditions observe it; Feature visits propose changes checked by outgoing effects. |
The runtime constructs every node-local State with no arguments before executing the enter port. Its type must be a frozen, slotted dataclass with direct fields, immutable defaults, and a generated initializer. Inherited fields and default factories are rejected. A returned state must have exactly the declared node state type and recursively immutable contents.
All incoming visits to a node share that node's state. A value required by another node should travel through the payload; a temporary value used only within one visit should remain a local variable.
Every feature starts at None, with no initializer callback. A Feature visit uses FeatureState.get(FEATURE) and FeatureState.replace(FEATURE, value) to propose values in the feature's declared domain. It returns FeatureSuccess and preserves the payload. The first assignment requires an assignment or unconstrained effect on the outgoing edge; evaluating a condition on a feature that is still None raises ValueError. An initialized feature cannot be reset to None.
Routing evaluates conditions against the state before the source visit and effects against that state and the proposed successor. Exactly one compatible outgoing edge is required. Zero or multiple compatible edges raise an exception; the candidate state does not become the next graph state. This commit rule does not undo files, agent requests, or other external effects performed by the visit.
Every child invocation initializes its own node and feature state. A Subroutine call shares the parent process; a Workflow call uses a separate process. In both cases, context.invoke() returns the child's output, not its internal state. A call node's own state remains part of the parent invocation. The call adapter may be evaluated again around a durable child invocation, but only the returned Success commits its candidate node-local state.
Provider conversation state has a separate lifetime, determined by the selected session resource. Managed run directories contain both public artifacts and private checkpoint state when checkpointing is enabled; see Runs and resumption.