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
26 changes: 26 additions & 0 deletions .changeset/37217-skill-ask-ai-action.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'@objectstack/skills': patch
---

docs(skills): `objectstack-ai` teaches the `ask_ai` action — the **Ask AI** button on a record

Clause-②: no
Metadata-protocol: none

`skills/objectstack-ai/SKILL.md`, a new subsection *The Ask AI button — `type: 'ask_ai'`* under *Actions as AI Tools*:

- What the action does: it pins the assistant's conversation to the record it runs on and opens the assistant, sending no message; it is declared on the object in `locations: ['record_header']` or `['record_more']`, with a `defineAction` example that type-checks against the spec.
- What the parse refuses beside it: a `target`, `ai.exposed: true`, and `actionType: 'ask_ai'` on a dashboard header (a header runs on no record).
- That nothing serves it headless: `list_actions` skips it, `run_action` refuses it, and no `action_` tool exists for it.
- Where it is absent rather than disabled: the console draws it only where the assistant surface is on and the AI service honours a conversation focus.

Paid for by deleting restatement in the same file, with the token ceiling unchanged (6801; the file now measures 6787):

- the *App AI Blueprint* table (its first two rows restate *Skill Configuration* and the `KnowledgeServicePlugin` wiring; its third row's claim that `agents` / `tools` / `skills` are the only AI stack collections was stale, since `aiContexts` is a `defineStack` key too);
- the alias sentence under *Platform agents* (`data_chat` / `metadata_assistant` for old bookmarks: the agent type is closed to third parties, so no author writes either);
- the pointer to `references/_index.md` for `AgentSchema` (the *References* section already points there);
- the rung-2 sentence "Read that file for the exact set" (the sentence before it names the file);
- the two product-analogy parentheticals beside `ask` and `build`;
- the memory clause of pitfall 1, kept to its two facts (the required keys and that there is no storage backend to choose).

`evals/skills-tools-knowledge.json`: a new case 10 asks for an Ask AI button on the contract record page; the expected answer is a `type: 'ask_ai'` action in `record_header` with no `target` and no `ai.exposed: true`; its `must_not_contain` holds only `target:`, a token a correct answer never carries. Case 9's reference answer no longer spells the `chunkSize` token it forbids (it says "no chunk-size key"), so the reference passes its own grader; the assertions are unchanged.
57 changes: 34 additions & 23 deletions skills/objectstack-ai/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ A `skill.tools[]` entry resolves against the union of four sources
tools, flattened from `PLATFORM_TOOLS_BY_PACKAGE` in
`packages/spec/src/system/constants/platform-tool-names.ts`: data /
knowledge tools from `service-ai`, schema / metadata / package tools from
`service-ai-studio`. Read that file for the exact set: it is the registry
the lint rule checks against.
`service-ai-studio`.
3. **`action_<name>`** — one tool per AI-exposed Action of your own stack
(`PLATFORM_TOOL_FAMILY_PREFIXES`). **The default path** for anything your app
does.
Expand Down Expand Up @@ -179,6 +178,32 @@ decided entirely by the skip rule above — `actionSkipReason(action, ctx)` and
`actionRequiresApproval(action)` (from `@objectstack/service-ai`) answer both
questions, and Studio's "AI exposure" diagnostics use the same predicates.

### The **Ask AI** button — `type: 'ask_ai'` ☁️

Pins the assistant's conversation to the record the action runs on and opens
it, sending no message. Declare it on the object, in
`locations: ['record_header']` or `['record_more']`:

<!-- os:check -->
```typescript
import { defineAction } from '@objectstack/spec';

export default defineAction({
name: 'ask_about_contract',
label: 'Ask AI',
objectName: 'contract',
type: 'ask_ai',
locations: ['record_header'],
});
```

It names nothing and is never a tool: the parse refuses a `target`,
`ai.exposed: true`, and `actionType: 'ask_ai'` on a dashboard header (a header
runs on no record). Nothing serves it headless: `list_actions` skips it,
`run_action` refuses it, and no `action_` tool exists for it. The console draws
it only where the assistant surface is on **and** the AI service honours a
conversation focus; elsewhere it is absent, not disabled.

---

## MCP — the open-edition AI path
Expand Down Expand Up @@ -350,9 +375,9 @@ there is **no top-level `temperature` / `maxTokens`** on an agent
1. **Mistaking `guardrails` for a gate.** `guardrails` is enforced per user turn
by the AI runtime ☁️ — token and time limits, blocked tool names and categories
refused — but it is a limit, not an approval; `memory` is enforced by the AI
runtime ☁️ too — long-term notes are recalled and reflected on, `maxEntries`
and `reflectionInterval` are required once `longTerm.enabled` is true, and
there is no storage backend to choose — and neither is a gate. For a gate
runtime ☁️ too (`maxEntries` and `reflectionInterval` are required once
`longTerm.enabled` is true; there is no storage backend to choose), and is
no gate either. For a gate
that is **enforced**, use
`enableActionApproval: true` (approval queue ☁️), `ai.requiresConfirmation` on
the **action** (its door only, pitfall 2), or `approval: 'always'` on an MCP
Expand All @@ -378,37 +403,23 @@ there is **no top-level `temperature` / `maxTokens`** on an agent

---

## App AI Blueprint

| Layer | File | Pattern |
|:--|:--|:--|
| Reusable skill | `src/skills/lead-qualification.skill.ts` | `defineSkill` — `instructions` + trigger conditions + a toolset where every name resolves; pick a `surface` |
| Knowledge source | `src/knowledge/sales-kb.ts` | `KnowledgeSourceSchema` metadata, registered at boot via `KnowledgeServicePlugin({ sources })` |
| Central registration | `defineStack({ skills: [...] })` | `agents` / `tools` / `skills` are the only AI stack collections |

---

## Platform agents — reference only ☁️

The `agent` type is **closed** to third parties (`allowRuntimeCreate:false`,
`allowEnvironmentOverlay:false`; ADR-0063 §2) and `os g agent` is retired: a
stack-authored agent is filtered out of `listAgents()`, refused outright by
`loadAgent()`, and 404s on chat. `AgentSchema`'s full field list is in
[references/_index.md](./references/_index.md).
`loadAgent()`, and 404s on chat.

The runtime ships **exactly two** agents, bound by *surface*. **`ask`** is the
data product (≈ Claude Chat): conversational read / query / explore over records
data product: conversational read / query / explore over records
plus running the business actions the app exposes, end-user audience,
RLS-bounded, canonical id `ask` (`ASK_AGENT_NAME`), and the implicit copilot for
any app that does not pin `app.defaultAgent`. **`build`** is the authoring
product (≈ Claude Code): agentic authoring of *metadata* through plan → draft →
product: agentic authoring of *metadata* through plan → draft →
verify → publish, builder audience, governance-gated, pinned by Studio via
`app.defaultAgent`. There is **no per-turn intent classifier** — a `build`-shaped
request arriving at `ask` is declined and redirected, never silently re-routed
into authoring (ADR-0063 §1/§5). `data_chat`→`ask` and
`metadata_assistant`→`build` resolve through the alias table for old bookmarks
and persisted `agent_id`s; they are **not** vocabulary — always write `ask` /
`build`.
into authoring (ADR-0063 §1/§5).

An agent's tool set is the **union of its surface-compatible skills' tools** —
there is no global fall-through (ADR-0064), so `ask` cannot author by
Expand Down
12 changes: 11 additions & 1 deletion skills/objectstack-ai/evals/skills-tools-knowledge.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,22 @@
{
"id": 9,
"prompt": "Index our `policy_doc` records (`title`, `body`) for the assistant with the in-memory adapter. Each body is a long Markdown handbook with headings; answers should cite one section, at most 600 characters, and neighbouring passages should overlap by 100 characters.",
"expected_output": "Emits a `KnowledgeSourceSchema.parse({...})` record with `adapter: 'memory'` (the adapter that takes the service's passages) and `source: { kind: 'object', object: 'policy_doc', contentFields: ['title', 'body'], split: { strategy: 'markdown', maxChars: 600 } }`: one section per heading, each passage embedded with its heading path, 600 characters at most unless the embedder's input limit is lower. Declines the overlap: passages never overlap, and the `knowledge.chunk_overlap` setting is retired (a write naming it is refused `400 UNKNOWN_KEY`), so it writes no overlap key and no `chunkSize`.",
"expected_output": "Emits a `KnowledgeSourceSchema.parse({...})` record with `adapter: 'memory'` (the adapter that takes the service's passages) and `source: { kind: 'object', object: 'policy_doc', contentFields: ['title', 'body'], split: { strategy: 'markdown', maxChars: 600 } }`: one section per heading, each passage embedded with its heading path, 600 characters at most unless the embedder's input limit is lower. Declines the overlap: passages never overlap, and the `knowledge.chunk_overlap` setting is retired (a write naming it is refused `400 UNKNOWN_KEY`), so it writes no overlap key and no chunk-size key.",
"files": [],
"assertions": {
"must_contain": ["split", "strategy", "markdown", "maxChars"],
"must_not_contain": ["chunkSize", "chunkOverlap", "overlap: 100"]
}
},
{
"id": 10,
"prompt": "Add an Ask AI button to the contract record page, so a user can ask the assistant about the contract they are looking at. Write the action.",
"expected_output": "Emits a `defineAction` with `type: 'ask_ai'`, `objectName: 'contract'` and `locations: ['record_header']` (or `['record_more']`), with no `target` and no `ai.exposed: true`: the action pins the assistant's conversation to the record and opens it, sending no message. States that it is never a tool (`list_actions` skips it, `run_action` refuses it, no `action_` tool exists for it) and that the console draws it only where the in-app assistant is on and honours a conversation focus; elsewhere it is absent, not disabled.",
"files": [],
"assertions": {
"must_contain": ["ask_ai", "record_header", "locations"],
"must_not_contain": ["target:"]
}
}
]
}
Loading