Passing Message History
The simplest approach is to feed the messages from one run into the next:Session IDs
Usesession_id to logically group runs that belong to the same conversation. This is recorded in traces and makes it easy to correlate runs:
Building a Conversation Loop
A typical interactive conversation loop:Async Conversation Loop
Streaming Multi-Turn
When streaming, collect the finalRunCompleted event to get the messages for the next turn:
Message Structure
Each message in the history is aMessage object with:
Messages include system prompts, user inputs, assistant responses, and tool call results. The full history is sent to the model on each turn, so be mindful of token limits in very long conversations.