final history = <ChatMessage>[];
// Step 1: Calculate data
await for (final chunk in agent.sendStream(
'Calculate the first 10 Fibonacci numbers and store them in a variable '
'called "fib_sequence".',
)) {
stdout.write(chunk.output);
history.addAll(chunk.messages);
}
// Step 2: Use the data from step 1
await for (final chunk in agent.sendStream(
'Using fib_sequence, create a plot showing the golden ratio convergence. '
'Save it as "golden_ratio.png".',
history: history,
)) {
stdout.write(chunk.output);
history.addAll(chunk.messages);
}