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
16 changes: 16 additions & 0 deletions .changeset/37976-skill-knowledge-sources-beyond-documents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@objectstack/skills': patch
---

docs(skills): `objectstack-ai` teaches knowledge sources over business objects, not only a document library

Clause-②: no
Metadata-protocol: none

`skills/objectstack-ai` § Knowledge Sources (RAG) gains three rules, one example each:

- **Long free text only.** `content` lists prose fields (an article body, a ticket's `description`, a note) with their title or subject line. Numbers, dates, statuses and the names of people or accounts stay out, and counts and filters go to the record tools (`aggregate_records`, or `aggregate_data` in the in-app assistant).
- **One source per corpus.** A skill's `instructions` say which source to pass in `sourceIds`, the argument of `search_knowledge`; omitted, every exposed source is scanned.
- **Attachment text goes through a field.** A `file` field in `content` adds no file text: write the extracted text to a `textarea` field and list that field.

No behaviour changes.
21 changes: 20 additions & 1 deletion scripts/check-skills-token-ratchet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,26 @@ export const CEILINGS = new Map([
// ceil(27623 / 4) = 6906; the row moves +13, the measured remainder only.
// Pinned AT the measurement.
// ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(27623 / 4)
['skills/objectstack-ai/SKILL.md', 6906], // -18 (was 6824), then -5 A2′ (was 6806)
// 6906 -> 7148 (2026-11-28, knowledge sources over business objects): the
// section taught a source for a document library only. It now says three
// things, one example each: `content` lists long free text only (a title or
// subject line with it), and counts and filters go to the record tools,
// named by both spellings (`aggregate_records`, `aggregate_data` in `ask`);
// one source per corpus, a skill's `instructions` naming which to pass in
// `sourceIds`, the argument of `search_knowledge`; attachment text reaches
// an index through a text field. Raise path the standing ruling
// 「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B). PAID DOWN
// FIRST: the `content` row's "Meaningful text only" (the first rule says
// it; the row keeps "Never ids or system fields"), and the `agent.knowledge`
// pitfall row's "describe intended grounding in `instructions`", now a
// pointer to the second rule; the retired-kinds line's "no form in 19"
// became a pointer to the third rule. Arithmetic in priced bytes (stamp
// line excluded), against `main`'s 27621 (the row's 6906, headroom 0): the
// file is 27648 -> 28617 bytes, so the LANDED priced text is 28590 ->
// ceil(28590 / 4) = 7148; the row moves +242, the measured remainder only.
// Pinned AT the measurement.
// ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(28590 / 4)
['skills/objectstack-ai/SKILL.md', 7148],
// -12 (was 6331): the `http.server` decision-table row dropped a trailing
// clause that taught `contributes.routes` as a key that "parses but serves
// nothing". The key is retired — an authored entry is now REFUSED, carrying
Expand Down
22 changes: 19 additions & 3 deletions skills/objectstack-ai/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ object or field, when you may not search that object or query a field it reads.
| `adapter` | Optional store id (`pgvector`, `turso`, `memory`). Omitted: the deployment's store (`pgvector` on PostgreSQL, `turso` otherwise), else the only one registered; several and none the deployment's is refused, naming them |
| `source.kind` | `'object'`, the one kind |
| `source.object` | The object whose records are indexed |
| `source.content` | Non-empty list of the fields whose text is indexed, in order. `'*'` is refused: it would also send fields added later. Meaningful text only, never ids or system fields |
| `source.content` | Non-empty list of the fields whose text is indexed, in order. `'*'` is refused: it would also send fields added later. Never ids or system fields |
| `source.metadataFields` | Fields kept for search-time filtering (`status`, `owner_id`, `tags`) |
| `source.where` | ObjectQL `where`: keeps drafts and archived rows out |
| `source.split` | How documents are cut into passages (below) |
Expand All @@ -270,7 +270,7 @@ Retired in 19, each refused with its fix: `id` (use `name`), `contentFields`
deployment configures one embedder), `vectorStore` (the store is `adapter`),
`adapterConfig` (an adapter takes plugin options), `refresh.cron` (call
`reindexSource` from a flow or job), and `source.kind: 'file'` / `'http'` with
`prefix`, `mimeTypes`, `urls`, `userAgent` (no form in 19). `os migrate meta
`prefix`, `mimeTypes`, `urls`, `userAgent` (attachment text: below). `os migrate meta
--from 18` lists a stack's edits; edit a registration in code by hand.

`os validate` and publish check each source; an error refuses the publish:
Expand Down Expand Up @@ -306,6 +306,22 @@ export const supportKb: KnowledgeSource = KnowledgeSourceSchema.parse({
});
```

**Sources over business objects**, not only a document library:

- **Long free text only.** `content` lists prose: an article body, a ticket's
`description`, a note, with its title or subject line. Numbers, dates,
statuses and the names of people or accounts stay out; counts and filters
go to the record tools. "Which customers reported login loops?" is
`search_knowledge`; "how many tickets are open per priority?" is
`aggregate_records` (in-app `ask`: `aggregate_data`).
- **One source per corpus**, and a skill's `instructions` say which to pass in
`sourceIds`: `search_knowledge({ query, sourceIds: ['ticket_bodies'] })`
searches the tickets and not `support_kb`. Omitted, every exposed source is
scanned.
- **Attachment text goes through a field.** A `file` field in `content` adds
no file text. Have the flow, hook or import that extracts the text write it
to a `textarea` field (`contract.attachment_text`), and list that field.

**Splitting (`split`).** The knowledge service cuts each document into passages
for a store declaring `capabilities.chunks`; any other store receives whole
documents. `split: { strategy, maxChars?, minChars? }` — `strategy` is required
Expand Down Expand Up @@ -461,7 +477,7 @@ https://objectstack.ai/docs/protocol-upgrade:
| Retired key | Removed in 17, tombstone gone in 18 — why, and what replaces it |
|:--|:--|
| `agent.tools` | The inline slot resolved names against the *full* registry with no surface check. Not a rename: the strict schema refuses the key as unknown; re-declare each tool in a `defineSkill` under the stack's `skills` (ADR-0064) |
| `agent.knowledge` | Declaring sources/indexes on an agent never scoped retrieval — `search_knowledge` takes `sourceIds` from the model's tool-call arguments. Restrict on the knowledge source (`aiExposed`, `source.where`); describe intended grounding in `instructions` |
| `agent.knowledge` | Declaring sources/indexes on an agent never scoped retrieval — `search_knowledge` takes `sourceIds` from the model's tool-call arguments. Restrict on the knowledge source (`aiExposed`, `source.where`); name the `sourceIds` to pass in `instructions` (§ Knowledge Sources) |

---

Expand Down
11 changes: 11 additions & 0 deletions skills/objectstack-ai/evals/skills-tools-knowledge.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@
"must_contain_any": [["requires: ['knowledge']", "requires: [\"knowledge\"]"]],
"must_not_contain": ["contentFields:"]
}
},
{
"id": 15,
"prompt": "Our support app has `kb_article` (`title`, `body`) and `support_ticket` (`subject`, `description` as a textarea, `priority`, `status`, `amount`, and a `contract_pdf` file field holding a signed PDF). The assistant should answer from article bodies, from ticket descriptions and from what the PDFs say, and also tell us how many open tickets there are per priority. Design the knowledge sources and say how a skill should search them. None of the project's files are in this directory: write the files in your answer.",
"expected_output": "Writes two `knowledge_source` items, one per corpus (articles, tickets), each `source: { kind: 'object', … }` with an explicit `content` list of long free-text fields only: `title` / `body` for articles, `subject` / `description` for tickets. `priority`, `status` and `amount` are not in `content` (at most `metadataFields`), and the count of open tickets per priority is answered by a record tool (`aggregate_records` / `query_records`), not by `search_knowledge`. The PDF is not indexed from the `contract_pdf` file field and no `kind: 'file'` or `'http'` source is written (both retired): the extracted text is first written to a text field on the record (a `textarea`, filled by a flow, hook or import) and that field is listed in `content`. The skill's `instructions` tell the model which source to search by passing `sourceIds` to `search_knowledge`, so a question does not scan every source; no second argument shape and no `knowledge` key on the skill is invented.",
"files": [],
"assertions": {
"must_contain": ["sourceIds", "content:", "textarea"],
"must_contain_any": [["aggregate_records", "query_records", "aggregate_data"]],
"must_not_contain": ["kind: 'file',", "kind: \"file\",", "kind: 'http',", "kind: \"http\",", "contentFields:", "content: ['priority'", "content: ['status'", "content: ['amount'", "content: ['contract_pdf'", "'description', 'priority'", "'description', 'status'", "'description', 'amount'", "'description', 'contract_pdf'"]
}
}
]
}
Loading