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
18 changes: 18 additions & 0 deletions .changeset/34996-ask-skill-iter-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
'@objectstack/skills': patch
'@objectstack/mcp': patch
---

docs(skills): the `objectstack-ask` skill loads for every question about the app's records, asks back without a figure of its own, keeps terms whole and declines a record kind it cannot see

Clause-②: no
Metadata-protocol: none

The `objectstack-ask` skill, and the page at `GET /mcp/skill` that is generated from it, now tell a connected client:

- The skill is for every question answered from the app's records, before the first data tool call, even one that names no metric: what has been claimed, spent, sold or paid so far, as well as a number, a total, a ranking, a breakdown, a trend or a list ("how much", "so far", 「一共」 join the trigger words).
- A term sent to `list_datasets` is the user's noun phrase for the thing, kept whole ("travel budget", not "travel" and "budget") and without the verbs, time words and question words around it ("trip days", not "trip days requested").
- A reply that asks the user back states no figure of its own (no count, total or option number): each option is named by its label in a bullet, and its description is quoted as written. It asks only about matches or candidates for words the user wrote; a word with no match and no candidates goes to the object fallback instead of a question about another word's matches.
- The object fallback opens with one rule: when the question names a kind of record that no listed object or dataset is, the client says it cannot see those records here (they may be hidden from it) and stops, and never answers from a different object that merely links to them.

Two sentences in the `candidates` row of step 2 that restated step 1 and the paragraph under the table are removed. The skill's eval cases add a question about what has been claimed so far and a question about a record kind no listed object shows. `packages/mcp/src/ask-skill.generated.ts` is regenerated from the skill; no code path changes.
2 changes: 1 addition & 1 deletion content/docs/ai/skills-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Do not use to author new metadata (the domain skills cover that), or to reconcil

Answer a business question over a live ObjectStack environment through its MCP tools (list_datasets, query_dataset, list_objects, describe_object, query_records, aggregate_records): find the governed metric the question names, compute it and cite its source, or fall back to an object query and say so.

Use when the user asks for a number, a ranking, a breakdown, a trend or a list from the app's data, in any language ("how many", "total", "top 10", "by stage", "this quarter"; "多少", "总额", "排名", "占比", "趋势", "按阶段统计", "列出").
Use for EVERY question answered from the app's records, before the first data tool call, even when it names no metric: a number, a total, what has been claimed, spent, sold or paid so far, a ranking, a breakdown, a trend or a list, in any language ("how many", "how much", "total", "so far", "top 10", "by stage", "this quarter"; "多少", "一共", "总额", "排名", "占比", "趋势", "按阶段统计", "列出").

Do not use for building or changing metadata (the domain skills cover that), or for writing a query in application code (see objectstack-query).

