Session versus turn
A session holds configuration, conversation, and saved work over time. A turn is one cycle of work. Input to an idle session starts a new turn; input while a turn is active steers ongoing work. Store the session ID against the correct application user and conversation.
Keep continuity explicit
Reuse the same session for follow-up requests. Opening a new session starts separate work. Open the event stream before sending follow-up input so early events are not missed. Persist identifiers in application storage rather than relying on one browser tab.
Recover before retrying
A broken network connection does not tell you whether agent work stopped. Retrieve session state and saved items. Check pending required actions and completed turns, then decide whether to reconnect, return a stored tool result, or send new input.
Separate resource lifetimes
Session history and environment files have different lifetimes. A durable conversation is not a guarantee that sandbox files remain available. Publish or copy outputs and follow environment lifecycle rules before stopping compute or deleting sessions.
Read the official reference
Check the source for current API fields, account requirements, and service limits.
OpenAI: sessions