Multi-turn sessions
Multi-turn sessions
Maintain conversation context across multiple requests. Use multi-turn sessions when you want to ask follow-up questions, explore a video collection iteratively, or build a chat interface that preserves context across turns. This guide covers how to start a session, continue it with follow-up messages, and build a reusable chat pattern.
Key concepts
- Session: A server-side conversation state that Jockey maintains across requests. You do not need to resend previous messages - Jockey remembers the full conversation history within a session. Each response includes a
session_idthat you pass on subsequent requests to continue the conversation.
Prerequisites
- You’ve already uploaded your content, and the asset has reached the
readystatus. See the Upload content page for details. - You’ve already created a knowledge store. See the Create a knowledge store page for details.
- You’ve already added at least one asset to the knowledge store, and the item has reached the
readystatus. See the Add assets page for details. - You’ve already read the Create a response page and understand the basic request and response format.
Start a session
Omit session_id on your first request. Jockey creates a new session and returns its ID in the response. Store this ID for follow-up requests.
Continue the conversation
Pass the session_id from the previous response to send follow-up messages. Jockey uses the full conversation history to inform its answers, so you can reference earlier results without repeating context.
Build a reusable chat function
For chat UIs or interactive applications, wrap the session logic in a function. The function creates a new session on the first call and reuses it for subsequent calls.
Common pitfalls
- Store the
session_id. If you lose it, you cannot continue the conversation. Start a new session instead. - Use the same knowledge store. Keep the same
knowledge_store_idacross turns for consistent results. - Session state is server-side. You do not need to resend conversation history - Jockey tracks it for you.
Next steps
- Streaming - combine multi-turn sessions with real-time streaming
- Structured output - get typed JSON responses within a session
- Create a response - review the basic request and response format
Jupyter notebook
Download the notebook to run this guide interactively.