Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .changeset/39221-no-ask-without-grouping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@objectstack/service-analytics': patch
'@objectstack/mcp': patch
'@objectstack/spec': patch
---

fix(analytics): `list_datasets` no longer asks about a measure whose dataset cannot give the grouping the question asks for

Clause-②: no
Metadata-protocol: none

When a word sent to `list_datasets` has a measure among its candidates, `nextStep.note` now carries one more sentence before the question about that word (ADR-0149 D3, the grouping note of 2026-12-03). The sentence lists, by label, the dimensions the datasets of those measures can be grouped by. It says that when the question asks for a breakdown or a ranking and no one of those datasets carries everything the question is split or ranked by, the word is not asked about: the object query tools (`query_records`, `aggregate_records`) answer, the answer says no governed metric was used, and each measure offered is mentioned as a declared metric that cannot be split that way. Asked "bookings by product category" beside a `Booked amount` measure whose dataset groups by order status only, an assistant now answers from the records with that label, where before this release it asked the user whether `Booked amount` was the number meant.

- Nothing is selected and no key changes: `nextStep.decision`, `nextStep.terms`, `candidates` and `matches` are what they were. Only the text of `nextStep.note` changes, and only for a word with a measure among its candidates (`candidates_only`, and a word left out beside a matched measure).
- Whether the question groups by something the listed dimensions carry is the client's to judge. A question with no grouping, a grouping a listed dimension carries, and a grouping the client cannot place are still asked about as before.
- A date dimension is marked as one beside its label, with the calendar grains it can be grouped by (day, week, month, quarter, year), so "by month" beside it is a grouping the dataset carries.
- A question that groups by several things is read whole: one dataset must carry all of them.
- The sentence names only dimensions and datasets the answer lists for the caller. On a `partial: true` answer it is not written, and the word is asked about as before.
- The sentence is written in English, Simplified Chinese, Traditional Chinese and Japanese, like the rest of the note.

The `list_datasets` description and the MCP `initialize` selection rule carry the rule in one shared sentence, and the descriptions of `candidates` and `nextStep.note` in `@objectstack/spec` say it. The `tools/list` payload grows from 38,940 to 39,291 bytes.
31 changes: 25 additions & 6 deletions content/docs/ai/connect-mcp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,31 @@ first by calling `list_datasets` with the question's business words; a word
matches only when it equals a name, label or synonym; each word with exactly one
measure match is answered with `query_dataset`, and two such words are two
metrics computed both; several matches are a question for the user; a word with
no match but with `candidates` in the answer (members offered as possible
readings) is the same question, listing each candidate's label, dataset label
and description, and is never treated as a match; no match and no candidates
falls back to `query_records` / `aggregate_records`, saying the answer is not
from a governed metric. A token without `data:read` gets neither tool and no
such sentence.
no match but with a measure among its `candidates` in the answer (members
offered as possible readings) is the same question, listing each candidate's
label, dataset label and description, and is never treated as a match; no match
and no candidates falls back to `query_records` / `aggregate_records`, saying
the answer is not from a governed metric. A token without `data:read` gets
neither tool and no such sentence.

The instructions scope that question about a candidate four ways:

- Only the user's own word is asked about. A word the client cut out of a
longer phrase, or reworded, is sent to `list_datasets` once more as the user
wrote it.
- A word with a measure among its candidates is not asked about when the
question breaks the number down or ranks it and no one of those candidates'
datasets carries everything it is split or ranked by. The object query tools
answer it, labelled as not from a governed metric, and the candidate is
mentioned as a declared metric that cannot be split that way.
- A word whose candidates are all dimensions is at most a possible grouping.
It is never asked about, and it never stops a matched measure.
- A word that names the field a filtered candidate measure aggregates is
answered from that field through the object query tools, labelled the same
way, and the measure is mentioned as a narrower declared metric.

The `list_datasets` answer states which case the words are in as `nextStep`,
and the instructions say to follow its `note`.