Expand Down
18 changes: 15 additions & 3 deletions packages/mcp/src/ask-skill.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ export const ASK_SKILL_DATA_LOOP: string = [
' "商机数") and what it is grouped or filtered by ("by stage", "按行业").',
'- Call `list_datasets({ terms })` with those words, as the user wrote them and',
' in the user\'s language. Do not translate or reword a term: a match on a word',
' you supplied is your reading, not the user\'s.',
' you supplied is your reading, not the user\'s. A term is the noun phrase for',
' the thing, kept whole ("travel budget", not "travel" and "budget": a',
' fragment\'s matches are not the user\'s) and without the verbs, time words',
' and question words around it ("trip days", not "trip days requested";',
' "报销金额", not "报销金额合计是多少").',
'- Each dataset in the answer carries `matches`: one entry per hit, with the',
' `term`, the `member` it names (`measures.<name>` or `dimensions.<name>`) and',
' `matchedOn`. A word matches only when it equals a member\'s name, label or',
Expand All @@ -38,12 +42,16 @@ 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. |',
'| 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. |',
'| 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. |',
'| 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. |',
'',
'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',
'until the user answers. State no figure of your own in it (no count, total',
'or option number): name each option by its label in a bullet, and quote its',
'description as written. Ask only about matches or candidates for words the user',
'wrote; when their word matched nothing and has no candidates, go to step 4',
'instead of asking about some other word\'s matches. `partial: true` on the answer means the catalogue may',
'be incomplete; `warning` says why, and you repeat it when you fall back.',
'',
'## 3. Compute a governed metric',
Expand All @@ -61,6 +69,10 @@ export const ASK_SKILL_DATA_LOOP: string = [
'',
'## 4. Fallback: object queries',
'',
'- The question names a kind of record (trip requests, invoices) and no listed',
' object or dataset is that kind: say you cannot see those records here (they',
' may be hidden from you) and stop. Never answer from a different object that',
' merely links to it.',
'- `list_objects`, then `describe_object({ objectName })` on the object you will',
' read. Read its fields before you filter: a field with `options` is filtered',
' by the option\'s `value`, never its label.',
Expand Down
20 changes: 19 additions & 1 deletion scripts/check-skills-token-ratchet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,25 @@ export const CEILINGS = new Map([
// 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],
// 1491 -> 1740, the ask-skill iteration loop's first kept change set
// (Part of #34996), measured on the travel_expense ask round before it was
// kept: the description triggers on every question answered from the app's
// records ("so far", 「一共」); a term is the user's noun phrase kept whole; an
// asked-back reply states no figure of its own, quotes each description as
// written and asks only about the user's own words; step 4 declines a record kind no listed object shows instead of
// answering from a linked one. Raise path the standing ruling
// 「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B). PAID DOWN
// FIRST — two restatements cut from step 2's `candidates` row, each keeping
// its other home: ", and never treat a candidate as a match" (step 1's "A
// candidate is not a match.") and "Compute nothing yet." (the paragraph under
// the table: "no figure, and no tool call until the user answers"). Text
// +1057 bytes, cuts -61, the reviewed narrowing of the ask-back sentence +2
// (re-measured before it was kept): 5981 -> 6979 bytes, less the 20-byte
// stamp line:
// ceil(($(wc -c < skills/objectstack-ask/SKILL.md) - 20) / 4) == ceil(6959 / 4)
// = 1740 (+249), the measured remainder only. Pinned AT the measurement, zero
// headroom; no other row moves.
['skills/objectstack-ask/SKILL.md', 1740],
]);

/**
Expand Down
28 changes: 21 additions & 7 deletions skills/objectstack-ask/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ description: >
MCP tools (list_datasets, query_dataset, list_objects, describe_object,
query_records, aggregate_records): find the governed metric the question
names, compute it and cite its source, or fall back to an object query and
say so. Use when the user asks for a number, a ranking, a breakdown, a trend
or a list from the app's data, in any language ("how many", "total", "top
10", "by stage", "this quarter"; "多少", "总额", "排名", "占比", "趋势",
"按阶段统计", "列出"). Do not use for building or changing metadata (the
say so. Use for EVERY question answered from the app's records, before the
first data tool call, even when it names no metric: a number, a total, what
has been claimed, spent, sold or paid so far, a ranking, a breakdown, a trend
or a list, in any language ("how many", "how much", "total", "so far", "top
10", "by stage", "this quarter"; "多少", "一共", "总额", "排名", "占比",
"趋势", "按阶段统计", "列出"). Do not use for building or changing metadata (the
domain skills cover that), or for writing a query in application code (see
objectstack-query).
license: Apache-2.0
Expand All @@ -33,7 +35,11 @@ wrote its business definition) outranks a number you work out yourself.
"商机数") and what it is grouped or filtered by ("by stage", "按行业").
- Call `list_datasets({ terms })` with those words, as the user wrote them and
in the user's language. Do not translate or reword a term: a match on a word
you supplied is your reading, not the user's.
you supplied is your reading, not the user's. A term is the noun phrase for
the thing, kept whole ("travel budget", not "travel" and "budget": a
fragment's matches are not the user's) and without the verbs, time words
and question words around it ("trip days", not "trip days requested";
"报销金额", not "报销金额合计是多少").
- Each dataset in the answer carries `matches`: one entry per hit, with the
`term`, the `member` it names (`measures.<name>` or `dimensions.<name>`) and
`matchedOn`. A word matches only when it equals a member's name, label or
Expand All @@ -51,12 +57,16 @@ 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. |
| 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. |
| 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. |
| 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. |

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
until the user answers. State no figure of your own in it (no count, total
or option number): name each option by its label in a bullet, and quote its
description as written. Ask only about matches or candidates for words the user
wrote; when their word matched nothing and has no candidates, go to step 4
instead of asking about some other word's matches. `partial: true` on the answer means the catalogue may
be incomplete; `warning` says why, and you repeat it when you fall back.

## 3. Compute a governed metric
Expand All @@ -74,6 +84,10 @@ be incomplete; `warning` says why, and you repeat it when you fall back.

## 4. Fallback: object queries

- The question names a kind of record (trip requests, invoices) and no listed
object or dataset is that kind: say you cannot see those records here (they
may be hidden from you) and stop. Never answer from a different object that
merely links to it.
- `list_objects`, then `describe_object({ objectName })` on the object you will
read. Read its fields before you filter: a field with `options` is filtered
by the option's `value`, never its label.
Expand Down
20 changes: 20 additions & 0 deletions skills/objectstack-ask/evals/metric-selection-fallback.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@
"must_contain": ["describe_object", "aggregate_records", "非指标口径", "销售分析", "赢单金额"],
"must_not_contain": ["query_dataset", "provenance"]
}
},
{
"id": 10,
"prompt": "The user asks: \"What has been claimed so far?\" It names no metric. You called `list_datasets({ terms: ['claimed'] })`. The answer lists one dataset, `expense_analysis` (label Expense Analysis), with `matches: []`; its measures are `total_claimed`, labelled Claimed Amount and described as \"Sum of submitted expense claim amounts\", and `claim_count`, labelled Claims. The answer also carries `candidates: [{ term: 'claimed', dataset: 'expense_analysis', member: 'measures.total_claimed' }]`. What is your reply?",
"expected_output": "A question about what has been claimed is answered from the app's records, so this skill applies before the first data call even though no metric is named. The word matches nothing and `candidates` lists one member for it, so the reply is a question and nothing else, asking whether that candidate is the one meant, such as \"Do you mean Claimed Amount (in Expense Analysis: sum of submitted expense claim amounts)?\", with the option named by its label in a bullet. It states no figure of its own: no total, no count of claims and no numbered option, and the candidate's description is quoted as written. It makes no tool call until the user answers.",
"files": [],
"assertions": {
"must_contain": ["Claimed Amount", "Expense Analysis", "?"],
"must_not_contain": ["query_dataset", "aggregate_records", "total_claimed", "1."]
}
},
{
"id": 11,
"prompt": "The user asks: \"How many trip requests were approved this month?\" `list_datasets({ terms: ['trip requests'] })` answers one dataset, `expense_analysis` (label Expense Analysis, `object: 'expense_claim'`), with `matches: []` and no `candidates`. `list_objects` shows `expense_claim` and `employee`; `expense_claim` has a lookup field `trip_request`, and no listed object is a trip request. What do you do?",
"expected_output": "No listed object or dataset is a trip request, so the records asked about cannot be seen here. The reply says, in the user's language, that it cannot see trip requests in this environment (they may be hidden from it) and stops. It does not count expense claims that link to a trip request through the `trip_request` lookup as an answer, and it gives no figure.",
"files": [],
"assertions": {
"must_contain": ["trip request"],
"must_not_contain": ["aggregate_records", "query_records", "query_dataset", "非指标口径"]
}
}
]
}
Loading