Runtime and context¶
The per-node Context and the StreamEvent yielded by stream(). See The Context object.
agentflow.runtime.Context
dataclass
¶
Per-node handle: identity, event emission, and interrupts.
Source code in agentflow/runtime.py
emit
¶
Surface an event to the run's stream and telemetry hooks.
Accepts any backend event (TextChunk, ToolCall, ...) or a
run-level :class:~agentflow.events.GateEvent.
Source code in agentflow/runtime.py
interrupt
async
¶
Suspend the run for a human, or return the supplied answer on resume.
On a fresh run this raises :class:InterruptError; the runtime catches
it, writes an interrupted checkpoint, and stops. When the run is later
resumed with a value, that value is seeded here and returned directly.
Source code in agentflow/runtime.py
wait
async
¶
Suspend the run until wake_at (an ISO-8601 time), then re-run.
This is a timer-based sibling of :meth:interrupt: a fresh call
suspends the run with a checkpoint marked to wake no earlier than
wake_at, and no human answer is needed — the clock resolves it.
When the run resumes (the control plane re-claims it once the time
passes, or an inline runner sleeps until then), this call returns and
the node runs again, typically to poll an external system once more.
payload is persisted on the checkpoint (e.g. a watcher cursor) so
the node can pick up where it left off. On resume the seeded value is
returned, mirroring :meth:interrupt; a watcher usually ignores it and
reads its cursor from state instead.
Source code in agentflow/runtime.py
agentflow.runtime.StreamEvent
dataclass
¶
One observable moment in a run, yielded by CompiledGraph.stream.