The instructions also name the published skills package and the version to
install, which is the server's own version
Expand Down
6 changes: 3 additions & 3 deletions content/docs/references/ai/dataset-tools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const result = DatasetNextStepSchema.parse(data);
| :--- | :--- | :--- | :--- |
| **decision** | `Enum<'one_measure' \| 'several_measures' \| 'candidates_only' \| 'no_measure'>` | ✅ | Which case of the ADR-0149 D3 selection rule each term in `terms` is in, computed by the platform from this answer's `matches` and `candidates`. `one_measure`: the term equals exactly one measure. `several_measures`: it equals more than one measure, in one dataset or in several. `candidates_only`: it matched no member and has entries in `candidates`. `no_measure`: it equals no measure and has no entry in `candidates`. A dimension the term equals is not counted |
| **terms** | `string[]` | ✅ | The caller's terms the decision is about, each as sent in the tool's `terms` input. This is the reference to the members the decision rests on, which `nextStep` does not list: they are the entries carrying one of these terms in the same answer, in a dataset's `matches` (those whose `member` is a measure) for `one_measure` and `several_measures`, and in `candidates` for `candidates_only`. `no_measure` rests on no member |
| **note** | `string` | ✅ | The decision in words: finished text in the caller's locale, composed by the tool from this answer and never typed by the model. Besides this answer's members it may name, for a term, the field that term names which a filtered measure listed here aggregates and which answers it (ADR-0149 D3, the note of 2026-12-01). The wording is the executor's; the schema declares the slot and fixes no text (ADR-0149 M1) |
| **note** | `string` | ✅ | The decision in words: finished text in the caller's locale, composed by the tool from this answer and never typed by the model. Besides this answer's members it may name, for a term, the field that term names which a filtered measure listed here aggregates and which answers it (ADR-0149 D3, the note of 2026-12-01). On a complete answer, before the question it writes about a term with a measure among its candidates, it names the dimensions of those measures' datasets, each a dimension this answer lists; on a `partial: true` answer it names none (ADR-0149 D3, the grouping note of 2026-12-03). The wording is the executor's; the schema declares the slot and fixes no text (ADR-0149 M1) |


---
Expand Down Expand Up @@ -256,7 +256,7 @@ const result = DatasetNextStepSchema.parse(data);
| **datasets** | `{ name: string; label: string; description?: string; object: string; … }[]` | ✅ | The datasets this caller may query. A dataset the caller may not query is absent, the same answer as one that does not exist |
| **partial** | `true` | optional | Present, and `true`, when the dataset read was degraded and `datasets` may be incomplete; `warning` says why. Absent on a complete answer |
| **warning** | `string` | optional | Why the answer is partial; present exactly when `partial` is |
| **candidates** | `{ term: string; dataset: string; member: string }[]` | optional | Members offered as possible readings of a term that matched no member of any listed dataset: for a clarifying question when a measure is among the term's candidates. A term whose candidates are all dimensions is offered them as a possible grouping, not for a question, and does not stop a matched measure. A measure that carries a filter and whose aggregated field the term names (the term equals, or is inside, that field's label or name) is not offered for that term: the field answers it, labelled as not from a governed metric, and `nextStep.note` names the field and mentions the measure as a narrower declared metric; its dataset's entry still lists it. Such a measure is still offered when the term names different fields through different candidates, and a measure with no filter is offered as before; with another measure candidate left for the term, that one is asked about first and the field answers only if the question settles nothing. A candidate is not a match: its term has no entry in any dataset's `matches`. The platform selects none: the list carries no score, and its order is the listing order stated here, not a ranking. Every candidate is a member this caller may read, listed in `datasets`. Terms in the order sent; for one term, datasets in the order listed, and each dataset's measures before its dimensions, as its entry lists them; at most 5 per term, the first in that order. Present only when `terms` were sent and a term that matched nothing has a candidate; absent otherwise, never an empty list. A term with a match has no candidate |
| **candidates** | `{ term: string; dataset: string; member: string }[]` | optional | Members offered as possible readings of a term that matched no member of any listed dataset: for a clarifying question when a measure is among the term's candidates. A term whose candidates are all dimensions is offered them as a possible grouping, not for a question, and does not stop a matched measure. A measure that carries a filter and whose aggregated field the term names (the term equals, or is inside, that field's label or name) is not offered for that term: the field answers it, labelled as not from a governed metric, and `nextStep.note` names the field and mentions the measure as a narrower declared metric; its dataset's entry still lists it. Such a measure is still offered when the term names different fields through different candidates, and a measure with no filter is offered as before; with another measure candidate left for the term, that one is asked about first and the field answers only if the question settles nothing. A term with a measure among its candidates is owed no question when the question breaks the number down or ranks it and no one of those measures' datasets carries all it is split or ranked by: the records answer it, labelled as not from a governed metric, each such measure is mentioned as a declared metric that cannot be split that way, and the term's candidates are listed as before. On a `partial: true` answer the term is asked about as before. A candidate is not a match: its term has no entry in any dataset's `matches`. The platform selects none: the list carries no score, and its order is the listing order stated here, not a ranking. Every candidate is a member this caller may read, listed in `datasets`. Terms in the order sent; for one term, datasets in the order listed, and each dataset's measures before its dimensions, as its entry lists them; at most 5 per term, the first in that order. Present only when `terms` were sent and a term that matched nothing has a candidate; absent otherwise, never an empty list. A term with a match has no candidate |
| **nextStep** | `{ decision: Enum<'one_measure' \| 'several_measures' \| 'candidates_only' \| 'no_measure'>; terms: string[]; note: string }` | optional | Which case of the ADR-0149 D3 selection rule the caller's `terms` are in, as the platform computed it from this answer's own `matches` and `candidates`: the case, the terms it is about and the case in words. It adds no match and no candidate and lists no member: the members it rests on are read from `matches` and `candidates` under its `terms`. Present only when `terms` were sent |

