Skip to main content

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:

ColumnTypeDescription
idintPrimary key
conv_idstrUnique conversation identifier
filenamestrStored as <conv_id>.jsonl
partner_idintOrganization FK
issue_idintLinked issue (optional)
source_idintLinked source (optional)
project_idintLinked project (optional)
line_countintNumber of messages
created_atdatetimeCreation timestamp
updated_atdatetimeLast 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"}
FieldLinesDescription
rolealluser, assistant, tool_call or tool_result
textallMessage text; for a tool_result, the result or the error (Error: ...)
tsallWhen the message appeared
tool_nametool linesName of the tool, such as execute_sql_query or count_rows
tool_argstool_callArguments of the call; sql holds the statement of execute_sql_query
tool_idtool linesPairs a result with its call, even when the same tool runs several times
tool_oktool_resultfalse when the tool failed
tool_truncated_fromtool_resultOriginal 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_id of the tool_call lines). 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​

  1. Open Studio in the Platform sidebar
  2. In the context panel, select a Source or Issue
  3. Related conversations appear in the history section
  4. Click on a conversation to load its messages
  5. 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 source
  • issue_id: Get conversations from this specific issue
  • project_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:

GroupDescription
source_conversationsFrom issues linked to the selected source
issue_conversationsDirectly linked to the selected issue
project_conversationsFrom 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​

LinkPurpose
issue_idAssociate with a quality issue
source_idAssociate with a data source
project_idAssociate 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:

  1. From an Issue: See all conversations about this issue
  2. From a Source: See conversations from all issues on this source
  3. From a Project: See conversations across all project sources

History Continuity​

When reopening a context (issue/source), the frontend can:

  1. Query contextual conversations
  2. Load previous messages as history
  3. 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:

MetadataDescription
conv_idUnique identifier
filenameFile <conv_id>.jsonl
line_countNumber of messages
created_atFirst message timestamp
updated_atLast 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:

  1. Message History: Previous messages passed in request
  2. Analysis State: analysis_completed, analysis_result tracked
  3. Scripts State: scripts_generated for codification workflows
  4. Enriched Context: Issue details, source schema, metrics

Session Management​

For long conversations, the frontend typically:

  1. Stores messages locally during the session
  2. Passes relevant history to each request
  3. 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​

  1. 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)
  2. LLM Privacy: Choose providers aligned with data policies
  3. Local Option: Use Ollama for sensitive data
  4. 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​

  1. Context Selection:

    • Always select a source or issue for context
    • Include relevant enriched data (schema, metrics)
    • Use data samples sparingly
  2. Conversation Structure:

    • One conversation per investigation topic
    • Start with clear objectives
    • Use follow-up questions to drill down
  3. History Management:

    • Keep relevant history, trim irrelevant parts
    • For long conversations, summarize early messages
    • Clear history when changing topics
  4. Organization:

    • Link conversations to issues for traceability
    • Use meaningful conversation IDs
    • Review related conversations before starting new ones

Next Steps​