Conversation Management
QALITA Studio tracks conversations in the Platform database, linking them to issues, sources, and projects for easy retrieval.
Conversation Storage
Database Model
Conversations are stored in the studio_conversation table:
| Column | Type | Description |
|---|---|---|
id | int | Primary key |
conv_id | str | Unique conversation identifier |
filename | str | Stored as <conv_id>.jsonl |
partner_id | int | Organization FK |
issue_id | int | Linked issue (optional) |
source_id | int | Linked source (optional) |
project_id | int | Linked project (optional) |
line_count | int | Number of messages |
created_at | datetime | Creation timestamp |
updated_at | datetime | Last update timestamp |
Conversation Content
Conversation content (messages) may be stored:
- In S3-compatible object storage (for full content)
- As metadata only in the database (line count, timestamps)
Message Format (when stored)
Studio saves each conversation as a JSONL file: one JSON object per line, in the order the messages appeared. Questions and answers carry role, text and ts (ISO 8601, left out when unknown):
{"role": "user", "text": "How many paid orders?", "ts": "2026-10-24T09:00:00.000Z"}
{"role": "assistant", "text": "There are 42 paid orders.", "ts": "2026-10-24T09:00:05.000Z"}
Each query the agent runs adds a tool_call line, followed by a tool_result line with the same tool_id, between the question and the answer:
{"role": "tool_call", "text": "execute_sql_query", "ts": "2026-10-24T09:00:01.000Z", "tool_name": "execute_sql_query", "tool_args": {"source_id": 3, "sql": "SELECT status, count(*) FROM orders GROUP BY status"}, "tool_id": "call_1"}
{"role": "tool_result", "text": "Columns: status, count\nRows (2 shown, 2 total):\n...", "ts": "2026-10-24T09:00:03.000Z", "tool_name": "execute_sql_query", "tool_ok": true, "tool_id": "call_1"}
| Field | Lines | Description |
|---|---|---|
role | all | user, assistant, tool_call or tool_result |
text | all | Message text; for a tool_result, the result or the error (Error: ...) |
ts | all | When the message appeared |
tool_name | tool lines | Name of the tool, such as execute_sql_query or count_rows |
tool_args | tool_call | Arguments of the call; sql holds the statement of execute_sql_query |
tool_id | tool lines | Pairs a result with its call, even when the same tool runs several times |
tool_ok | tool_result | false when the tool failed |
tool_truncated_from | tool_result | Original length of a result that was cut |
Each result is kept up to 20,000 characters. A longer result is cut, tool_truncated_from records its original length, and Studio says so under the result.
Files saved before this format have no tool_id and only a short summary of each result. They still open: their calls and results are paired by tool name.
Studio shows the answers as Markdown (GitHub-flavoured: tables, lists, code blocks, links). HTML in an answer or in a saved file is shown as text, not rendered; only a <br> line break is kept.
Access to a Stored Conversation
A stored conversation holds the results of the queries the agent ran, so reading it requires read access to each source those results may come from:
- the conversation's linked source (
source_id); - every source a recorded query ran on (
tool_args.source_idof thetool_calllines). A call whose result is recorded as failed (tool_ok: false) returned no data and is not checked.
Without that access, the download is refused with the same error as the source itself, for example 403 with the code PRIVATE_NOT_SHARED. Studio then shows the conversation as unavailable, with the reason, and does not let you continue it: start a new conversation instead.
A conversation linked to no source and recording no query on one is readable by every member of the organization who can read Studio conversations. This is the case for conversations saved before executed queries were stored, unless they are linked to a source.
Saving a Conversation
Saving a conversation (POST /api/v1/studio/conversations) requires the studio_conversation:create permission. The issue and project routes (POST /api/v1/issues/{id}/studio_conversations, POST /api/v1/projects/{id}/studio_conversations) require issue:update and project:update.
The Platform names the stored file <conv_id>.jsonl; a filename sent by the client is ignored. conv_id is a plain file name: letters, digits, ., _ and -, starting with a letter or a digit, 128 characters at most. Any other conv_id is refused with 422. A conv_id names one conversation of the organization, wherever it is linked: the issue and project routes update that conversation and link it to the issue or project. The project route keeps the conversation's issue link when issue_id is left out.
A save never writes over the file of another conversation. A conversation saved before this rule may be stored under a file name that is not its own conv_id: a save whose <conv_id>.jsonl is already that file is refused with 409, and you save under another conv_id. When the file belongs to an older entry with the same conv_id, the author-or-admin rule below applies instead.
Only the author of a conversation, or an admin, can save over it; anyone else gets 403. The conversation listings (GET /api/v1/studio/conversations and GET /api/v1/studio/conversations/context) return editable: true for the conversations you can save over. When you continue a conversation started by someone else, Studio saves your messages as a copy under a new conv_id and leaves the original unchanged.
Saving over an existing conversation also requires read access to its linked source. A save without source_id keeps the stored link, and a save with another source replaces it only if you can read both.
Chat Request Messages
During chat, messages are passed in the request. Only the questions and answers are sent back to the LLM, not the executed queries:
{
"message": "Current user message",
"messages_history": [
{ "role": "user", "content": "First message" },
{ "role": "assistant", "content": "First response" },
{ "role": "user", "content": "Follow-up question" },
{ "role": "assistant", "content": "Follow-up answer" }
]
}
Retrieving Conversations
Via Platform Interface
- Open Studio in the Platform sidebar
- In the context panel, select a Source or Issue
- Related conversations appear in the history section
- Click on a conversation to load its messages
- Continue the conversation or start fresh. Continuing a conversation started by someone else creates your own copy; theirs stays as it was
Via API
Get Contextual Conversations
Retrieve conversations based on current context (source, issue, project):
Endpoint: GET /api/v1/studio/conversations/context
Query Parameters:
source_id: Get conversations from issues linked to this sourceissue_id: Get conversations from this specific issueproject_id: Get all project conversations
Example:
curl -H "Authorization: Bearer YOUR_TOKEN" \
"https://your-platform/api/v1/studio/conversations/context?source_id=456&project_id=1"
Response:
{
"source_conversations": [
{
"id": 5,
"conv_id": "conv_20241020_143022",
"filename": "conv_20241020_143022.jsonl",
"project_id": 1,
"project_name": "E-Commerce",
"issue_id": 123,
"issue_title": "High null rate in email",
"source_id": 456,
"source_name": "customers",
"line_count": 24,
"created_at": "2024-10-20T14:30:22Z",
"updated_at": "2024-10-20T15:45:00Z",
"editable": true
}
],
"issue_conversations": [],
"project_conversations": [
{
"id": 8,
"conv_id": "investigation_orders",
"filename": "investigation_orders.jsonl",
"project_id": 1,
"project_name": "E-Commerce",
"issue_id": 125,
"issue_title": "Duplicate order IDs",
"source_id": 457,
"source_name": "orders",
"line_count": 36,
"created_at": "2024-10-19T09:30:00Z",
"updated_at": "2024-10-19T11:00:00Z",
"editable": false
}
],
"total_count": 2
}
Conversation Grouping
Conversations are grouped by context:
| Group | Description |
|---|---|
source_conversations | From issues linked to the selected source |
issue_conversations | Directly linked to the selected issue |
project_conversations | From all sources/issues in the project |
This enables users to see related conversations when working on similar topics.
Conversation Linking
Conversations in Studio are linked to Platform entities for organization and retrieval.
Entity Linking
| Link | Purpose |
|---|---|
issue_id | Associate with a quality issue |
source_id | Associate with a data source |
project_id | Associate with a project |
Automatic Linking
When chatting with context, conversations are automatically linked:
{
"message": "Analyze this issue",
"context": {
"issue_id": 123,
"source_id": 456,
"project_id": 1
}
}
The resulting conversation will be linked to:
- Issue #123
- Source #456
- Project #1
Conversation Discovery
Users can discover related conversations:
- From an Issue: See all conversations about this issue
- From a Source: See conversations from all issues on this source
- From a Project: See conversations across all project sources
History Continuity
When reopening a context (issue/source), the frontend can:
- Query contextual conversations
- Load previous messages as history
- Continue the conversation with full context
# Load history for context
convs = requests.get(
f"{BASE_URL}/studio/conversations/context",
headers=headers,
params={"issue_id": 123}
).json()
# Use in next chat request
if convs["issue_conversations"]:
prev_conv = convs["issue_conversations"][0]
# Load messages from this conversation
# Pass as messages_history in chat request
Conversation Metadata
Each conversation tracks:
| Metadata | Description |
|---|---|
conv_id | Unique identifier |
filename | File <conv_id>.jsonl |
line_count | Number of messages |
created_at | First message timestamp |
updated_at | Last message timestamp |
This metadata helps users identify relevant conversations without loading full content.
Working with Conversations
Passing Message History
When continuing a conversation, pass previous messages:
import requests
headers = {"Authorization": "Bearer YOUR_TOKEN"}
# First message
response1 = requests.post(
f"{BASE_URL}/studio/chat",
headers=headers,
json={
"message": "What quality issues does this source have?",
"context": {"source_id": 456},
"conversation_id": "investigation_001"
}
).json()
# Follow-up with history
response2 = requests.post(
f"{BASE_URL}/studio/chat",
headers=headers,
json={
"message": "Which one should I fix first?",
"context": {"source_id": 456},
"conversation_id": "investigation_001",
"messages_history": [
{"role": "user", "content": "What quality issues does this source have?"},
{"role": "assistant", "content": response1["response"]}
]
}
).json()
Context Continuity
The agent maintains context through:
- Message History: Previous messages passed in request
- Analysis State:
analysis_completed,analysis_resulttracked - Scripts State:
scripts_generatedfor codification workflows - Enriched Context: Issue details, source schema, metrics
Session Management
For long conversations, the frontend typically:
- Stores messages locally during the session
- Passes relevant history to each request
- Saves conversation metadata to Platform on completion
Privacy and Security
Data in Conversations
Conversations may include:
- User prompts about data issues
- Agent responses with analysis
- The queries the agent ran and their results (data samples included)
- Schema information
- Quality metrics
Security Considerations
- Access Control: Conversations filtered by
partner_id; reading or overwriting one also requires read access to the sources its results come from (see Access to a Stored Conversation), and only its author or an admin can overwrite it (see Saving a Conversation) - LLM Privacy: Choose providers aligned with data policies
- Local Option: Use Ollama for sensitive data
- No PII in Prompts: Avoid including personal data in messages
Sensitive Data
When including data samples in context:
- Mask or exclude PII columns
- Use aggregates instead of raw values
- Consider synthetic data for examples
Best Practices
-
Context Selection:
- Always select a source or issue for context
- Include relevant enriched data (schema, metrics)
- Use data samples sparingly
-
Conversation Structure:
- One conversation per investigation topic
- Start with clear objectives
- Use follow-up questions to drill down
-
History Management:
- Keep relevant history, trim irrelevant parts
- For long conversations, summarize early messages
- Clear history when changing topics
-
Organization:
- Link conversations to issues for traceability
- Use meaningful conversation IDs
- Review related conversations before starting new ones
Next Steps
- 🔧 Platform Integration - Deep dive into Platform integration
- 📖 Configuration - Configure your LLM providers
- 🚀 Features - Explore all Studio capabilities