### Nested Shape: `ListDatasetsOutput.datasets[number]`
Expand Down Expand Up @@ -286,7 +286,7 @@ const result = DatasetNextStepSchema.parse(data);
| :--- | :--- | :--- | :--- |
| **decision** | `Enum<'one_measure' \| 'several_measures' \| 'candidates_only' \| 'no_measure'>` | ✅ | Which case of the ADR-0149 D3 selection rule each term in `terms` is in, computed by the platform from this answer's `matches` and `candidates`. `one_measure`: the term equals exactly one measure. `several_measures`: it equals more than one measure, in one dataset or in several. `candidates_only`: it matched no member and has entries in `candidates`. `no_measure`: it equals no measure and has no entry in `candidates`. A dimension the term equals is not counted |
| **terms** | `string[]` | ✅ | The caller's terms the decision is about, each as sent in the tool's `terms` input. This is the reference to the members the decision rests on, which `nextStep` does not list: they are the entries carrying one of these terms in the same answer, in a dataset's `matches` (those whose `member` is a measure) for `one_measure` and `several_measures`, and in `candidates` for `candidates_only`. `no_measure` rests on no member |
| **note** | `string` | ✅ | The decision in words: finished text in the caller's locale, composed by the tool from this answer and never typed by the model. Besides this answer's members it may name, for a term, the field that term names which a filtered measure listed here aggregates and which answers it (ADR-0149 D3, the note of 2026-12-01). The wording is the executor's; the schema declares the slot and fixes no text (ADR-0149 M1) |
| **note** | `string` | ✅ | The decision in words: finished text in the caller's locale, composed by the tool from this answer and never typed by the model. Besides this answer's members it may name, for a term, the field that term names which a filtered measure listed here aggregates and which answers it (ADR-0149 D3, the note of 2026-12-01). On a complete answer, before the question it writes about a term with a measure among its candidates, it names the dimensions of those measures' datasets, each a dimension this answer lists; on a `partial: true` answer it names none (ADR-0149 D3, the grouping note of 2026-12-03). The wording is the executor's; the schema declares the slot and fixes no text (ADR-0149 M1) |


---
Expand Down
25 changes: 25 additions & 0 deletions packages/mcp/src/initialize-selection-rule-34686.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,28 @@ describe('[#35778] initialize instructions — the default text points at the se
}
});
});

