Handling answers¶
ask, answer_approval and get_answer all return an answer. This page covers what's in it, and what your
app does with each status. The code here uses the call and ask helpers from the
Quickstart.
The answer, twice¶
Each result carries the same answer in two forms. Use whichever suits your app:
structuredContent: the answer as data (below). Best when your own code draws the screen.content: the answer as readable Markdown (Klaris's words, anything waiting for the person, and each table written out, first 20 rows), plus aresource_linkfor each file. Best when a model reads the result and writes the reply, as Claude and ChatGPT do.
| Field | What it holds |
|---|---|
conversation_id |
The chat (conv_…). Pass it to ask for a follow-up. |
status |
What to do next: see Statuses. |
answer |
Klaris's words, in Markdown. |
outputs |
Tables, charts, single figures and files Klaris made: see Outputs. |
question |
When status is needs_answer: what Klaris needs to know. |
approvals |
When status is needs_approval: what is waiting for the person's yes. |
steps |
What Klaris did, in plain words ("Look up renewals"). |
The full field list is in the MCP reference.
Statuses¶
status |
What to do |
|---|---|
answered |
Show answer and outputs. |
working |
Not ready yet. Call get_answer with the conversation_id. |
needs_answer |
Show question to the person, and send their reply with ask in the same chat. |
needs_approval |
Show each of approvals and call answer_approval with the person's own decision. |
failed |
Something went wrong; answer says what, in plain words. The person can ask again. |
stopped |
The answer was stopped before it finished. |
Ignore values you don't know: new ones may be added (see Changelog).
Answers that take longer¶
ask waits up to about 40 seconds. Most answers come well within that. One that needs several queries can
take longer: then ask returns status: "working" with the conversation_id. Call get_answer with it. It
waits up to about 40 seconds more and returns the answer, or working again.
- Every call returns within 50 seconds, so it fits a client that gives up at a minute.
- The answer carries on in Klaris whether you wait or not. If your call times out or your server restarts,
call
get_answerlater; nothing is lost. - If Klaris itself stops while working (a restart), that answer reads as
failedwithin about 2 minutes.
Progress¶
While Klaris works, it sends an MCP progress notification for each step ("Look up renewals", "Run a query on Warehouse"), if your call asks for progress. Show them to the person so a longer answer doesn't look stuck:
A question back¶
When Klaris needs to know something before it can answer ("which period?"), status is needs_answer and
question holds a lead line and up to three short questions, each with a few options:
{
"text": "A couple of things first:",
"questions": [
{
"id": "q1",
"header": "Measure",
"text": "What does \"doing best\" mean here?",
"multiple": false,
"options": [
{
"label": "Premium",
"description": "Annual premium sold"
},
{
"label": "Conversion"
}
]
},
{
"id": "q2",
"header": "Period",
"text": "What time period should I use?",
"multiple": false,
"options": [
{
"label": "This month"
},
{
"label": "This quarter"
}
]
}
]
}
Show the questions (the options make good buttons) and send the reply with ask in the same chat, one line
per question, by its header:
The person may also answer in their own words, or ask something else instead.
Approvals¶
Some things wait for the person's yes, depending on the workspace's rules: for example, running a query in a
workspace that asks before every query. Then status is needs_approval, and each of approvals holds:
{
"approval_id": "apr_51d0…",
"summary": "Run a query on Warehouse: renewals due this month by carrier",
"sql": "select carrier, count(*) from renewals where due_date < date '2026-12-01' group by carrier"
}
Show the summary (and the sql, for people who read it), ask the person, then pass their decision:
answer = (await call(person, "answer_approval", {
"conversation_id": answer["conversation_id"],
"approval_id": approval["approval_id"],
"approve": True, # or False, with an optional "reason"
})).structured_content
Never decide for the person
Call answer_approval only with what the person chose. Not your code, and not your assistant's model.
If the person asks something new instead of answering, what was waiting is dropped and never runs. An approval that waits 7 days expires the same way.
Outputs¶
Each output has a kind, a title, and its data. New kinds and fields may be added later: ignore any you don't
know.
Tables¶
{
"kind": "table",
"title": "Orders by Region",
"data": {
"columns": [
{
"key": "region",
"label": "Region",
"type": "string"
},
{
"key": "orders",
"label": "Orders",
"type": "integer"
}
],
"rows": [
[
"Northeast",
2070
],
[
"Southeast",
1600
]
],
"row_count": 5,
"truncated": false,
"table_id": "tbl_9c2d…"
}
}
rowsholds up to 50 rows.row_countis how many there are in all.- Column
typeisstring,number,integer,date,datetime,boolean,percentorcurrency. Dates are ISO text. Acurrencycolumn hasunit(such as$). Apercentvalue is already a percentage: 12.5 means 12.5%. labelis the column's name in plain words; use it as the heading.
More rows: call get_table_rows with the table_id, an offset (50 for the rows after the answer's) and a
limit (up to 200). It reads Klaris's saved copy, so it doesn't run the query again. Each page says whether
there are more.
page = (await call(person, "get_table_rows", {"table_id": table_id, "offset": 50, "limit": 200})).structured_content
A table's rows are kept for 90 days after they were last read. After that, get_table_rows says they were
cleared; asking Klaris again gives a fresh result. For totals over a big table ("how many in all, by state?"), ask
Klaris in the same chat rather than adding up pages yourself.
Charts and single figures¶
A chart is data plus an encoding, not a picture, so you draw it in your own style:
{
"kind": "chart",
"title": "Orders by Month",
"data": {
"columns": [
{
"key": "month",
"label": "Month",
"type": "date"
},
{
"key": "orders",
"label": "Orders",
"type": "integer"
}
],
"rows": [
[
"2026-10-01",
612
],
[
"2026-11-01",
645
]
],
"row_count": 2,
"truncated": false
},
"encoding": {
"type": "line",
"x": "month",
"y": [
"orders"
]
}
}
encoding.type is bar, line, area, pie, donut, scatter, combo, heatmap, funnel or metric.
x, y, y2, series, value and compare name columns. A chart carries up to 2,000 points. A single figure
has kind: "metric".
Files¶
Asked for a spreadsheet, Klaris makes an Excel or CSV file. The answer carries it twice:
- in
outputs, askind: "file"withfile.filename,file.format(xlsxorcsv),file.media_type,file.size_bytesandfile.uri(klaris://files/file_…); - in
content, as aresource_linkwith the same address: MCP's own way to point at something the app may read.
To give it to the person, read it with resources/read and that address, using the same person's token, and
offer it as a download in your own app:
- Only the person whose chat made the file can read it, and only while that chat exists.
- Up to 20 MB over MCP. A bigger file is refused with words saying where the person can get it.
- If your app doesn't read files yet, nothing breaks: the figures are in the answer anyway, and the readable text tells your model what to say about the file.
Chats¶
- Klaris makes the
conversation_id, on the firstaskwithout one. Keep it with your own thread, and pass it for follow-ups. A chat belongs to one person: anyone else using its id gets "No such chat". - One question at a time per chat. Asking again while the last answer is still
workingreturns an error saying to callget_answerfirst, so a retry after a timeout never runs a question twice. Other chats, and other people, aren't held up. - Long chats are fine. As a chat grows, Klaris summarises its older part for itself and carries on. The person still sees every message.
list_conversations,get_conversationanddelete_conversationlet people find, reopen and delete their chats. Delete only when the person asks: it also removes the chat's tables and files.- Chats are kept in Klaris, not in the MCP session, so ids work across sessions, days and tokens.
Errors from a tool¶
A tool that can't do what was asked returns an error result (isError: true) with plain words you can show,
such as "Too many questions in a short time. Wait a minute, then ask again." See
Limits and errors.