diff --git a/.changeset/34868-ask-skill-reads-candidates.md b/.changeset/34868-ask-skill-reads-candidates.md new file mode 100644 index 00000000000..1c414a63e6f --- /dev/null +++ b/.changeset/34868-ask-skill-reads-candidates.md @@ -0,0 +1,21 @@ +--- +'@objectstack/skills': patch +'@objectstack/mcp': patch +--- + +docs(skills): the `objectstack-ask` skill reads `candidates` for a word that matched nothing + +Clause-②: no +Metadata-protocol: none + +`list_datasets` now answers a business word that matched nothing with `candidates`, the members the server offers as possible readings. The `objectstack-ask` skill, and the page at `GET /mcp/skill` that is generated from it, still told a client to judge near readings itself from the catalogue. They now read the server's list, in the same rule the `list_datasets` tool description and the `initialize` selection rule state. + +What a connected client now reads, where it differs from before: + +- Step 1 names `candidates`: a word that matched nothing may have them, each a `{ term, dataset, member }` pointer to a member the same answer lists. A candidate is not a match. +- A word with no match and one or more candidates is a question for the user. The client lists each candidate's label, its dataset's label and its description, picks none, treats none as a match and computes nothing until the user answers. +- One candidate is a question too: the client asks whether it is the one meant. This replaces the earlier wording, in which one near form selected nothing and went to the fallback. +- No match and no candidates for the word for a thing measured is the fallback to the object tools, with the answer saying no governed metric was used (非指标口径). +- The client's own loose-form check is removed: the two rows that had the client judge whether a word was a loose form of several listed measures, and the paragraph that defined a loose form. This supersedes the loose-form sentences in this release's earlier `objectstack-ask` and `GET /mcp/skill` entries. Against a server that returns no `candidates`, a word with no match goes to the labelled fallback, which still names a listed dataset on the same object. + +The skill's eval cases cover several candidates, one candidate, and no candidates. `packages/mcp/src/ask-skill.generated.ts` is regenerated from the skill; no code path changes. diff --git a/packages/mcp/src/ask-skill.generated.ts b/packages/mcp/src/ask-skill.generated.ts index 6ba5fb44d5e..b32193c2131 100644 --- a/packages/mcp/src/ask-skill.generated.ts +++ b/packages/mcp/src/ask-skill.generated.ts @@ -25,6 +25,9 @@ export const ASK_SKILL_DATA_LOOP: string = [ ' `term`, the `member` it names (`measures.` or `dimensions.`) and', ' `matchedOn`. A word matches only when it equals a member\'s name, label or', ' synonym (case, spacing, `_` and `-` aside), never by similarity.', + '- A word that matched nothing may have `candidates` on the answer: members', + ' offered as possible readings, each a `{ term, dataset, member }` pointer to a', + ' member the same answer lists. A candidate is not a match.', '- No `list_datasets` among your tools: this environment serves you no governed', ' metrics. Go to step 4.', '', @@ -35,17 +38,10 @@ export const ASK_SKILL_DATA_LOOP: string = [ '| Each word for a thing measured matches exactly one measure | Compute: step 3. Two words with one measure each ("营收和赢单率") are two metrics, not a choice: compute both, with one `query_dataset` per dataset. |', '| One word matches several measures, in one dataset or in two | Ask the user which one they mean. List each candidate\'s label, its dataset\'s label and its description. Do not pick one. |', '| Only a dimension matches | That is a grouping ("by stage"), not a number. You still need a measure match; without one, ask which number is meant. |', - '| Nothing matches, and the word is a loose form of several listed measures | Ask the user which one they mean, listing the same three things. Do not pick one, and compute nothing yet. |', - '| Nothing matches, and the listed measures do not offer several readings of the word | Step 4, and say in the answer that no governed metric was used. One near form is not a match either: it selects nothing. |', + '| A word matches nothing, and `candidates` lists members for it, one or several | Ask the user which one they mean, listing each candidate\'s label, its dataset\'s label and its description; with one candidate, ask whether it is the one meant. Do not pick one, and never treat a candidate as a match. Compute nothing yet. |', + '| No match and no candidates for the word for a thing measured | Step 4, and say in the answer that no governed metric was used. |', '| `membersWithheld: true` on a dataset | Say that it has members (measures or groupings) you may not read; the metric asked for may be among them. Do not say the metric does not exist. |', '', - 'The same answer lists every dataset you may query with all its measures,', - 'matched or not (a call without `terms` returns that catalogue too), so the', - 'loose-form check needs no second read. A loose form is a word a listed', - 'measure\'s name, label or description contains, directly or in translation:', - '"revenue" against Won Revenue, Annual Revenue and Planned Revenue; "金额"', - 'against several amounts.', - '', 'When you ask, the reply is the question alone: no figure, and no tool call', 'until the user answers. `partial: true` on the answer means the catalogue may', 'be incomplete; `warning` says why, and you repeat it when you fall back.', diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 726d77d9c9e..819a5a4b82f 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -1695,7 +1695,17 @@ export const CEILINGS = new Map([ // a match either. 5848 -> 6105 bytes (+257), less the 20-byte stamp line: // 5828 -> 6085 priced bytes, ceil(6085 / 4) = 1522 (+65). Still the new // file's own measurement, pinned AT it, zero headroom; no other row moves. - ['skills/objectstack-ask/SKILL.md', 1522], + // 1522 -> 1491, a LOWERING, re-measured on the PR that makes step 2 read the + // answer's `candidates` (ADR-0149 D3 amendment note): a word with no match + // and a candidate listed is a question for the user, a lone candidate + // included, and no match with no candidate is the labelled fallback. Cut: + // the two loose-form rows and the paragraph that defined a loose form over + // the catalogue, since the server's `candidates` replaces the client's own + // check. Added: one step 1 bullet naming `candidates`, and the two rows that + // read it. 6105 -> 5981 bytes (-124), less the 20-byte stamp line: + // ceil(($(wc -c < skills/objectstack-ask/SKILL.md) - 20) / 4) == ceil(5961 / 4) + // = 1491 (-31). Pinned AT the measurement, zero headroom; no other row moves. + ['skills/objectstack-ask/SKILL.md', 1491], ]); /** diff --git a/skills/objectstack-ask/SKILL.md b/skills/objectstack-ask/SKILL.md index 482410fbd63..cd76aade638 100644 --- a/skills/objectstack-ask/SKILL.md +++ b/skills/objectstack-ask/SKILL.md @@ -38,6 +38,9 @@ wrote its business definition) outranks a number you work out yourself. `term`, the `member` it names (`measures.` or `dimensions.`) and `matchedOn`. A word matches only when it equals a member's name, label or synonym (case, spacing, `_` and `-` aside), never by similarity. +- A word that matched nothing may have `candidates` on the answer: members + offered as possible readings, each a `{ term, dataset, member }` pointer to a + member the same answer lists. A candidate is not a match. - No `list_datasets` among your tools: this environment serves you no governed metrics. Go to step 4. @@ -48,17 +51,10 @@ wrote its business definition) outranks a number you work out yourself. | Each word for a thing measured matches exactly one measure | Compute: step 3. Two words with one measure each ("营收和赢单率") are two metrics, not a choice: compute both, with one `query_dataset` per dataset. | | One word matches several measures, in one dataset or in two | Ask the user which one they mean. List each candidate's label, its dataset's label and its description. Do not pick one. | | Only a dimension matches | That is a grouping ("by stage"), not a number. You still need a measure match; without one, ask which number is meant. | -| Nothing matches, and the word is a loose form of several listed measures | Ask the user which one they mean, listing the same three things. Do not pick one, and compute nothing yet. | -| Nothing matches, and the listed measures do not offer several readings of the word | Step 4, and say in the answer that no governed metric was used. One near form is not a match either: it selects nothing. | +| A word matches nothing, and `candidates` lists members for it, one or several | Ask the user which one they mean, listing each candidate's label, its dataset's label and its description; with one candidate, ask whether it is the one meant. Do not pick one, and never treat a candidate as a match. Compute nothing yet. | +| No match and no candidates for the word for a thing measured | Step 4, and say in the answer that no governed metric was used. | | `membersWithheld: true` on a dataset | Say that it has members (measures or groupings) you may not read; the metric asked for may be among them. Do not say the metric does not exist. | -The same answer lists every dataset you may query with all its measures, -matched or not (a call without `terms` returns that catalogue too), so the -loose-form check needs no second read. A loose form is a word a listed -measure's name, label or description contains, directly or in translation: -"revenue" against Won Revenue, Annual Revenue and Planned Revenue; "金额" -against several amounts. - When you ask, the reply is the question alone: no figure, and no tool call until the user answers. `partial: true` on the answer means the catalogue may be incomplete; `warning` says why, and you repeat it when you fall back. diff --git a/skills/objectstack-ask/evals/metric-selection-fallback.json b/skills/objectstack-ask/evals/metric-selection-fallback.json index f9835e54614..579f3825c74 100644 --- a/skills/objectstack-ask/evals/metric-selection-fallback.json +++ b/skills/objectstack-ask/evals/metric-selection-fallback.json @@ -23,18 +23,18 @@ }, { "id": 3, - "prompt": "The user asks: \"What was revenue last month?\" `list_datasets({ terms: ['revenue', 'last month'] })` answers three datasets, each with `matches: []`. Their measures include Won Revenue (dataset Sales: \"Amount of opportunities closed as won\"), Annual Revenue (dataset Accounts: \"Sum of each account's stated yearly revenue\") and Planned Revenue (dataset Targets: \"Revenue target set for the period\"); no measure has the synonym `revenue`. What is your reply?", - "expected_output": "Nothing matches, and the word is a loose form of several listed measures: the catalogue already in hand lists Won Revenue, Annual Revenue and Planned Revenue, whose labels contain it. A similar word is not a match, so no measure is selected. The reply is a question and nothing else, such as \"Which revenue do you mean?\", listing each candidate by its label, its dataset's label and its description (Won Revenue, in Sales; Annual Revenue, in Accounts; Planned Revenue, in Targets). It does not pick one and computes nothing: no figure, and no tool call until the user answers.", + "prompt": "The user asks: \"What was revenue last month?\" `list_datasets({ terms: ['revenue', 'last month'] })` answers three datasets, each with `matches: []`: `sales` (label Sales) lists the measure `won_revenue`, labelled Won Revenue and described as \"Amount of opportunities closed as won\"; `accounts` (label Accounts) lists `annual_revenue`, labelled Annual Revenue, \"Sum of each account's stated yearly revenue\"; `targets` (label Targets) lists `planned_revenue`, labelled Planned Revenue, \"Revenue target set for the period\". The answer also carries `candidates: [{ term: 'revenue', dataset: 'sales', member: 'measures.won_revenue' }, { term: 'revenue', dataset: 'accounts', member: 'measures.annual_revenue' }, { term: 'revenue', dataset: 'targets', member: 'measures.planned_revenue' }]`. What is your reply?", + "expected_output": "The word matches nothing, and `candidates` lists three members for it. A candidate is not a match, so no measure is selected. The reply is a question and nothing else, such as \"Which revenue do you mean?\", listing each candidate by its label, its dataset's label and its description, read from the dataset entries the candidates point to (Won Revenue, in Sales: amount of opportunities closed as won; Annual Revenue, in Accounts: sum of each account's stated yearly revenue; Planned Revenue, in Targets: revenue target set for the period). It shows labels, not the measures' machine names. It does not pick one and computes nothing: no figure, and no tool call until the user answers.", "files": [], "assertions": { "must_contain": ["Won Revenue", "Annual Revenue", "Planned Revenue", "Sales", "Accounts", "Targets", "?"], - "must_not_contain": ["query_dataset", "aggregate_records", "非指标口径"] + "must_not_contain": ["query_dataset", "aggregate_records", "非指标口径", "won_revenue", "annual_revenue", "planned_revenue"] } }, { "id": 4, - "prompt": "The user asks: \"How many open support tickets do we have per priority?\" `list_datasets({ terms: ['open support tickets', 'priority'] })` answers two sales datasets with `matches: []`; none of their measures is about tickets. `list_objects` shows an object `support_ticket`. What do you do, and how does the answer open?", - "expected_output": "Nothing matches and no listed measure is a reading of the word, so this is the fallback. Calls `describe_object({ objectName: 'support_ticket' })` and reads the fields before filtering: `status` and `priority` carry `options`, so the filter uses the option's `value`, never its label. Calls `aggregate_records` once with a count grouped by `priority` and a `where` on the open status value, instead of paging `query_records` and adding rows up. Opens the answer with one line saying, in the user's language, that the figure is not from a governed metric, computed from the Support Ticket object's status and priority fields, then shows the counts by priority label and states the filter in words.", + "prompt": "The user asks: \"How many open support tickets do we have per priority?\" `list_datasets({ terms: ['open support tickets', 'priority'] })` answers two sales datasets with `matches: []` and no `candidates`; none of their measures is about tickets. `list_objects` shows an object `support_ticket`. What do you do, and how does the answer open?", + "expected_output": "The word for the thing measured has no match and no candidates, so this is the fallback. Calls `describe_object({ objectName: 'support_ticket' })` and reads the fields before filtering: `status` and `priority` carry `options`, so the filter uses the option's `value`, never its label. Calls `aggregate_records` once with a count grouped by `priority` and a `where` on the open status value, instead of paging `query_records` and adding rows up. Opens the answer with one line saying, in the user's language, that the figure is not from a governed metric, computed from the Support Ticket object's status and priority fields, then shows the counts by priority label and states the filter in words.", "files": [], "assertions": { "must_contain": ["describe_object", "aggregate_records", "priority"], @@ -43,7 +43,7 @@ }, { "id": 5, - "prompt": "The user asks: \"Which of this week's shipments are over the carrier's weight limit?\" `list_datasets` has no match and no measure about shipments. `describe_object({ objectName: 'shipment' })` lists `name`, `carrier`, `status`, `shipped_at` and `destination`; no object has a field for weight or for a carrier's limit. What is your reply?", + "prompt": "The user asks: \"Which of this week's shipments are over the carrier's weight limit?\" `list_datasets` has no match, no `candidates` and no measure about shipments. `describe_object({ objectName: 'shipment' })` lists `name`, `carrier`, `status`, `shipped_at` and `destination`; no object has a field for weight or for a carrier's limit. What is your reply?", "expected_output": "The data cannot answer. Says the data it can read does not record it and names what is missing: a shipment's weight, and each carrier's limit. Offers the computation if the user supplies those values. It fills the gap with no figure of its own and draws no conclusion from one, so it names no shipment as over or under the limit. Any figure it does add (such as how many shipments went out this week) comes from a tool answer in this conversation.", "files": [], "assertions": { @@ -53,8 +53,8 @@ }, { "id": 6, - "prompt": "用户问:「我们的毛利率是多少?」 `list_datasets({ terms: ['毛利率'] })` answers one dataset, `finance_summary` (label 财务汇总), with `membersWithheld: true`, `matches: []` and two listed measures, 营业收入 and 费用合计. What is your reply?", - "expected_output": "`membersWithheld: true` on 财务汇总 means it has members (measures or groupings) this user may not read, and the metric asked for may be among them, so the reply says exactly that, in Chinese and naming the dataset by its label, as in 「财务汇总里有您无权查看的指标或分组,毛利率可能是其中之一」. It never tells the user the metric is absent, and it shows the user no raw flag name. Nothing matched and the two listed measures (营业收入, 费用合计) are not readings of 毛利率, so no measure is selected and no governed figure is given; if it goes on to compute anything from the object tools, that answer opens with the 非指标口径 line.", + "prompt": "用户问:「我们的毛利率是多少?」 `list_datasets({ terms: ['毛利率'] })` answers one dataset, `finance_summary` (label 财务汇总), with `membersWithheld: true`, `matches: []` and two listed measures, 营业收入 and 费用合计; the answer has no `candidates`. What is your reply?", + "expected_output": "`membersWithheld: true` on 财务汇总 means it has members (measures or groupings) this user may not read, and the metric asked for may be among them, so the reply says exactly that, in Chinese and naming the dataset by its label, as in 「财务汇总里有您无权查看的指标或分组,毛利率可能是其中之一」. It never tells the user the metric is absent, and it shows the user no raw flag name. 毛利率 has no match and no candidates, so no measure is selected, neither listed measure (营业收入, 费用合计) is offered as a reading of it, and no governed figure is given; if it goes on to compute anything from the object tools, that answer opens with the 非指标口径 line.", "files": [], "assertions": { "must_contain": ["财务汇总", "毛利率"], @@ -70,6 +70,26 @@ "must_contain": ["query_dataset", "营收", "赢单率", "销售分析"], "must_not_contain": ["aggregate_records", "非指标口径"] } + }, + { + "id": 8, + "prompt": "The user asks: \"What is our churn this quarter?\" `list_datasets({ terms: ['churn', 'this quarter'] })` answers one dataset, `subscriptions` (label Subscriptions), with `matches: []`; its measures are `churn_rate`, labelled Churn Rate and described as \"Share of subscriptions cancelled in the period\", and `active_count`, labelled Active Subscriptions. The answer also carries `candidates: [{ term: 'churn', dataset: 'subscriptions', member: 'measures.churn_rate' }]`. What is your reply?", + "expected_output": "The word matches nothing, and `candidates` lists one member for it. One candidate is still not a match, so it is not picked and nothing is computed. The reply is a question and nothing else, asking whether that candidate is the one meant, such as \"Do you mean Churn Rate (in Subscriptions: share of subscriptions cancelled in the period)?\", naming the candidate's label, its dataset's label and its description, not its machine name. It gives no figure, makes no tool call until the user answers, and does not fall back to the object tools either: the fallback is for a word with no candidates.", + "files": [], + "assertions": { + "must_contain": ["Churn Rate", "Subscriptions", "?"], + "must_not_contain": ["query_dataset", "aggregate_records", "churn_rate"] + } + }, + { + "id": 9, + "prompt": "用户问:「上个月的营业额是多少?」 `list_datasets({ terms: ['营业额', '上个月'] })` answers one dataset, `sales_analysis` (label 销售分析, `object: 'opportunity'`), with `matches: []` and two measures, 赢单金额 and 赢单数; the answer has no `candidates`. `list_objects` shows `opportunity`. What do you do, and how does the answer open?", + "expected_output": "营业额 has no match and no candidates, so this is the fallback: it asks nothing, and it does not treat 赢单金额 as a match because the word looks close. Calls `describe_object({ objectName: 'opportunity' })` and reads the fields before filtering, then `aggregate_records` once for the sum over last month. Opens the answer, in Chinese, with one line saying it is not from a governed metric (非指标口径) and names the object and fields it computed from. Because `opportunity` is the `object` of the listed dataset 销售分析, it adds one line naming that dataset and its measures (赢单金额, 赢单数), so the user can ask for the governed figure, and it states the month it filtered to in words.", + "files": [], + "assertions": { + "must_contain": ["describe_object", "aggregate_records", "非指标口径", "销售分析", "赢单金额"], + "must_not_contain": ["query_dataset", "provenance"] + } } ] }