/**
* [ADR-0149 D3, the grouping note of 2026-12-03] A word with a measure among
* its candidates is not asked about when no dimension of those candidates'
* datasets carries the grouping the question asks for: both doors say it in
* the same words, after the question it conditions.
*/
describe('[ADR-0149 D3 grouping note] initialize instructions — a grouping no candidate\'s dataset carries, in the same words as list_datasets', () => {
const GROUPING_TERM =
'A word with a measure among its candidates is not asked about when the question breaks the number down or '
+ 'ranks it and no one of those candidates\' datasets carries all it is split or ranked by: the object query tools answer it, '
+ 'labelled as not from a governed metric, and the candidate is mentioned as a declared metric that cannot be '
+ 'split that way.';

it('both doors carry the sentence, after the question and the own-word sentence', async () => {
const runtime = new MCPServerRuntime({ name: 't', version: '1.0.0' });
const text = await instructionsOf(runtime, makeBridge());
const list = getDatasetToolDefinitions().find((d) => d.name === LIST_DATASETS_TOOL_NAME)!;
for (const door of [text, list.description]) {
const at = door.indexOf(GROUPING_TERM);
expect(at).toBeGreaterThan(door.indexOf('Only the user\'s own word is asked about'));
expect(door.indexOf('A word whose candidates are all dimensions is at most a possible grouping')).toBeGreaterThan(at);
}
});
});
10 changes: 9 additions & 1 deletion packages/mcp/src/mcp-server-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,11 @@ const AUTHORING_CONTRACT_LINE: string | undefined = (() => {
* same words as `list_datasets`' description; [ADR-0149 D3, note of
* 2026-12-01] a word that names the field a filtered measure candidate
* aggregates is answered from that field, labelled, the measure mentioned as a
* narrower declared metric, again in `list_datasets`' own words;
* narrower declared metric, again in `list_datasets`' own words; [ADR-0149
* D3, the grouping note of 2026-12-03] a word with a measure among its
* candidates is not asked about when no one of the datasets of those
* measures carries everything the question groups by: the object tools
* answer it, labelled, and each such measure is mentioned, in the same words too;
* only a word with no match and no candidate falls back to the object tools,
* with the answer labelled. [#34919] The answer itself then states the
* case (`list_datasets` `nextStep`, composed by the service-analytics
Expand All @@ -1914,6 +1918,10 @@ const DATASET_SELECTION_RULE =
+ 'way, listing each candidate\'s label, dataset label and description; do not pick one or treat it as a match. '
+ 'Only the user\'s own word is asked about: one you cut out of a longer phrase of the question, or reworded, '
+ 'is sent to list_datasets once more as the user wrote it instead, never the whole question. '
+ 'A word with a measure among its candidates is not asked about when the question breaks the number down or '
+ 'ranks it and no one of those candidates\' datasets carries all it is split or ranked by: the object query tools answer it, '
+ 'labelled as not from a governed metric, and the candidate is mentioned as a declared metric that cannot be '
+ 'split that way. '
+ 'A word whose candidates are all dimensions is at most a possible grouping: never ask about it, and it never '
+ 'stops a matched measure. '
+ 'A word that names the field a filtered candidate measure aggregates (it equals or is inside that field\'s '
Expand Down
10 changes: 6 additions & 4 deletions packages/mcp/src/tools-list-weight-34689.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ async function measureToolsList(): Promise<{ total: number; rows: ToolRow[] }> {

/**
* The slimmed total (36,481 bytes, from 47,712), raised to 39,000 when
* `get_current_user` joined the surface (38,569 bytes measured). It leaves no
* room for another tool: a PR that needs more raises it beside its own
* before/after table.
* `get_current_user` joined the surface (38,569 bytes measured), and to 39,300
* when `list_datasets`' description gained the sentence of ADR-0149 D3's
* grouping note of 2026-12-03 (38,940 bytes before it, 39,291 with it). It
* leaves no room for another tool: a PR that needs more raises it beside its
* own before/after table.
*/
const TOOLS_LIST_BYTE_CEILING = 39_000;
const TOOLS_LIST_BYTE_CEILING = 39_300;

describe('[#34689] the open door tools/list weight', () => {
it('prints the per-tool table and stays under the ceiling', async () => {
Expand Down
Loading
Loading