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

docs(skills): the `objectstack-ask` skill reads `withheldFields`, asks `aggregate_records` for a top or bottom N, and answers "how many" from `totalGroups`

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 three things. In step 4: a `query_records` or `get_record` answer whose `withheldFields` names a field means the field exists but is hidden from the caller, so the client says it is not visible, never that it is empty; and a top or bottom N is asked of `aggregate_records` with `orderBy` (an aggregation alias or a group key) and `limit: N`, so the database ranks and cuts the groups. In step 6, one bullet covers `truncated: true`: more rows or groups existed than came back, so the client says the result is partial, and cites `totalGroups` (answered by `query_dataset` and `aggregate_records`) as how many groups existed before the cut; a `query_dataset` answer without `totalGroups` has an unknown total, never `rowCount`. A capped `query_records` page keeps stating its own `total`, which the bullet leaves alone.

The two per-tool `truncated` sentences that bullet replaces are removed from steps 3 and 4. `packages/mcp/src/ask-skill.generated.ts` is regenerated from the skill; no code path changes.
15 changes: 10 additions & 5 deletions packages/mcp/src/ask-skill.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ export const ASK_SKILL_DATA_LOOP: string = [
' `provenance` (the dataset\'s label and each measure\'s label, as in',
' 「指标:营收(数据集:销售分析)」), not from memory.',
'- Use the measure\'s `description` to say what the number includes and excludes.',
'- `truncated: true`: more rows existed than came back. Say the result is',
' partial. A `warning` on the answer narrows what you were allowed to read:',
' repeat it.',
'- A `warning` on the answer narrows what you were allowed to read: repeat it.',
'',
'## 4. Fallback: object queries',
'',
Expand All @@ -82,8 +80,12 @@ export const ASK_SKILL_DATA_LOOP: string = [
' read. Read its fields before you filter: a field with `options` is filtered',
' by the option\'s `value`, never its label.',
'- Use `aggregate_records` for a count, sum, average or breakdown. Never page',
' through `query_records` to add numbers up yourself. `truncated: true` on its',
' answer means groups were cut off: say so.',
' through `query_records` to add numbers up yourself. For a top or bottom N,',
' pass `orderBy` (an aggregation alias or a group key) and `limit: N`, so the',
' database ranks and cuts the groups.',
'- `withheldFields` on a `query_records` or `get_record` answer names fields',
' that exist but are hidden from you: say they are not visible to you, never',
' that they are empty.',
'- Open the answer with one line saying it is not from a governed metric',
' (非指标口径), and name the object and fields you computed it from.',
'- When that object is a listed dataset\'s `object`, add one line naming the',
Expand All @@ -102,5 +104,8 @@ export const ASK_SKILL_DATA_LOOP: string = [
'- Answer in the user\'s language.',
'- Show labels, not machine names or raw option values.',
'- Every figure comes from a tool answer in this conversation.',
'- `truncated: true`: more rows or groups existed than came back; say the',
' result is partial, and cite `totalGroups` as how many groups existed before',
' the cut. Without it, say a `query_dataset` total is unknown, not `rowCount`.',
'- State the filter and the time window you used, in words.',
].join('\n');
28 changes: 27 additions & 1 deletion scripts/check-skills-token-ratchet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1923,7 +1923,33 @@ export const CEILINGS = new Map([
// ceil(($(wc -c < skills/objectstack-ask/SKILL.md) - 20) / 4) == ceil(7115 / 4)
// = 1779 (+29), the measured remainder only. Pinned AT the measurement, zero
// headroom; no other row moves.
['skills/objectstack-ask/SKILL.md', 1779],
// 1779 -> 1873, the cards that teach the object tools' new members: step 4
// says `withheldFields` names fields that exist but are hidden (never empty),
// and how to ask `aggregate_records` for a top or bottom N; one shared
// `truncated` bullet in step 6 answers "how many" from `totalGroups` for
// `query_dataset` and `aggregate_records` alike, and says the total is
// unknown without it. Same raise path (ruling record 6513306068, letter B).
// PAID DOWN FIRST — the per-tool `truncated` restatements cut, the shared
// bullet keeping their one home: step 3's "`truncated: true`: more rows
// existed than came back. Say the result is partial." and step 4's
// "`truncated: true` on its answer means groups were cut off: say so."
// Cuts -151 bytes, net +377: 7135 -> 7512 bytes, less the 20-byte stamp line:
// ceil(($(wc -c < skills/objectstack-ask/SKILL.md) - 20) / 4) == ceil(7492 / 4)
// = 1873 (+94), the measured remainder only. Pinned AT the measurement, zero
// headroom; no other row moves.
// 1873 -> 1877, re-measured on the same PR before it landed, after its
// contract review (record 6997032414, M1) found the shared bullet telling the
// agent a total is unknown on a capped `query_records` page, which states
// its own `total`. The bullet now cites `totalGroups` as the pre-cut count and
// scopes "unknown" to a `query_dataset` answer without it (`aggregate_records`
// always answers it). Same raise path (ruling record 6513306068, letter B);
// the restatements were cut on the row's previous measurement and nothing
// else in the file restates it. Bullet 215 -> 230 bytes: 7512 -> 7527 bytes,
// less the 20-byte stamp line:
// ceil(($(wc -c < skills/objectstack-ask/SKILL.md) - 20) / 4) == ceil(7507 / 4)
// = 1877 (+4), the measured remainder only. Pinned AT the measurement, zero
// headroom; no other row moves.
['skills/objectstack-ask/SKILL.md', 1877],

// ── the objectstack-project skill joins the catalog ──
// A new published process skill: how a change moves through a metadata-app
Expand Down
15 changes: 10 additions & 5 deletions skills/objectstack-ask/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ be incomplete; `warning` says why, and you repeat it when you fall back.
`provenance` (the dataset's label and each measure's label, as in
「指标:营收(数据集:销售分析)」), not from memory.
- Use the measure's `description` to say what the number includes and excludes.
- `truncated: true`: more rows existed than came back. Say the result is
partial. A `warning` on the answer narrows what you were allowed to read:
repeat it.
- A `warning` on the answer narrows what you were allowed to read: repeat it.

## 4. Fallback: object queries

Expand All @@ -97,8 +95,12 @@ be incomplete; `warning` says why, and you repeat it when you fall back.
read. Read its fields before you filter: a field with `options` is filtered
by the option's `value`, never its label.
- Use `aggregate_records` for a count, sum, average or breakdown. Never page
through `query_records` to add numbers up yourself. `truncated: true` on its
answer means groups were cut off: say so.
through `query_records` to add numbers up yourself. For a top or bottom N,
pass `orderBy` (an aggregation alias or a group key) and `limit: N`, so the
database ranks and cuts the groups.
- `withheldFields` on a `query_records` or `get_record` answer names fields
that exist but are hidden from you: say they are not visible to you, never
that they are empty.
- Open the answer with one line saying it is not from a governed metric
(非指标口径), and name the object and fields you computed it from.
- When that object is a listed dataset's `object`, add one line naming the
Expand All @@ -117,4 +119,7 @@ be incomplete; `warning` says why, and you repeat it when you fall back.
- Answer in the user's language.
- Show labels, not machine names or raw option values.
- Every figure comes from a tool answer in this conversation.
- `truncated: true`: more rows or groups existed than came back; say the
result is partial, and cite `totalGroups` as how many groups existed before
the cut. Without it, say a `query_dataset` total is unknown, not `rowCount`.
- State the filter and the time window you used, in words.
40 changes: 40 additions & 0 deletions skills/objectstack-ask/evals/metric-selection-fallback.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,46 @@
"must_contain": ["trip request"],
"must_not_contain": ["aggregate_records", "query_records", "query_dataset", "非指标口径"]
}
},
{
"id": 12,
"prompt": "The user asks: \"List the open opportunities with their probability.\" No dataset matches, so you fell back: `describe_object({ objectName: 'opportunity' })` lists the fields `name`, `stage` and `probability`, and `query_records` answered three open opportunities (Acme Renewal, Globex Expansion, Initech Pilot), each with `name` and `stage` but no `probability`, plus `withheldFields: ['probability']`. How do you write the answer?",
"expected_output": "Opens with one line saying the list is not from a governed metric and names the Opportunity object and its fields. Lists the three opportunities by name and stage, and says the probability field exists but is not visible to it, because `withheldFields` names it. It never says the probability is empty, blank or zero, and gives no probability value.",
"files": [],
"assertions": {
"must_contain": ["not visible", "Acme Renewal"],
"must_not_contain": ["is empty", "is blank", "are empty", "are blank"]
}
},
{
"id": 13,
"prompt": "The user asks: \"Which 5 industries bring in the most revenue, and how many industries are there?\" `revenue` and `industry` match one measure and one dimension of `sales_analysis` (label Sales Analysis). `query_dataset` with `order` on revenue descending and `limit: 5` answered five rows (Software, Retail, Banking, Energy, Health), `rowCount: 5`, `truncated: true`, and no `totalGroups`. How do you write the answer?",
"expected_output": "Cites the answer's source, then lists the five industries by revenue and says the result is partial: more industries exist than came back. Because the answer carries no `totalGroups`, it says the total number of industries is unknown. It never gives 5 (`rowCount`) as how many industries there are.",
"files": [],
"assertions": {
"must_contain": ["Software", "Health", "partial", "unknown"],
"must_not_contain": ["there are 5", "there are five"]
}
},
{
"id": 14,
"prompt": "The user asks: \"Which 3 accounts have the most open opportunities, and how many accounts have any?\" No dataset matches, so you fell back on `opportunity`. `aggregate_records` with a count grouped by `account`, `orderBy` on the count descending and `limit: 3` answered three groups (Acme 12, Globex 9, Initech 7), `truncated: true` and `totalGroups: 41`. How do you write the answer?",
"expected_output": "Opens with one line saying it is not from a governed metric, naming the Opportunity object and its account field. Lists the three accounts with their counts, says the result is partial, and cites 41 as how many accounts have open opportunities (the groups before the cut). It does not give 3 as that number.",
"files": [],
"assertions": {
"must_contain": ["Acme", "41", "partial"],
"must_not_contain": ["unknown"]
}
},
{
"id": 15,
"prompt": "The user asks: \"List the open support tickets and how many there are.\" No dataset matches, so you fell back: `query_records` on `support_ticket` answered a page of 50 records with `total: 240` and `truncated: true`, and no `totalGroups`. How do you write the answer?",
"expected_output": "Opens with one line saying it is not from a governed metric, naming the Support Ticket object. Says there are 240 open tickets, from the answer's `total`, shows the 50 that came back and says the list is partial. It never says the total is unknown, and never gives 50 as the total.",
"files": [],
"assertions": {
"must_contain": ["240", "partial"],
"must_not_contain": ["unknown"]
}
}
]
}
Loading