Query shapes
What this covers
A query shape describes how the agent answers one type of question: which fields the planner should choose, which chart is used, which quality checks run, and how the answer is narrated. The built-in shapes cover totals, breakdowns, rankings, compositions, trends, matrices, and detail tables. This page explains how to choose built-in shapes or customise them for a project.
For an example question of each kind, see the section "Kinds of questions, with examples" in Agent Chat.
Where to find it
Tenant Administration, Projects, your project, Project settings, Conversational agent, Query shapes.
How it works
- Use built-in defaults leaves the project on the platform shapes. After Save, the stored document is empty and the agent uses the current built-in set.
- Customise for this project copies the built-in set into this project so you can edit it. Changes take effect only after Save on the Conversational agent settings.
- Pick a query shape from the list. Catalogue coverage rows and guard entries stay in the document but are not shown here; they continue to apply at runtime.
- More settings shows when the shape matches (field counts of dates, categories and measures) and lets you change those rules. Matching uses result field counts, not specific model columns and not the wording of the question. “Not restricted” is different from zero.
- Show the answer as sets the chart. Existing quality safeguards stay on. When a chart cannot be shown, the agent uses a table.
- When the result looks different changes the presentation after the query has run, without changing which shape was selected, its instructions, or its narration:
- If the result is a single row: show KPI cards or a table. The cards print the dimension members above the values, for example "City: London" above "Amount 5,000" for "in which city did the highest transaction occur".
- If the values are percentages that add up to 100%: show a pie chart or a table. This applies only to a result with one category, one measure, no date field, at least two rows, no negative values, and a total of 100 (or 1.0 when shares are stored as fractions). A pie that fails the pie safeguards (for example too many segments) is dropped and the shape's own chart is used.
- Keep the choice above removes the rule.
- A project with charts switched off, or a presentation already chosen for this turn, always wins over a result rule.
- The built-in "One measure by category" shape ships with both rules; the built-in ranking shape ships with the single-row rule. A project that was customised before this feature keeps its saved document unchanged; add the rules in the form if you want them.
- Planning instructions tell the agent which fields to choose. Optional answer instructions guide the narration for that shape.
- + Add clones the current shape into the same family with a new id (lowercase letter, then letters, numbers, underscores or hyphens). Give the copy different matching conditions so the agent can select it.
- Remove deletes the selected editable shape from this project draft. Keep at least one editable shape. Guards and catalogue rows cannot be removed from this screen.
- Review with AI checks that the document can be executed, then asks the project's answer model to review the instructions. Advice never blocks saving; a document that fails the executable check cannot be saved.
- Save on the Conversational agent settings applies the document. The agent uses it from the next question.
- The JSON document is not the editor. Use Show JSON only if you need to inspect the stored registry.
Rules
- The guard family always applies to a result with no measure values, even if you list another family first in
family_order. You can still reorder the other families to change which presentation shape wins. - The guard entry
unsupported_no_valuesmust stay in the document. - Entry ids must be unique.
- In the JSON, result rules are the optional entry key
result_rules: a list of{"when": ..., "chart": ...}with at most one rule per condition. Conditions:single_row(chartkpiortable) andpercent_of_whole(chartpieortable). Guard and catalogue entries cannot carry result rules. - Supported charts: kpi, bar, h_bar, line, multi_line, multi_line_wide, pie, grouped_bar, stacked_bar. Leave
chartout ofrenderer_bindingfor a table. - Fields with no runtime consumer are fixed:
shape,required_constraints,narration_fact_contract,insight_fact_contract, andfallbackon built-in entries; new entries always fall back to a table. Quality check names must be implemented ones: category_limit, pie_suitable, time_series, multi_series, matrix_size, table_size, additive_values. A pie entry must keep pie_suitable, a line entry time_series, a multi-line entry multi_series, a bar entry category_limit, a matrix entry matrix_size, a detail entry table_size. - A change to the platform's protected registry surface (guard entries and the pinned fields on built-in entries) is a migration event. A saved project document that no longer matches will refuse every question until a modeller saves an updated document. The Query shapes tab warns when the saved document is invalid.
- A new entry is selected by its match rule only: the counts of date, category and measure columns. The description and the planner instructions are not used to choose between entries. Two entries with the same match rule and shape are ordered by
family_orderand then by position in the family; the first is the default. The narrator then chooses among the shapes that match those counts.
Question templates
Question templates teach the agent to recognise more kinds of questions and how to answer them. Each template has:
- Question type and example questions: how the agent recognises it.
- Parts of the question: what the planner fills in (for example measure, period, category).
- Answered by: a governed query, a KPI evaluation, or the model's own definition of a term.
- How to answer (planner): which fields, filters, sort order or governed expressions to use. Every number is computed by the query router, never by the AI; a share or a change can be a governed expression even when the model has no measure for it.
- How to present the answer (narrator): what the answer states first and how to describe the returned rows.
The built-in set covers totals, snapshots, latest entity, rankings, breakdowns, trends, period comparisons, targets, shares, exception lists, entity details, contributions, distributions, matrices, funnels, retention, forecasts and definitions, plus thresholds ("which merchants sold more than 50,000"), ratios such as average order value, distinct counts, comparisons of named members, change per group between two periods, change in share, day-of-week and month-of-year patterns, first and last dates, data coverage, actual versus plan, and averages per day, week or month.
Analytic templates use statistics and window calculations that the query router computes: running totals, moving averages, rank positions, top N within each group, 80/20 concentration, outliers (values far from the average, measured in standard deviations), quartiles and deciles, averages of period or entity totals (a typical month, sales per customer), and cohorts by first purchase date. Planner instructions may use these building blocks: stddev, variance, median, percentile, rank, dense_rank, row_number, ntile, running_sum, moving_avg, a result_filter on a calculated column, and an outer level that aggregates the query's own results.
To change or add templates, choose a custom registry, edit the Question templates section and save. A template never blocks a question: without a matching template the agent answers as before. For a definition template the agent relays the model's definition word for word instead of writing its own.
Shapes and templates on a model with several fact groups
A model can hold several lines of figures (fact groups), for example payments and targets. A shape or a question template works on such a model as on any other, with three rules that come from the query router. They apply when the figures of one answer come from different fact groups. Inside one fact group nothing below is restricted.
What a calculation may contain. The query router makes the calculation itself, after it has answered each fact group and lined the results up.
| In a template's governed expression | Across fact groups |
|---|---|
Arithmetic: + - * / |
Answered |
ROUND, ABS, CEIL, FLOOR, COALESCE on numbers |
Answered |
A threshold on the calculation (result above 95) |
Answered |
Text, date and logical functions (CONCAT, EXTRACT, CASE) |
Declined |
Statistics and windows: stddev, median, percentile, rank, running_sum, moving_avg, ratio_to_total, an outer level |
Declined |
A percentage of one figure over another is written as 100 * a / b. Rounding
is not part of a percentage: put ROUND(..., 2) in the template when the
answer should be rounded. The built-in share template rounds a share of a
total to two decimals.
What happens when a calculation is declined. The agent never calculates a figure itself. If the declined calculation was only a column to show, the agent returns the figures it is made of, each with the aggregation the calculation used, under a notice that the calculation was not made, followed by the query router's reason. If the calculation decides which rows are shown or their order (a rank, a top N, a threshold), nothing is returned in its place and the router's reason is the answer.
Which fields a template may group and filter by. Across fact groups a field has to be one that every fact group in the answer reaches: a shared table such as a calendar, or a conformed dimension the modeller declared. A period is a field like any other: "by month" or "in 2025" needs a year and month that all the fact groups reach, not the date field of one of them. When the planner picks a field that only some of the fact groups reach, it is asked once for a plan on the shared fields before the query is sent. A field the user named is always sent as asked. A question the model cannot answer by the asked field is refused with one fixed sentence, which the agent shows unchanged: "The measures [list] are not available by the dimensions [list] in model [name]."
Good practice.
- In planner instructions, name the kind of field ("the year and month of the shared calendar"), not one fact group's date field.
- Keep analytic templates (rankings within a group, running totals, outliers) for questions about one fact group. For a comparison between fact groups use arithmetic, or ask the modeller for a composite measure.
- When a comparison between fact groups is asked often, a composite measure gives it one agreed definition and works in every template.
See Questions Across Fact Groups.
Seeing which shape was used
The chat trace drawer shows "Shape: <id>" next to the route. The agent log screen shows "Selected shape" for every turn.