record

suspend fun <State> Flow<GraphEvent<State>>.record(): RunRecord<State>

Runs the graph of this stream to its end and returns what happened, in a form a test can compare:

val run = agent.stream(AgentState("Where is my pizza?")).record()

assertEquals(listOf("model", "tools", "model"), run.nodes)
assertEquals("Your pizza is 5 minutes away.", run.text)
assertEquals("Your pizza is 5 minutes away.", run.state.answer)

A run that fails throws here, as it does when the stream is collected.