Skip to main content
Combines Stream() with conversation history — demonstrates event handling so you do not print the same assistant text twice (deltas vs final body). Source: examples/agent_with_stream_conversation/

What it demonstrates

  • Stream with ConversationOptions
  • Distinguishing TEXT_MESSAGE_CONTENT deltas from RUN_FINISHED aggregate content
  • Pattern for chat UIs that stream then finalize

Key code

This example uses in-memory conversation (no Redis required). The key pattern: print deltas on TEXT_MESSAGE_CONTENT and do not reprint RUN_FINISHED.Result.Content — it duplicates the streamed text.

Run

From examples/:

Expected output

Tokens print as they stream; the run exits after RUN_FINISHED. Run again with a follow-up — in-memory history carries context within the same process (use Redis + conversation.mdx for cross-process persistence).

Learn more

Stream

Base streaming example

Conversation

Session history