AI agents — declare tools, model and prompt
The two platform agents (ask and build), how skills extend them, and the shape of an AgentSchema record
Part of the AI module. In the open edition, agents, tools, and
skills are typed metadata. You author skills (defineSkill) — agents are
platform-owned and tool records are optional (see below) — from the open
@objectstack/spec/ai package, and an
external AI client (Claude, Cursor, a local model — any MCP client) reaches your
objects, queries, and business Actions through @objectstack/mcp (BYO-AI),
all governed by RLS. This page describes that metadata and the AgentSchema it
validates against. Like the rest of your metadata, you don't hand-write agents —
Claude Code authors them from the objectstack-ai skill; you
os validate and test the tools in the Console
(the loop).
ObjectOS — the in-product chat runtime. The authoring format on
this page is open. The in-product chat runtime that runs agents for end users —
the two platform agents ask and build, all in-product chat, and the
/api/v1/ai/* chat endpoints — ships in ObjectOS, not in the open-source
framework, which uses @objectstack/mcp (BYO-AI) instead. The next two sections
describe that ObjectOS runtime.
Per ADR-0063 the ObjectOS runtime ships exactly two platform agents, bound by the surface the user is in — the user never picks from a roster:
| Agent | Surface | Does | Edition |
|---|---|---|---|
ask | data console | Read / query / explore records + run the business actions the app exposes. RLS-bounded. | ObjectOS |
build | Studio | Author metadata (objects, fields, views, flows) via plan → draft → verify → publish. | ObjectOS |
Within the ObjectOS runtime there is no per-turn intent classifier and
no agent dropdown: the surface binds the agent (data console → ask, Studio →
build). A build-shaped request that reaches ask is declined and redirected to
the Builder, never silently re-routed. (For data query and source-mode authoring,
the open edition ships neither agent and uses @objectstack/mcp (BYO-AI)
instead — see the callout in the AI Overview.)
Connect your AI (BYO-AI over MCP)
Step-by-step client setup (Claude Code, Claude Desktop, .mcp.json, API keys)
with verification and troubleshooting lives in
Connect an MCP Client. The summary below covers the
architecture.
Every deployment serves MCP at /api/v1/mcp by default (a core platform
capability — set OS_MCP_SERVER_ENABLED=false to opt out), with two
authentication tracks: The in-product entry point is the
Connect an AI Assistant page: per-client connect snippets, the portable
SKILL.md download (GET /api/v1/mcp/skill), and API-key minting.
- OAuth 2.1 (interactive clients — recommended). Each deployment is its
own spec-compliant authorization server: the endpoint publishes
.well-known/oauth-protected-resource/.well-known/oauth-authorization-serverdiscovery metadata, clients self-register via Dynamic Client Registration (RFC 7591) and run an authorization-code + PKCE flow. Nothing is pre-registered with Anthropic or any central service, so self-hosted and private deployments work out of the box. You authorize the client in the browser; it then acts as an agent on your behalf (principalKind: 'agent'), its data access bounded by the intersection of the consent scopes and your own permissions/RLS — it can never exceed either. The agent acts in one organization: the one you had selected when you consented, carried in the token as itsorganization_idclaim. Your grants scoped to that organization count for it; grants scoped to your other organizations do not (select the other organization and authorize the client again to work there). Your membership is re-checked on every request by the rule a browser session's organization gets: under an organization wall (isolatedorgrouptenancy) a token whose organization you no longer belong to falls back to no organization, so only your global grants apply — underisolated, a former member's agent gets an empty200on reads and a refusal on writes to organization data. Undersingle(no wall) the organization stands as consented, as a session's does. A token issued before consents carried an organization holds your global grants only until you re-confirm the consent once. For object CRUD the consent scopes (data:read,data:write) are a real ceiling, not just a tool-family filter: they narrow the exposed tools and cap what the agent can do at the data layer — adata:readtoken can never write a record even where you could. Business actions are gated differently (#2849):actions:execute+ the action's declared capabilities decide which actions the agent may invoke, and only actions the app author explicitly exposed to AI (ai: { exposed: true }) are invokable at all — but an invoked action's body runs as trusted application code with the app's full data authority, not under the agent's data ceiling. The author's AI opt-in, not the data layer, is the boundary for what actions can do. - API key (headless). Mint a key (
POST /api/v1/keys, shown once) and send it asx-api-key— for CI, scripts, and agents without a browser. - AI service account (unattended). When an agent runs on its own, not
on your behalf, give it its own identity instead of your key. An
organization administrator (or a platform administrator) registers one
(Setup → Users → Register AI Service Account, or
POST /api/v1/auth/service-account/registerwithnameand an optionalownerId): a user of kindagent, a plain member of the active organization, accountable to a named person who is a member there (the caller by default). Its name carries its purpose. It never signs in: it has no password and no session, and its email is a placeholder that is never delivered. Its owner, or an administrator of its organization, mints its key (Create API Key on the account, orPOST /api/v1/auth/service-account/create-keywithuserId), shown once, bound to the account's organization and under the same expiry ceiling as any key. The key acts as the account: only the grants given to the account count, an account never holds administrator standing, and the agent ceiling clears View All, Modify All and the other elevated permissions from whatever sets it is given. Both doors take a signed-in session only, so a key — the account's own included — can neither register an account nor mint one's key. An account is never counted as one of the administrators that keep an organization manageable, and never receives administrator mail. A flow that runs as the system (runAs: 'system') writes past the account's grants, so an account starts one only through an action whose author opted it into AI (ai: { exposed: true }), run overPOST /api/v1/actions/...or the MCPrun_actiontool. The flow's trigger route and a declaredtype: 'flow'endpoint refuse it 403PERMISSION_DENIED, and the refusal names the declaration to add (see Run a flow via API). A flow that runs as the user, the default, it starts at every door under its own grants. Its lifecycle has doors of its own, each taking a signed-in session only (POST /api/v1/auth/service-account/<door>):suspend(its owner or an administrator) stops every key on its next call, without revoking any;resume(an administrator only, so an owner cannot undo an administrator's stop) lets the same keys work again. A ban a platform administrator placed only a platform administrator lifts.revoke-keyandrestore-key(its owner or an administrator) stop or restart one key and leave its others alone. A platform administrator's revoke can be restored only by a platform administrator.set-owner(an administrator) names another member as the accountable owner. When the owner leaves the organization, the account is suspended, and it is not resumed until an administrator names a new owner. When the organization's directory (SCIM) deactivates or deletes the owner, the account is suspended too, a re-activation of the owner does not resume it, andresumerefuses until the owner is re-activated or a new owner is named.retire(an administrator) ends its membership and revokes every key for good; the account's record stays, so what it wrote still names it.
Per client:
| Client | How to connect |
|---|---|
| Claude Code | os mcp connect registers your ObjectOS Cloud environment; os mcp connect --url <base> registers a self-hosted or local server as objectstack. Without the CLI: claude mcp add --transport http objectstack https://<your-deployment>/api/v1/mcp. Either way a browser login opens on first use. Headless alternative: add --header "x-api-key: osk_..." to the claude mcp add line (os mcp connect stores no token). |
| Claude Desktop | Settings → Connectors → Add custom connector → paste the MCP URL → sign in when prompted. Connects from Anthropic's servers — needs public HTTPS (see below). |
| claude.ai (web) | Settings → Connectors → Add custom connector → paste the MCP URL. Connects from Anthropic's servers — needs public HTTPS (see below). |
| Other MCP clients | Any client implementing MCP authorization discovers the flow automatically; header-based clients can send the API key instead. |
Private / intranet deployments. OAuth requires HTTPS (localhost is
exempt, per OAuth 2.1). What decides reach is where the connection is made
from, not whether the client application runs on your machine. Claude
Code (claude mcp add, or the plugin) dials the endpoint from your own
machine, so it reaches an intranet-only deployment (an internal CA works).
claude.ai and Claude Desktop both go through the same claude.ai
custom-connector system, which connects from Anthropic's servers:
Anthropic's custom-connector documentation requires the MCP server to be
reachable over the public internet from Anthropic's IP ranges, and states that
a server on a private corporate network, behind a VPN, or blocked by a firewall
will not connect — a locally trusted certificate does not change that. So an
intranet deployment is connected through the Claude Code track; Add custom
connector is not a second door to it — a network fact, not a platform switch.
On a plain-HTTP non-localhost deployment the OAuth track stays dark and the
endpoint is API-key-only, fail-closed.
You extend the platform with skills, not agents
"Agent skill" ≠ "authoring skill." The *.skill.ts / defineSkill files
here are agent skills — runtime capability bundles the ask / build
agents consume. They are a different thing from the SKILL.md authoring
skills on the AI Skills System page, which teach a coding
assistant to write your metadata and never run. Same word, two layers.
*.agent.ts is closed to third parties — the agent metadata type is
allowRuntimeCreate:false, allowEnvironmentOverlay:false, reserved for the two platform
agents and platform-owned subagents (ADR-0063 §2). To give the ask agent a new
capability you author an agent skill (*.skill.ts). Every skill declares
surface: 'ask' | 'build' | 'both', and an agent's tool set is the union of its
surface-compatible skills' tools — there is no global fall-through, so a skill
reaches an agent only when their surfaces match
(ADR-0064).
os validate warns if a stack declares an agent (agent-authoring-withdrawn).
A skill needs no tool records — name the Action
Per ADR-0109
the default path declares zero defineTool records. The runtime already
materialises one action_<name> tool per AI-exposed Action, so a skill names
that tool directly. The Action is the same one your UI button runs, so
permissions, validation and audit are identical whether a human clicks or the
assistant calls:
import { defineAction } from '@objectstack/spec/ui';
import { defineSkill } from '@objectstack/spec/ai';
// 1. The Action you already have — opt it in to AI.
export const ConvertLeadAction = defineAction({
name: 'convert_lead',
label: 'Convert Lead',
objectName: 'crm_lead',
type: 'flow', // headless: script | api | flow
target: 'lead_conversion_flow',
ai: {
exposed: true, // ADR-0011 — opt-in, default off
description: 'Converts a qualified lead into an account, contact and opportunity.',
},
});
// 2. The skill names its materialised tool. No defineTool anywhere.
export const LeadQualificationSkill = defineSkill({
name: 'lead_qualification',
label: 'Lead Qualification',
surface: 'ask',
instructions: `Score the lead with BANT from what you read, then convert it
when the user agrees. Scoring is your judgement — there is no scoring tool.`,
tools: ['get_record', 'query_records', 'action_convert_lead'],
});Three things decide whether action_<name> exists, and os validate checks
all three (ai-skill-tool-unresolved):
| Requirement | Why |
|---|---|
ai.exposed: true + ai.description (≥40 chars) | ADR-0011 governance gate — AI reach is opt-in, and the description is the LLM's contract |
type is script / api / flow | url / modal / form are UI-only: they have no headless path, so they stay human-driven by design |
a target (or a body, for script) | something has to dispatch |
A modal Action is not a gap to fix. When the operation should collect input
from a person — an escalation reason, a refund amount — leave it modal and have
the skill's instructions recommend the button instead of calling it.
The other tools a skill may name are the platform ones the runtime
registers (describe_object, query_records, aggregate_data,
search_knowledge, visualize_data, …). Between those and your Actions, most
skills need nothing else: "analyse the pipeline", "draft this email" and "score
this lead" are reasoning the model does with data — writing them as tool
names is the most common authoring mistake, and produces an assistant that
claims abilities it does not have.
A defineTool record is an optional refinement layer, not a required step
— reach for one only when the AI-facing surface must differ from the Action
itself (a different LLM-facing description, fewer exposed parameters).
A skill has two halves, and they run in different places
| Half | Keys | Where it runs |
|---|---|---|
| Judgment | instructions, mcpPrompt | Both editions. On the open framework @objectstack/mcp serves it as an MCP prompt — a connected client can prompts/list it by name and prompts/get the text (Connect an MCP client), on a server that serves the tools the skill binds (below), unless the skill sets mcpPrompt: false. On ObjectOS it is injected into the active agent's system prompt. |
| Wiring | tools, surface, triggerConditions | Bound on ObjectOS only. Composing an agent's tool set and deciding when a skill activates are properties of an in-product agent loop. Over MCP the model lives in the client and drives one flat tool list, and your AI-exposed Actions already reach it through list_actions / run_action. surface and triggerConditions are inert there; tools is read, and decides whether the skill is offered. |
Over MCP, tools decides whether the skill is offered. The prompt surface
registerSkillPrompts (@objectstack/mcp) installs lists and gets a skill only
when the server it is installed on lists every tool the skill binds, read from
that server's own tool list when the prompt request is answered. A plain name is
served by a tool of that name, a trailing wildcard (describe_*) by any listed
tool it matches, and an action_<name> entry (or action_*) also by
run_action. A skill that binds no tool is offered as before, and prompts/get
answers a withheld skill as it answers an unknown prompt name. This holds on the
HTTP endpoint and on any host that drives its own MCP server and calls
registerSkillPrompts, stdio included; the plugin's own long-lived stdio
server, which projects skills through MCPServerRuntime.bridgePrompts instead,
applies no such filter. So bind a skill only to tools its intended connections
serve: one that names a tool no MCP tool family serves is offered on no such
connection unless a host registers that tool.
A skill written only for the in-product agents opts out of MCP with
mcpPrompt: false. Its instructions may assume the in-product tool set or
the in-product approval card even when every tool it binds is one MCP serves
too. With mcpPrompt: false the skill is never listed by prompts/list and is
unknown to prompts/get, on every MCP connection, stdio included, whatever its
tools. The stdio server takes its list once, at boot: a skill switched to
false while it runs stays listed until restart, but prompts/get answers it
as unknown at once.
Absent or true, it is offered as described above. ObjectOS reads the
skill exactly as before: the key decides MCP projection and nothing else
(Connect an MCP client).
Both halves are still validated everywhere — a skill naming a tool that does not exist is an authoring error in either distribution. So a skill written against the open framework keeps its full meaning when the app runs on ObjectOS; nothing is authored twice.
The shape of an agent
An agent is typed metadata validated by AgentSchema — exported, together with the
defineAgent factory, from the open @objectstack/spec/ai package (the platform's
own ask / build records use exactly these fields):
| Field | Meaning |
|---|---|
surface | 'ask' | 'build' — the product surface this agent binds (ADR-0063 §1) |
role | Free-text persona string (e.g. "Senior Support Engineer") — not an enum |
instructions | System prompt / prime directives |
model | Provider + model config (provider: openai | azure_openai | anthropic | local) |
skills | Skill names to attach (the primary Agent → Skill → Tool capability model) |
tools | Removed in protocol 17 (#3894) — typed never, so writing it fails tsc, and a value that reaches the runtime is rejected at parse. This is not a rename: there is no key the value moves to. Declare each tool on a skill instead — a platform tool by its registered name, or action_<name> for one of your own AI-exposed Actions — and attach that skill through skills (ADR-0064) |
knowledge | Removed in protocol 17 (#3896) — typed never, so writing it fails tsc, and a value that reaches the runtime is rejected at parse. Declaring sources / indexes here never scoped retrieval: search_knowledge takes sourceIds from the LLM's own tool-call arguments, not from the agent record, so an author who “scoped” access here scoped nothing. This is not a rename: there is no key the value moves to — delete the block. Restrict retrieval at the knowledge-service / source level (per-source permissions), and describe intended grounding in instructions so the model asks for the right sources |
There is no type field and no fixed agent "type" taxonomy — behaviour comes from
persona, instructions, skills, and tools. There are no triggers / schedule
fields on an agent; drive agents from Flows/Workflows, or — on
the ObjectOS runtime — via the in-product chat endpoint
(/api/v1/ai/*). On the open-source framework, invoke the underlying Actions/Flows through
@objectstack/mcp.
An agent has no tool slot of its own. Its tool set is exactly the union of
its surface-compatible skills' tools, with no fall-through to the global
registry (ADR-0064).
The removed tools key was the one seam that broke that invariant: the runtime
resolved agent.tools[].name against the full registry with no surface
check, so an ask-surface agent could name an authoring tool and reach it. So
there is nowhere on the agent to move a reference to — re-declare each one
in a skill's tools by hand, then attach the skill. See
Actions as Tools for how an Action becomes
LLM-callable.
The agent definitions below illustrate agent anatomy — how an AgentSchema
record is shaped (that schema and the defineAgent factory are part of the open
@objectstack/spec/ai package). Note that the agent metadata type is
allowRuntimeCreate:false / allowEnvironmentOverlay:false (ADR-0063 §2): the cloud /
Enterprise in-product runtime honors only the two platform agents ask and
build, so you do not ship a custom agent to that runtime — you extend it by
authoring a skill (open metadata) that attaches to ask. In the open edition,
express the same capability as Actions / Flows plus the skills/tools its references
point at, and reach it through @objectstack/mcp (BYO-AI).
Sales Assistant Agent
import { defineAgent } from '@objectstack/spec/ai';
export const SalesAssistantAgent = defineAgent({
name: 'sales_assistant',
label: 'Sales Assistant',
role: 'Sales Development Assistant',
instructions: `You are a sales assistant AI.
Your responsibilities:
1. Qualify incoming leads (BANT criteria)
2. Suggest next best actions
3. Draft personalized emails
4. Analyze win/loss patterns
Always be professional and data-driven.`,
model: {
provider: 'openai',
model: 'gpt-4',
temperature: 0.7,
maxTokens: 2000,
},
// Capability comes from skills — the only tool-bearing slot (ADR-0064).
// Each skill names the platform tools and `action_<name>` tools it needs.
// (There is no agent-level `knowledge` block — it was removed in protocol
// 17 (#3896 close-out): declaring sources never scoped retrieval. Restrict
// access at the knowledge-service/source level; describe intended
// grounding in `instructions`.)
skills: ['lead_qualification', 'opportunity_coaching', 'email_drafting'],
});Customer Service Agent
export const ServiceAgent = defineAgent({
name: 'service_agent',
label: 'Customer Service Agent',
role: 'Customer Service Specialist',
instructions: `You are a customer service AI agent.
Your responsibilities:
1. Triage incoming cases
2. Suggest relevant knowledge articles
3. Draft response templates
4. Escalate critical issues
Always be empathetic and solution-focused.`,
model: {
provider: 'openai',
model: 'gpt-4',
temperature: 0.5,
maxTokens: 1500,
},
// Skills carry the tools. `case_triage` names the platform data tools it
// reads with; `knowledge_search` names `search_knowledge` (Knowledge
// Protocol). Neither needs a `defineTool` record.
skills: ['case_triage', 'knowledge_search', 'response_drafting'],
});Lead Enrichment Agent
export const LeadEnrichmentAgent = defineAgent({
name: 'lead_enrichment',
label: 'Lead Enrichment Agent',
role: 'Data Enrichment Worker',
instructions: `You enrich lead records with additional data.
Tasks:
1. Look up company information
2. Enrich contact details
3. Add firmographic data
4. Research technology stack
Use reputable data sources.`,
model: {
provider: 'openai',
model: 'gpt-3.5-turbo',
temperature: 0.3,
maxTokens: 1000,
},
// The enrichment Flows are exposed with `ai.exposed`, so the runtime
// materialises `action_lookup_company` / `action_enrich_contact` for the
// skill to name.
skills: ['contact_enrichment'],
});To run enrichment when a lead is created or on a schedule, trigger this agent
from a Flow or Workflow — agents themselves carry no
triggers/schedule fields.
Revenue Intelligence Agent
export const RevenueIntelligenceAgent = defineAgent({
name: 'revenue_intelligence',
label: 'Revenue Intelligence Agent',
role: 'Revenue Operations Analyst',
instructions: `You analyze sales data and provide insights.
Responsibilities:
1. Analyze pipeline health
2. Identify at-risk deals
3. Summarize trends
4. Generate executive summaries
Use the data tools to query records and aggregate metrics.`,
model: {
provider: 'openai',
model: 'gpt-4',
temperature: 0.2,
maxTokens: 3000,
},
// Pipeline analysis is reasoning over the platform's own data tools
// (query_records / aggregate_data / visualize_data), which the skill
// names directly — see "Natural Language Queries".
skills: ['revenue_forecasting'],
});