reportProgress

suspend fun reportProgress(value: Any)

Reports value from a running node to whoever collects the run: it arrives as a GraphEvent.NodeProgress in the flow of CompiledGraph.stream or CompiledGraph.streamResume, before the node's GraphEvent.NodeCompleted. Use it for what a node produces while it works, such as the text a model writes or how far a download is.

val download = node("download", work = { order ->
files.forEachIndexed { index, file ->
fetch(file)
reportProgress("${index + 1} of ${files.size}")
}
}) { order, _ -> order.copy(downloaded = true) }

Call it from the action of a node, or from the work of a node with a work and an update. The call returns when the collector has handled the event, so a slow collector slows the node down instead of filling memory. It does nothing when the run was started with CompiledGraph.invoke or CompiledGraph.resume, because nobody collects those, and nothing outside a running node.

Progress is not part of the state: it is not saved in a checkpoint, and a step that runs again after a failure reports again.