From 01f29dff3a42580dcf80905d44cb3ade26155a93 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 02:48:39 +0000 Subject: [PATCH 1/4] =?UTF-8?q?feat(spec)!:=20retire=20an=20agent's=20mode?= =?UTF-8?q?l.provider=20=E2=80=94=20no=20runtime=20read=20it;=20the=20depl?= =?UTF-8?q?oyment's=20AI=20settings=20choose=20the=20provider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ADR-0049 enforce-or-remove. `AIModelConfigSchema.provider` (openai / azure_openai / anthropic / local) was parsed and never read: the AI runtime applies the model name, temperature and maxTokens only, and the providers a deployment turns on are its own AI settings, a list the enum never matched. - retiredKey() tombstone with the prescription; the 18.x emitted default `openai` is stripped as residue (acceptRetiredDefaultResidue) - D2 conversion agent-model-provider-removed (step 19, lossless, retired from the load path), RETIRED_KEYS_BY_MAJOR[19] entry, D3 semantic entry agent-model-provider-retired, step-19 rationale - liveness ledger note, authorable-surface + reference docs regenerated, agent form help text and its 11 locale bundles, removal-version JOIN row - agent metadata preview shows the model name only - docs, CLI explain, benchmark and test fixtures stop authoring the key - pin suite with a tree-scoped absence walk (radius declared in vitest.repo-tests.json) Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgTnm6d4W7ugSacDJ3j --- .../37712-agent-model-provider-retired.md | 30 ++ content/docs/ai/agents.mdx | 6 +- .../docs/getting-started/common-patterns.mdx | 1 - content/docs/references/ai/agent.mdx | 6 +- docs/notes/crm-development-standards.mdx | 1 - packages/cli/src/commands/explain.ts | 4 +- .../src/metadata-validation-sweep.test.ts | 2 +- .../ar.metadata-forms.generated.ts | 2 +- .../de.metadata-forms.generated.ts | 2 +- .../en.metadata-forms.generated.ts | 2 +- .../es-ES.metadata-forms.generated.ts | 2 +- .../fr.metadata-forms.generated.ts | 2 +- .../ja-JP.metadata-forms.generated.ts | 2 +- .../ko.metadata-forms.generated.ts | 2 +- .../pt-BR.metadata-forms.generated.ts | 2 +- .../ru.metadata-forms.generated.ts | 2 +- .../zh-CN.metadata-forms.generated.ts | 2 +- .../zh-Hant.metadata-forms.generated.ts | 2 +- packages/spec/authorable-surface/ai.json | 2 +- packages/spec/docs/MCP_GUIDE.md | 1 - packages/spec/liveness/agent.json | 2 +- packages/spec/scripts/lib/default-changes.ts | 4 +- .../agent-model-provider-retirement.test.ts | 337 ++++++++++++++++++ packages/spec/src/ai/agent.form.ts | 2 +- packages/spec/src/ai/agent.test.ts | 23 +- packages/spec/src/ai/agent.zod.ts | 49 ++- packages/spec/src/benchmark.bench.ts | 1 - .../19/agent-model-provider-removed.ts | 95 +++++ packages/spec/src/conversions/registry.ts | 2 + .../19.ai__AIModelConfig__provider.ts | 12 + .../19.agent-model-provider-retired.ts | 38 ++ .../spec/src/migrations/registry.ts.template | 2 + .../src/migrations/semantic-relevance.test.ts | 6 +- .../retired-key-removal-version.pin.test.ts | 3 + packages/spec/vitest.repo-tests.json | 1 + ...AgentPreview.emptyCollection-8520.test.tsx | 2 +- .../previews/AgentPreview.test.tsx | 10 +- .../metadata-admin/previews/AgentPreview.tsx | 9 +- 38 files changed, 605 insertions(+), 68 deletions(-) create mode 100644 .changeset/37712-agent-model-provider-retired.md create mode 100644 packages/spec/src/ai/agent-model-provider-retirement.test.ts create mode 100644 packages/spec/src/conversions/entries/19/agent-model-provider-removed.ts create mode 100644 packages/spec/src/migrations/entries/retired-keys/19.ai__AIModelConfig__provider.ts create mode 100644 packages/spec/src/migrations/entries/semantic/19.agent-model-provider-retired.ts diff --git a/.changeset/37712-agent-model-provider-retired.md b/.changeset/37712-agent-model-provider-retired.md new file mode 100644 index 00000000000..4e9db898b65 --- /dev/null +++ b/.changeset/37712-agent-model-provider-retired.md @@ -0,0 +1,30 @@ +--- +'@objectstack/spec': minor +'@objectstack/cli': patch +'@objectstack/platform-objects': patch +'@object-ui/app-shell': patch +--- + +feat(spec)!: retire an agent's `model.provider` — no runtime read it; the deployment's AI settings choose the provider + +Clause-②: no (narrowing) +Metadata-protocol: narrowed +Skills-docs: follow-up owed + + + +**BREAKING** key removal on `AIModelConfigSchema` (`@objectstack/spec/ai`), an agent's `model` block. The key declared which provider served the agent, from an enum of `openai`, `azure_openai`, `anthropic` and `local`, and no runtime ever read it: the AI runtime that executes agents applies the model name, `temperature` and `maxTokens` from the block and nothing else, so an agent that declared `anthropic` ran on whatever provider the deployment served. The providers a deployment can turn on are its own AI settings, a list the enum neither matched nor could follow. + +| FROM | TO | +|:--|:--| +| `model: { provider: 'anthropic', model: 'claude-sonnet-4' }` | `model: { model: 'claude-sonnet-4' }` — the deployment resolves the name among the providers it has turned on | +| `model: { provider: 'openai' }` (a provider and no model name) | `model: {}` or no `model` block — the agent runs on the deployment's default model — or name a model the deployment offers | + +The one-line fix: delete `provider` from every agent's `model` block; `os migrate meta --from 18 --write` deletes it from agent sources. Writing it after upgrade fails `tsc` (the input type is `never`) and fails the parse with that prescription. `provider: 'openai'`, the default every released 18.x toolchain wrote into a parsed agent's `model` block, is accepted as inert residue and stripped, so agents built and stored by 18.x keep loading. The model name, `temperature`, `maxTokens` and `topP` are unchanged. + +The retirement kit: + +- **`@objectstack/spec`**: `provider` is a `retiredKey()` tombstone on `AIModelConfigSchema`, and the 18.x emitted default is stripped by `acceptRetiredDefaultResidue`. The D2 conversion `agent-model-provider-removed` (lossless, retired from the load path) deletes the key from `agents[]` on every data-at-rest seam (stored rows, built artifacts, `os migrate meta`); the D3 entry `agent-model-provider-retired` names what the upgrade still owes: whether an agent whose author wrote a provider should now name a model the deployment offers or run on its default model. The key is registered in `RETIRED_KEYS_BY_MAJOR[19]`. The liveness ledger's `model` row records the removal. The agent form's model help text no longer names a provider. +- **`@objectstack/platform-objects`**: the agent form's regenerated help-text labels. +- **`@object-ui/app-shell`**: the agent metadata preview shows the model name alone and never a provider pill. +- **`@objectstack/cli`**: `os explain agent` describes the `model` block without `provider`, and its example drops it. diff --git a/content/docs/ai/agents.mdx b/content/docs/ai/agents.mdx index ecc3562fc2d..46cfa2fa46a 100644 --- a/content/docs/ai/agents.mdx +++ b/content/docs/ai/agents.mdx @@ -306,7 +306,7 @@ own `ask` / `build` records use exactly these fields): | `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`) | +| `model` | Model config: `model` (the model name, optional — absent means the deployment's default model), `temperature`, `maxTokens`, `topP`. There is no `provider`: it was **removed in protocol 19 (#37712)** because no runtime read it — the deployment's AI settings choose the provider, and resolve the model name among the providers they turn on | | `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_` 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 | @@ -365,7 +365,6 @@ Your responsibilities: Always be professional and data-driven.`, model: { - provider: 'openai', model: 'gpt-4', temperature: 0.7, maxTokens: 2000, @@ -401,7 +400,6 @@ Your responsibilities: Always be empathetic and solution-focused.`, model: { - provider: 'openai', model: 'gpt-4', temperature: 0.5, maxTokens: 1500, @@ -434,7 +432,6 @@ Tasks: Use reputable data sources.`, model: { - provider: 'openai', model: 'gpt-3.5-turbo', temperature: 0.3, maxTokens: 1000, @@ -470,7 +467,6 @@ Responsibilities: Use the data tools to query records and aggregate metrics.`, model: { - provider: 'openai', model: 'gpt-4', temperature: 0.2, maxTokens: 3000, diff --git a/content/docs/getting-started/common-patterns.mdx b/content/docs/getting-started/common-patterns.mdx index 81f3f49cd39..14eb91c1774 100644 --- a/content/docs/getting-started/common-patterns.mdx +++ b/content/docs/getting-started/common-patterns.mdx @@ -396,7 +396,6 @@ export const supportAgent = defineAgent({ label: 'Customer Support Agent', role: 'Customer Support Agent', model: { - provider: 'openai', model: 'gpt-4o', temperature: 0.3, maxTokens: 2048 diff --git a/content/docs/references/ai/agent.mdx b/content/docs/references/ai/agent.mdx index 76be187cd41..c9d3a00b7b0 100644 --- a/content/docs/references/ai/agent.mdx +++ b/content/docs/references/ai/agent.mdx @@ -28,7 +28,7 @@ const result = AIModelConfigSchema.parse(data); | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | -| **provider** | `Enum<'openai' \| 'azure_openai' \| 'anthropic' \| 'local'>` | optional | | +| **provider** | `never` | optional | [REMOVED] `agent.model.provider` was removed in @objectstack/spec 19.0.0 (ADR-0049 enforce-or-remove) — it never had an effect: no runtime read it, and the provider that serves an agent is chosen by the deployment's AI settings, never by the agent. Delete the key. To pin a model, name it in `agent.model.model`; the deployment resolves that name among the providers it has turned on, and an agent that names no model runs on the deployment's default model. Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **model** | `string` | optional | Model name (e.g. gpt-4, claude-3-opus). Optional: when absent, the agent runs on the host's default model for this environment, so an agent that only tunes sampling (e.g. `temperature`) need not name a model. | | **temperature** | `number` | optional (default: `0.7`) | | | **maxTokens** | `number` | optional | | @@ -48,7 +48,7 @@ const result = AIModelConfigSchema.parse(data); | **avatar** | `string` | optional | | | **role** | `string` | ✅ | The persona/role (e.g. "Senior Support Engineer") | | **instructions** | `string` | ✅ | System Prompt / Prime Directives | -| **model** | `{ provider?: Enum<'openai' \| 'azure_openai' \| 'anthropic' \| 'local'>; model?: string; temperature?: number; maxTokens?: number; … }` | optional | | +| **model** | `{ model?: string; temperature?: number; maxTokens?: number; topP?: number }` | optional | | | **lifecycle** | `never` | optional | [REMOVED] `agent.lifecycle` was removed in @objectstack/spec 17.7.0 (ADR-0049 enforce-or-remove) — no runtime ever read it: no agent moved through a declared state and no transition was ever refused. Delete the key. A phase of a conversation is a skill with its own `instructions` and `tools`, selected by its `triggerConditions` (ADR-0064); multi-step process orchestration is a Flow (ADR-0019); a record's status transitions are a `state_machine` validation rule on the object (ADR-0020). Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **surface** | `Enum<'ask' \| 'build'>` | optional (default: `"ask"`) | Product surface this agent binds ('ask' \| 'build') — ADR-0063 §1 | | **skills** | `string[]` | optional | Skill names to attach (Agent→Skill→Tool architecture) | @@ -72,7 +72,7 @@ const result = AIModelConfigSchema.parse(data); | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | -| **provider** | `Enum<'openai' \| 'azure_openai' \| 'anthropic' \| 'local'>` | optional | | +| **provider** | `never` | optional | [REMOVED] `agent.model.provider` was removed in @objectstack/spec 19.0.0 (ADR-0049 enforce-or-remove) — it never had an effect: no runtime read it, and the provider that serves an agent is chosen by the deployment's AI settings, never by the agent. Delete the key. To pin a model, name it in `agent.model.model`; the deployment resolves that name among the providers it has turned on, and an agent that names no model runs on the deployment's default model. Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **model** | `string` | optional | Model name (e.g. gpt-4, claude-3-opus). Optional: when absent, the agent runs on the host's default model for this environment, so an agent that only tunes sampling (e.g. `temperature`) need not name a model. | | **temperature** | `number` | optional (default: `0.7`) | | | **maxTokens** | `number` | optional | | diff --git a/docs/notes/crm-development-standards.mdx b/docs/notes/crm-development-standards.mdx index 481a595fb49..808fe0957b0 100644 --- a/docs/notes/crm-development-standards.mdx +++ b/docs/notes/crm-development-standards.mdx @@ -370,7 +370,6 @@ export const MyAgent: Agent = { instructions: `Clear instructions for the AI...`, model: { - provider: 'openai', // 'openai' | 'azure_openai' | 'anthropic' | 'local' model: 'gpt-4', temperature: 0.7, maxTokens: 2000, diff --git a/packages/cli/src/commands/explain.ts b/packages/cli/src/commands/explain.ts index d6bc7c6b4ef..e7d3b003104 100644 --- a/packages/cli/src/commands/explain.ts +++ b/packages/cli/src/commands/explain.ts @@ -191,7 +191,7 @@ export const SCHEMAS: Record = { ], optional: [ { name: 'skills', type: 'string[]', description: 'Skill names to attach (Agent -> Skill -> Tool architecture, ADR-0064). This is where tool access comes from: a platform tool by its registered name, or `action_` for one of your own AI-exposed Actions — declared inside the skill, not here.' }, - { name: 'model', type: 'AIModelConfig', description: 'LLM configuration OBJECT — { provider, model, temperature, maxTokens, topP }. A bare model string is rejected, and model settings such as `temperature` live in HERE, never at the agent top level.' }, + { name: 'model', type: 'AIModelConfig', description: 'LLM configuration OBJECT — { model, temperature, maxTokens, topP }; `model` is optional (absent = the deployment\'s default model). A bare model string is rejected, model settings such as `temperature` live in HERE, never at the agent top level, and there is no `provider` (removed: the deployment\'s AI settings choose it).' }, { name: 'surface', type: '"ask" | "build"', description: 'Product surface this agent is for (default "ask")' }, { name: 'avatar', type: 'string', description: 'Avatar image reference' }, { name: 'access', type: 'string[]', description: 'Who can chat with this agent — enforced at the chat route' }, @@ -208,7 +208,7 @@ export const SCHEMAS: Record = { // tool inside a skill and attach the skill by name here. skills: ['knowledge_lookup'], // \`model\` is an object, and temperature belongs inside it. - model: { provider: 'openai', model: 'gpt-4o', temperature: 0.2 }, + model: { model: 'gpt-4o', temperature: 0.2 }, }`, related: ['object', 'flow', 'query'], docsPath: 'ai/agent', diff --git a/packages/objectql/src/metadata-validation-sweep.test.ts b/packages/objectql/src/metadata-validation-sweep.test.ts index cfa20e67b79..bf9498b5eaf 100644 --- a/packages/objectql/src/metadata-validation-sweep.test.ts +++ b/packages/objectql/src/metadata-validation-sweep.test.ts @@ -342,7 +342,7 @@ const FIXTURES: Record = { label: 'Sweep', role: 'Sweep test agent', instructions: 'be helpful', - model: { provider: 'openai', model: 'gpt-4o-mini' }, + model: { model: 'gpt-4o-mini' }, }, invalid: { name: 'sweep_agent', label: 'Sweep' }, invalidatedField: 'instructions', diff --git a/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts index 66184b4f84a..68040e43ae8 100644 --- a/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts @@ -3288,7 +3288,7 @@ export const arMetadataForms: NonNullable = { }, model: { label: "النموذج", - helpText: "تهيئة نموذج الذكاء الاصطناعي (المزوّد، واسم النموذج، ودرجة الحرارة، إلخ)" + helpText: "تهيئة نموذج الذكاء الاصطناعي (اسم النموذج، ودرجة الحرارة، إلخ)" }, planning: { label: "التخطيط", diff --git a/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts index 590fe6b933a..81894ea11de 100644 --- a/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts @@ -3288,7 +3288,7 @@ export const deMetadataForms: NonNullable = { }, model: { label: "Modell", - helpText: "Konfiguration des KI-Modells (Anbieter, Modellname, Temperatur usw.)" + helpText: "Konfiguration des KI-Modells (Modellname, Temperatur usw.)" }, planning: { label: "Planung", diff --git a/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts index 78ae54f05e7..4a53dfdcf53 100644 --- a/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts @@ -3288,7 +3288,7 @@ export const enMetadataForms: NonNullable = { }, model: { label: "Model", - helpText: "AI model configuration (provider, model name, temperature, etc.)" + helpText: "AI model configuration (model name, temperature, etc.)" }, planning: { label: "Planning", diff --git a/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts index f6c42f131d3..42060df995a 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts @@ -3288,7 +3288,7 @@ export const esESMetadataForms: NonNullable = }, model: { label: "Modelo", - helpText: "Configuración del modelo de IA (provider, model name, temperature, etc.)" + helpText: "Configuración del modelo de IA (model name, temperature, etc.)" }, planning: { label: "Planificación", diff --git a/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts index 6f065d97159..56c8ce3f29a 100644 --- a/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts @@ -3288,7 +3288,7 @@ export const frMetadataForms: NonNullable = { }, model: { label: "Modèle", - helpText: "Configuration du modèle d’IA (fournisseur, nom du modèle, température, etc.)" + helpText: "Configuration du modèle d’IA (nom du modèle, température, etc.)" }, planning: { label: "Planification", diff --git a/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts index bd0fdd9f105..6a3f0e0af1b 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts @@ -3288,7 +3288,7 @@ export const jaJPMetadataForms: NonNullable = }, model: { label: "モデル", - helpText: "AI モデル設定(provider, model name, temperature など)" + helpText: "AI モデル設定(model name, temperature など)" }, planning: { label: "計画", diff --git a/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts index 6c719537349..ebc10c88083 100644 --- a/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts @@ -3288,7 +3288,7 @@ export const koMetadataForms: NonNullable = { }, model: { label: "모델", - helpText: "AI 모델 구성(공급자, 모델 이름, 온도 등)" + helpText: "AI 모델 구성(모델 이름, 온도 등)" }, planning: { label: "계획", diff --git a/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts index 0f69615e1f8..c068a1f74b3 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts @@ -3288,7 +3288,7 @@ export const ptBRMetadataForms: NonNullable = }, model: { label: "Modelo", - helpText: "Configuração do modelo de IA (provedor, nome do modelo, temperatura etc.)" + helpText: "Configuração do modelo de IA (nome do modelo, temperatura etc.)" }, planning: { label: "Planejamento", diff --git a/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts index ac460729bd0..29eb976a438 100644 --- a/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts @@ -3288,7 +3288,7 @@ export const ruMetadataForms: NonNullable = { }, model: { label: "Модель", - helpText: "Настройка модели ИИ (поставщик, имя модели, температура и т. д.)" + helpText: "Настройка модели ИИ (имя модели, температура и т. д.)" }, planning: { label: "Планирование", diff --git a/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts index 3dc16113c19..cc1e9491f21 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts @@ -3288,7 +3288,7 @@ export const zhCNMetadataForms: NonNullable = }, model: { label: "模型", - helpText: "AI 模型配置(提供方、模型名、温度等)" + helpText: "AI 模型配置(模型名、温度等)" }, planning: { label: "规划", diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts index 2f00ab6a459..a3390dd8dc0 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts @@ -3288,7 +3288,7 @@ export const zhHantMetadataForms: NonNullable }, model: { label: "模型", - helpText: "AI 模型設定(提供方、模型名、溫度等)" + helpText: "AI 模型設定(模型名、溫度等)" }, planning: { label: "規劃", diff --git a/packages/spec/authorable-surface/ai.json b/packages/spec/authorable-surface/ai.json index fdf15d10f84..0300eb7a121 100644 --- a/packages/spec/authorable-surface/ai.json +++ b/packages/spec/authorable-surface/ai.json @@ -4,7 +4,7 @@ "keys": [ "ai/AIModelConfig:maxTokens", "ai/AIModelConfig:model", - "ai/AIModelConfig:provider", + "ai/AIModelConfig:provider [RETIRED]", "ai/AIModelConfig:temperature", "ai/AIModelConfig:topP", "ai/AIUsageRecord:costUsd", diff --git a/packages/spec/docs/MCP_GUIDE.md b/packages/spec/docs/MCP_GUIDE.md index ed1807b3e1a..3e9f8d519fa 100644 --- a/packages/spec/docs/MCP_GUIDE.md +++ b/packages/spec/docs/MCP_GUIDE.md @@ -307,7 +307,6 @@ export const salesAgent = AgentSchema.parse({ instructions: 'You help sales team with customer data and pipeline management.', model: { - provider: 'openai', model: 'gpt-4-turbo', temperature: 0.3, }, diff --git a/packages/spec/liveness/agent.json b/packages/spec/liveness/agent.json index bc72a65c737..c40ad90cedf 100644 --- a/packages/spec/liveness/agent.json +++ b/packages/spec/liveness/agent.json @@ -42,7 +42,7 @@ "verifiedAt": "2026-09-15", "evidenceScope": "cross-repo", "evidence": "cloud @cb8ee7ff: packages/service-ai/src/agent-runtime.ts#buildRequestOptions — applies model, temperature and maxTokens onto AIRequestOptions; model.provider and topP have no reader anywhere in cloud.", - "note": "PARTIAL — model/temperature/maxTokens applied; model.provider + topP DEAD." + "note": "PARTIAL — model/temperature/maxTokens applied; topP DEAD. model.provider REMOVED 2026-11-27 (#37712) — tombstoned at the schema (retiredKey carries the prescription; authoring it is a tsc error and a parse error, the 18.x emitted default `openai` is stripped as residue) and stripped from sources by the protocol-19 conversion `agent-model-provider-removed`. A nested key has no row of its own, so this container row carries it; the provider is the deployment's AI settings." }, "skills": { "status": "live", diff --git a/packages/spec/scripts/lib/default-changes.ts b/packages/spec/scripts/lib/default-changes.ts index c831504cf0b..fc37c42842c 100644 --- a/packages/spec/scripts/lib/default-changes.ts +++ b/packages/spec/scripts/lib/default-changes.ts @@ -811,7 +811,9 @@ export const DEFAULT_CHANGES_BY_MAJOR: Readonly) => { + let thrown: unknown; + try { + defineStack({ + manifest: { id: 'com.example.agent-model', name: 'agent_model', version: '1.0.0', type: 'app' }, + agents: [agent], + } as never); + } catch (e) { + thrown = e; + } + return thrown as { code?: string; status?: number; issues?: Array<{ path: PropertyKey[]; message: string }> }; +}; + +describe('agent model provider retirement — the tombstone, at every door that carries an agent', () => { + it('refuses every value an author could have written at its path with the prescription', () => { + for (const provider of ['anthropic', 'azure_openai', 'local', 'google', {}, null, 0]) { + const r = AgentSchema.safeParse({ ...MODEL_AGENT, model: { provider, model: 'gpt-4o' } }); + expect(r.success, `provider: ${JSON.stringify(provider)}`).toBe(false); + const issues = r.error!.issues; + expect(issues).toHaveLength(1); + expect(issues[0].code).toBe('invalid_type'); + expect(issues[0].path).toEqual(['model', 'provider']); + expect(issues[0].message).toMatch(PROVIDER_PRESCRIPTION); + // House convention 1: the fully-qualified key, in backticks, opens it. + expect(issues[0].message.startsWith('`agent.model.provider` was removed')).toBe(true); + expect(issues[0].message.endsWith(MIGRATE_SENTENCE)).toBe(true); + } + }); + + it('accepts the 18.x emitted default `openai` as inert residue and strips it — the parsed agent carries no provider', () => { + const parsed = AgentSchema.parse({ ...MODEL_AGENT, model: { provider: 'openai', model: 'gpt-4o', temperature: 0.2 } }); + expect(parsed.model).toEqual({ model: 'gpt-4o', temperature: 0.2 }); + expect('provider' in (parsed.model as object)).toBe(false); + // The model block's own door agrees. + const block = AIModelConfigSchema.parse({ provider: 'openai' }); + expect('provider' in block).toBe(false); + // CONTROL: a near value is not the residue — only the exact literal is. + expect(AIModelConfigSchema.safeParse({ provider: 'OpenAI' }).success).toBe(false); + expect(AIModelConfigSchema.safeParse({ provider: 'openai ' }).success).toBe(false); + }); + + it('the walked shape keeps `provider` as a key — the tombstone stays reachable for its refusal', () => { + expect(Object.keys(AIModelConfigSchema.shape)).toContain('provider'); + expect(Object.keys(AIModelConfigSchema.shape), 'CONTROL: its live neighbour').toContain('model'); + }); + + it('fails tsc at the authoring site: the input type of `provider` is `never`', () => { + const agent: Agent = { + ...MODEL_AGENT, + model: { + // @ts-expect-error — `provider` is a retiredKey() tombstone: its input type is `never`. + provider: 'anthropic', + model: 'claude-sonnet-4', + }, + }; + // The parse channel agrees with the type channel on the same literal. + expect(() => AgentSchema.parse(agent)).toThrow(PROVIDER_PRESCRIPTION); + }); + + it('the authoring door, defineStack, refuses it with the STACK_SCHEMA_INVALID envelope — never rewrites it', () => { + const refusal = stackRefusal({ ...MODEL_AGENT, model: { provider: 'anthropic', model: 'claude-sonnet-4' } }); + expect(refusal?.code).toBe('STACK_SCHEMA_INVALID'); + expect(refusal?.status).toBe(422); + expect(refusal.issues).toHaveLength(1); + expect(refusal.issues?.[0]?.path).toEqual(['agents', 0, 'model', 'provider']); + expect(refusal.issues?.[0]?.message).toMatch(PROVIDER_PRESCRIPTION); + }); +}); + +describe('agent model provider retirement — the D2 conversion', () => { + const CONVERSION_ID = 'agent-model-provider-removed'; + const persisted = (provider: unknown) => ({ + ...MODEL_AGENT, + model: { provider, model: 'claude-sonnet-4', temperature: 0.3 }, + }); + + it('a STORED agent row carrying the key replays clean through the rehydration seam', () => { + const notices: Array<{ conversionId?: string; path?: string; from?: string; to?: string }> = []; + const rehydrated = applyConversionsToStoredItem('agent', persisted('anthropic'), { + onNotice: (n) => notices.push(n as { conversionId?: string; path?: string; from?: string; to?: string }), + }) as Record; + expect(notices.map((n) => [n.conversionId, n.path, n.from, n.to])).toEqual([ + [CONVERSION_ID, 'agents[0].model.provider', 'provider', '(removed)'], + ]); + // CONTROL: every live key on the same row survives byte-for-byte. + expect(rehydrated).toEqual({ ...MODEL_AGENT, model: { model: 'claude-sonnet-4', temperature: 0.3 } }); + // And the rehydrated row is exactly what the write door accepts now. + expect(AgentSchema.safeParse(rehydrated).success).toBe(true); + }); + + it('a persisted artifact is REFUSED at the boot door before the conversion and ACCEPTED after it', () => { + const artifact = () => ({ agents: [persisted('local')] }); + const before = ObjectStackDefinitionSchema.safeParse(artifact()); + expect(before.success).toBe(false); + expect(JSON.stringify(before.error?.issues ?? [])).toContain('`agent.model.provider` was removed'); + const after = ObjectStackDefinitionSchema.safeParse(applyConversions(artifact(), { includeRetired: true })); + expect(after.success, JSON.stringify(after.error?.issues ?? [])).toBe(true); + }); + + it('is idempotent by construction, and leaves an agent without the key untouched by reference', () => { + const input = { agents: [persisted('azure_openai'), { ...MODEL_AGENT, name: 'plain_agent', model: { temperature: 0.1 } }] }; + const { stack, notices } = collectConversionNotices(input, { includeRetired: true }); + expect(notices.filter((n) => n.conversionId === CONVERSION_ID)).toHaveLength(1); + expect((stack.agents as unknown[])[1]).toBe(input.agents[1]); + const replay = collectConversionNotices(stack, { includeRetired: true }); + expect(replay.notices).toHaveLength(0); + expect(replay.stack).toBe(stack); + }); + + it('is retired from the load path — a live author is refused at parse, never silently rewritten', () => { + const input = { agents: [persisted('anthropic')] }; + const { stack, notices } = collectConversionNotices(input); + expect(notices.filter((n) => n.conversionId === CONVERSION_ID)).toHaveLength(0); + expect(stack).toEqual(input); + }); + + it('is registered under major 19: the exact key, the chain step, and one D3 entry for the contract', () => { + expect(RETIRED_KEYS_BY_MAJOR[19]).toContain('ai/AIModelConfig:provider'); + expect(MIGRATIONS_BY_MAJOR[19]!.conversionIds).toContain(CONVERSION_ID); + const conversion = ALL_CONVERSIONS.find((c) => c.id === CONVERSION_ID); + expect(conversion, 'the D2 conversion must be registered').toBeDefined(); + expect(conversion!.toMajor).toBe(19); + expect(conversion!.retiredFromLoadPath).toBe(true); + expect(conversion!.surface).toBe('agent.model.provider'); + const d3 = MIGRATIONS_BY_MAJOR[19]!.semantic.filter((s) => s.id === 'agent-model-provider-retired'); + expect(d3).toHaveLength(1); + expect(d3[0]!.conversionIds).toEqual([CONVERSION_ID]); + expect(d3[0]!.reason).toContain(`\`${CONVERSION_ID}\``); + }); +}); + +// ─── Tree-scoped absence, with a DECLARED radius ───────────────────────────── +// +// `tsc` is the primary sweeper — `retiredKey()` types `provider` `never` on +// `Agent['model']`, so every TYPED authoring site fails to compile. The residue +// is what `tsc` never judges: JSON, YAML, MD/MDX code fences, untyped `.js`, +// and TS literals typed `any` / `unknown`. This walk covers that residue +// across the five repo roots `scripts/cross-package-test-inputs.mjs` already +// declares for `@objectstack/spec#test` (mirrored in `turbo.json`), plus the +// example apps' own `src/` trees, declared there as `examples/*/src/**/*.ts`. +// +// The matcher judges the AUTHORING SHAPE, never a mention: a `model` key whose +// object value holds a `provider` key before any nested brace (TS / JS / JSON, +// and YAML block and flow form). `provider` alone is far too common a word to +// judge — knowledge embedders, settings and model registries all carry one. +// Inline code is prose and is stripped before judging. The bound, stated: a +// block assembled by spread or under computed keys, and `docs/**`, +// `.claude/**`, `.github/**` and the repo-root files are outside what this +// walk sees. +describe('tree-scoped absence: nothing inside the declared radius still authors an agent model provider', () => { + const SPEC_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..'); + const REPO_ROOT = path.resolve(SPEC_ROOT, '../..'); + const THIS_FILE = path.relative(REPO_ROOT, fileURLToPath(import.meta.url)).split(path.sep).join('/'); + + /** The walked roots — declared in `scripts/cross-package-test-inputs.mjs` under `@objectstack/spec`. */ + const WALK_ROOTS = ['packages', 'examples', 'skills', 'content', 'scripts']; + const SCANNED_EXT = new Set(['.ts', '.mts', '.cts', '.js', '.mjs', '.cjs', '.json', '.md', '.mdx', '.yaml', '.yml']); + /** Under `examples/` the non-code extensions, plus `.ts` inside an app's own `src/` tree. */ + const EXAMPLES_EXT = new Set(['.json', '.md', '.mdx', '.yaml', '.yml']); + const EXAMPLE_APP_SRC_TS = /^examples\/[^/]+\/src\/.+\.ts$/; + const SKIPPED_DIRS = new Set(['node_modules', 'dist', '.git', '.turbo', '.cache', '.objectstack', 'coverage', '.next', '.source']); + + const AUTHORING = [ + // TS / JS / JSON, block or inline: the key, then an object whose own keys + // (before any nested brace) include `provider`. + /(^|[^\w.$])["']?model["']?\s*:\s*\{[^{}]*?(^|[^\w.$])["']?provider["']?\s*:/m, + // YAML block form: the key on its own line, `provider` indented below it + // among its siblings. + /^[ \t]*(-[ \t]+)?model[ \t]*:[ \t]*\r?\n(?:[ \t]+[^\s][^\n]*\r?\n)*?[ \t]+provider[ \t]*:/m, + ]; + + /** + * Inline code spans are prose — the house style `check:doc-authoring` enforces + * — so stripping single-backtick spans separates "the retirement kit + * describing what it removed" from "a source still writing it". + * Newline-bounded: a fenced block's content is NOT stripped. + */ + const stripInlineCode = (text: string): string => text.replace(/`[^`\n]*`/g, ''); + const judge = (text: string): RegExpExecArray | null => { + const stripped = stripInlineCode(text); + for (const re of AUTHORING) { + const m = re.exec(stripped); + if (m) return m; + } + return null; + }; + + /** + * Structural exclusions — the retirement kit, each with its reason. ⛔ NOT an + * allowlist file (`spec-property-retirement` §4): every entry's JOB is to + * spell the retired key. + */ + const EXCLUDED = new Set([ + // This pin authors the key to assert its refusal and its conversion. + THIS_FILE, + // A DIFFERENT schema's live key: a model-registry entry's `model` block is + // `ModelConfigSchema` (ai/model-registry.zod.ts), whose `provider` is live + // and unrelated to an agent's. Its suite authors registry entries only. + 'packages/spec/src/ai/model-registry.test.ts', + ]); + const EXCLUDED_PREFIXES = [ + // The D2 conversion's fixture authors the pre-retirement agent on purpose. + 'packages/spec/src/conversions/', + // Release-owned prose records the removal; never edited by a code PR. + 'content/docs/releases/', + // GITIGNORED build output (`packages/spec/json-schema/`), reached only + // because this is a FILESYSTEM walk. Its source is `agent.zod.ts`. + 'packages/spec/json-schema/', + ]; + /** tsup's own bundle of `tsup.config.ts`, written and deleted mid-build. */ + const TSUP_BUNDLED_CONFIG = /\.bundled_[^./]+\.mjs$/; + + /** Tolerates ONLY a path that vanished mid-walk; every other read fault is re-raised. */ + const readIfPresent = (full: string): string | undefined => { + try { + return fs.readFileSync(full, 'utf-8'); + } catch (err) { + if ((err as NodeJS.ErrnoException)?.code !== 'ENOENT') throw err; + return undefined; + } + }; + + it('the matcher recognises an authoring and ignores a prose mention and a neighbour (anti-vacuity)', () => { + // Offenders — the retired shape, in each syntax the walk reads. + expect(judge("defineAgent({ model: { provider: 'openai', model: 'gpt-4o' } })")).not.toBeNull(); + expect(judge(" model: {\n model: 'gpt-4o',\n provider: 'anthropic',\n },")).not.toBeNull(); + expect(judge('{ "model": { "provider": "openai", "model": "gpt-4" } }')).not.toBeNull(); + expect(judge('model:\n temperature: 0.2\n provider: anthropic\n')).not.toBeNull(); + expect(judge("Prose.\n\n```ts\ndefineAgent({ model: { provider: 'openai' } });\n```\n")).not.toBeNull(); + // Neighbours that must NOT match. + expect(judge("the `model: { provider: 'openai' }` block loses its provider")).toBeNull(); + expect(judge("model: { model: 'gpt-4o', temperature: 0.2 }")).toBeNull(); + expect(judge("defaultModel: { provider: 'openai', model: 'gpt-4o-mini' }")).toBeNull(); + expect(judge("embedder_model: 'x', embedder_provider: 'openai'")).toBeNull(); + expect(judge("provider: retiredKey(MODEL_PROVIDER_RETIRED),")).toBeNull(); + expect(judge("const s = { model: 1, nested: { provider: 'x' } };")).toBeNull(); + expect(judge('model:\n temperature: 0.2\nprovider:\n kind: x\n')).toBeNull(); + }); + + it('no agent model provider authoring survives inside the declared radius outside the retirement kit', () => { + const offenders: string[] = []; + let visited = 0; + let exampleSources = 0; + const walk = (dir: string) => { + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const full = path.join(dir, entry.name); + const rel = path.relative(REPO_ROOT, full).split(path.sep).join('/'); + if (entry.isDirectory()) { + if (SKIPPED_DIRS.has(entry.name) || entry.name.startsWith('.')) continue; + walk(full); + continue; + } + if (!entry.isFile()) continue; + const ext = path.extname(entry.name); + const scanned = rel.startsWith('examples/') + ? EXAMPLES_EXT.has(ext) || EXAMPLE_APP_SRC_TS.test(rel) + : SCANNED_EXT.has(ext); + if (!scanned) continue; + if (entry.name === 'CHANGELOG.md') continue; // release prose records the removal + if (EXCLUDED.has(rel) || EXCLUDED_PREFIXES.some((p) => rel.startsWith(p))) continue; + if (TSUP_BUNDLED_CONFIG.test(entry.name)) continue; + visited += 1; + if (EXAMPLE_APP_SRC_TS.test(rel)) exampleSources += 1; + const text = readIfPresent(full); + if (text === undefined) continue; + const m = judge(text); + if (m) offenders.push(`${rel} authors \`${m[0].trim().replace(/\s+/g, ' ')}\``); + } + }; + for (const root of WALK_ROOTS) walk(path.join(REPO_ROOT, root)); + // Anti-vacuity: the walk really covered the tree, and the example apps' + // sources were really read. + expect(visited).toBeGreaterThan(1000); + expect(exampleSources).toBeGreaterThan(50); + expect(offenders, 'an agent model provider authoring means the retirement is being undone').toEqual([]); + }); +}); diff --git a/packages/spec/src/ai/agent.form.ts b/packages/spec/src/ai/agent.form.ts index a5e361fbacf..323bf5defaa 100644 --- a/packages/spec/src/ai/agent.form.ts +++ b/packages/spec/src/ai/agent.form.ts @@ -38,7 +38,7 @@ export const agentForm = defineForm({ description: 'Model selection, instructions, planning, and memory.', fields: [ { field: 'instructions', required: true, widget: 'textarea', helpText: 'System prompt — tell the agent how to behave and what it can do' }, - { field: 'model', type: 'composite', helpText: 'AI model configuration (provider, model name, temperature, etc.)' }, + { field: 'model', type: 'composite', helpText: 'AI model configuration (model name, temperature, etc.)' }, { field: 'planning', type: 'composite', helpText: 'Autonomous reasoning configuration: a runaway fuse counted in model calls, each one model call plus its tool batch, after which the agent stops (1–1000, default 10).' }, { field: 'memory', type: 'composite', helpText: 'Long-term memory: distilled notes kept per user, recalled before each conversation and written by a reflection every reflectionInterval delivered interactions. When long-term memory is enabled, maxEntries and reflectionInterval are required. Enforced by the cloud AI runtime.' }, // `lifecycle` input removed with the key (#21320): the conversation state diff --git a/packages/spec/src/ai/agent.test.ts b/packages/spec/src/ai/agent.test.ts index 9fa0ac27ff1..859b5db4c06 100644 --- a/packages/spec/src/ai/agent.test.ts +++ b/packages/spec/src/ai/agent.test.ts @@ -20,32 +20,17 @@ describe('AIModelConfigSchema', () => { }; const result = AIModelConfigSchema.parse(config); - expect(result.provider).toBeUndefined(); + expect('provider' in result).toBe(false); expect(result.temperature).toBe(0.7); }); it('adds no provider to a block that names none — the host picks the model and its provider', () => { const result = AIModelConfigSchema.parse({ temperature: 0.2 }); expect('provider' in result).toBe(false); - expect(AIModelConfigSchema.parse({ provider: 'anthropic' }).provider).toBe('anthropic'); - expect(AIModelConfigSchema.safeParse({ provider: 'google' }).success).toBe(false); - }); - - it('should accept all providers', () => { - const providers = ['openai', 'azure_openai', 'anthropic', 'local'] as const; - - providers.forEach(provider => { - const config = { - provider, - model: 'test-model', - }; - expect(() => AIModelConfigSchema.parse(config)).not.toThrow(); - }); }); it('should accept full model config', () => { const config = { - provider: 'anthropic' as const, model: 'claude-3-opus-20240229', temperature: 0.5, maxTokens: 4096, @@ -59,7 +44,7 @@ describe('AIModelConfigSchema', () => { const result = AIModelConfigSchema.parse({ temperature: 0.2 }); expect(result.model).toBeUndefined(); expect(result.temperature).toBe(0.2); - expect(result.provider).toBeUndefined(); + expect('provider' in result).toBe(false); expect(AIModelConfigSchema.parse({}).model).toBeUndefined(); }); @@ -204,7 +189,6 @@ describe('AgentSchema', () => { role: 'Business Intelligence Analyst', instructions: 'Analyze data and provide insights.', model: { - provider: 'anthropic', model: 'claude-3-opus-20240229', temperature: 0.3, maxTokens: 8192, @@ -370,7 +354,6 @@ Your responsibilities: Always be polite, empathetic, and solution-oriented.`, model: { - provider: 'openai', model: 'gpt-4-turbo-preview', temperature: 0.7, maxTokens: 2048, @@ -400,7 +383,6 @@ Core capabilities: Be persuasive but honest. Focus on value creation.`, model: { - provider: 'anthropic', model: 'claude-3-sonnet-20240229', temperature: 0.8, }, @@ -427,7 +409,6 @@ Skills: Be precise, data-driven, and clear in your explanations.`, model: { - provider: 'openai', model: 'gpt-4', temperature: 0.3, maxTokens: 4096, diff --git a/packages/spec/src/ai/agent.zod.ts b/packages/spec/src/ai/agent.zod.ts index 2c97383f7f3..2a2589b6676 100644 --- a/packages/spec/src/ai/agent.zod.ts +++ b/packages/spec/src/ai/agent.zod.ts @@ -2,7 +2,7 @@ import { z } from 'zod'; import { ROUTER_ADDRESSABLE_NAME_MESSAGE, ROUTER_ADDRESSABLE_NAME_PATTERN } from '../kernel/address-grammar'; -import { enumWithRetiredValues, retiredKey } from '../shared/retired-key'; +import { acceptRetiredDefaultResidue, enumWithRetiredValues, retiredKey } from '../shared/retired-key'; import { ProtectionSchema } from '../shared/protection.zod'; import { MetadataProtectionFields } from '../kernel/metadata-protection.zod'; import { lazySchema } from '../shared/lazy-schema'; @@ -21,10 +21,45 @@ const AGENT_HISTORY = 'Until this shape was closed these were dropped silently — the agent still registered ' + 'and still answered, minus whatever the key was meant to configure or constrain.'; +// ── Retired `model.provider` (ADR-0049 enforce-or-remove, #37712) ─────────── +// +// The block once declared which provider served the agent — an enum of +// `openai`, `azure_openai`, `anthropic` and `local`. No runtime ever read it: +// the cloud AI runtime, the one runtime that executes agents, applies the +// model name, `temperature` and `maxTokens` and nothing else from this block, +// and the providers a deployment can turn on are its own AI settings +// (`AI_PROVIDERS` in service-settings: `gateway`, `openai`, `anthropic`, +// `google`, …), a list the enum neither matched nor could follow — two of its +// four values name no provider a deployment has. The model name is the one +// choice an agent makes; the deployment resolves it among the providers it +// has turned on. Tombstoned with `retiredKey()`: `tsc` refuses the key and the +// parse answers with this prescription; the ADR-0087 conversion +// `agent-model-provider-removed` deletes it from stored rows and existing +// sources. Module-private and written with `//`: prose the refusal consumes. +const MODEL_PROVIDER_RETIRED = + '`agent.model.provider` was removed in @objectstack/spec 19.0.0 (ADR-0049 enforce-or-remove) — ' + + 'it never had an effect: no runtime read it, and the provider that serves an agent is chosen by ' + + 'the deployment\'s AI settings, never by the agent. Delete the key. To pin a model, name it in ' + + '`agent.model.model`; the deployment resolves that name among the providers it has turned on, ' + + 'and an agent that names no model runs on the deployment\'s default model. ' + + 'Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand.'; + +// [#37712] The default the retired `provider` emitted, captured as a literal +// at retirement (`acceptRetiredDefaultResidue`, the #12840 rule for a retired +// DEFAULTED key). Every agent a released 18.x toolchain parsed with a `model` +// block carries `provider: 'openai'` written out although no author wrote it; +// that residue is accepted and stripped, and every other value (the ones an +// author did write) keeps the tombstone's refusal. +const MODEL_PROVIDER_RETIRED_KEY_RESIDUE = { provider: 'openai' } as const; + /** * AI Model Configuration + * + * The model an agent runs on and its sampling settings. Which provider serves + * the model is the deployment's choice: `provider` was retired (#37712, + * ADR-0049) because no runtime ever read it. */ -export const AIModelConfigSchema = lazySchema(() => strictObject({ +export const AIModelConfigSchema = lazySchema(() => acceptRetiredDefaultResidue(strictObject({ surface: 'this model configuration', history: AGENT_HISTORY, aliases: { @@ -34,7 +69,13 @@ export const AIModelConfigSchema = lazySchema(() => strictObject({ top_p: 'topP', nucleus: 'topP', }, }, { - provider: z.enum(['openai', 'azure_openai', 'anthropic', 'local']).optional(), + /** + * REMOVED (#37712, ADR-0049) — the provider is the deployment's choice, never + * the agent's; see `MODEL_PROVIDER_RETIRED` above. A tombstone, not a bare + * delete, so authoring it is a `tsc` error and a parse error that carries + * the prescription instead of an anonymous unrecognized-key refusal. + */ + provider: retiredKey(MODEL_PROVIDER_RETIRED), model: z.string().optional().describe( 'Model name (e.g. gpt-4, claude-3-opus). Optional: when absent, the agent runs on the ' + 'host\'s default model for this environment, so an agent that only tunes sampling ' @@ -43,7 +84,7 @@ export const AIModelConfigSchema = lazySchema(() => strictObject({ temperature: z.number().min(0).max(2).default(0.7), maxTokens: z.number().optional(), topP: z.number().optional(), -})); +}), MODEL_PROVIDER_RETIRED_KEY_RESIDUE)); /* * REMOVED — `AIKnowledgeSchema` / `AIKnowledge` (#3896 audit close-out). It diff --git a/packages/spec/src/benchmark.bench.ts b/packages/spec/src/benchmark.bench.ts index d6c7b7c2416..1144b9ad87f 100644 --- a/packages/spec/src/benchmark.bench.ts +++ b/packages/spec/src/benchmark.bench.ts @@ -146,7 +146,6 @@ describe('AI Domain — Schema Parse Performance', () => { role: 'assistant', instructions: 'You are a helpful assistant.', model: { - provider: 'openai', model: 'gpt-4o', }, tools: [], diff --git a/packages/spec/src/conversions/entries/19/agent-model-provider-removed.ts b/packages/spec/src/conversions/entries/19/agent-model-provider-removed.ts new file mode 100644 index 00000000000..b6c22c70334 --- /dev/null +++ b/packages/spec/src/conversions/entries/19/agent-model-provider-removed.ts @@ -0,0 +1,95 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import type { MetadataConversion } from '../../types.js'; +import { mapCollection } from '../../walk.js'; +import { isDict, stripKeys } from '../shared.js'; + +/** + * An agent's model provider — `agent.model.provider` — leaves the spec + * (protocol 19, #37712; ADR-0049 enforce-or-remove). + * + * The key declared which provider served the agent, from an enum of `openai`, + * `azure_openai`, `anthropic` and `local`. No runtime ever read it: cloud's AI + * service, the one runtime that executes agents, applies the model name, + * `temperature` and `maxTokens` from the `model` block and nothing else, and + * the providers a deployment can turn on are its own AI settings. So no + * authored value ever chose a provider, and the delete is LOSSLESS: authoring + * now refuses the key by name (`retiredKey`, ai/agent.zod.ts). + * + * One edit: the key is deleted from `model`, whatever it holds — one of the + * four enum values, or anything else. Every other key of the block stays, and + * a block left empty stays as an empty block (an empty `model` block parses: + * every key in it is optional or defaulted). One notice per agent that + * carried it. + * + * Idempotent by construction: `stripKeys` skips an absent key and hands the + * input back by reference. Retired from the load path: an author is refused at + * parse with the prescription; data at rest (`applyConversionsToStoredItem`), + * built artifacts and `os migrate meta` replay it. + */ +const agentModelProviderRemoved: MetadataConversion = { + id: 'agent-model-provider-removed', + toMajor: 19, + retiredFromLoadPath: true, + retiredAfter: '18.6.0', + surface: 'agent.model.provider', + summary: + "agent model key 'provider' removed: no runtime ever read it — the provider that serves an agent is " + + "chosen by the deployment's AI settings, never by the agent. The key is deleted; the model name, " + + 'temperature and every other model key stay', + apply(stack, emit) { + return mapCollection(stack, 'agents', (agent, path) => { + const model = agent.model; + if (!isDict(model)) return agent; + const next = stripKeys(model, ['provider'], emit, `${path}.model`); + return next === model ? agent : { ...agent, model: next }; + }); + }, + fixture: { + before: { + agents: [ + { + // The old default, as a released toolchain materialized it into a + // parsed agent whose author never wrote `provider`. + name: 'support_agent', + label: 'Support', + model: { provider: 'openai', model: 'gpt-4o', temperature: 0.2 }, + }, + { + // An explicit choice the runtime never honoured: deleted all the + // same — the provider is the deployment's. + name: 'review_agent', + label: 'Review', + model: { provider: 'anthropic', model: 'claude-sonnet-4', maxTokens: 2000 }, + }, + { + // The provider alone: the block stays, empty. + name: 'local_agent', + label: 'Local', + model: { provider: 'local' }, + }, + { + // Already canonical, and an agent with no model block at all: both + // ride through untouched. + name: 'tuned_agent', + label: 'Tuned', + model: { temperature: 0.3 }, + }, + { name: 'plain_agent', label: 'Plain' }, + ], + }, + after: { + agents: [ + { name: 'support_agent', label: 'Support', model: { model: 'gpt-4o', temperature: 0.2 } }, + { name: 'review_agent', label: 'Review', model: { model: 'claude-sonnet-4', maxTokens: 2000 } }, + { name: 'local_agent', label: 'Local', model: {} }, + { name: 'tuned_agent', label: 'Tuned', model: { temperature: 0.3 } }, + { name: 'plain_agent', label: 'Plain' }, + ], + }, + // Three: one per agent whose `model` carried the key. + expectedNotices: 3, + }, +}; + +export { agentModelProviderRemoved }; diff --git a/packages/spec/src/conversions/registry.ts b/packages/spec/src/conversions/registry.ts index abf44d04d79..c402e587509 100644 --- a/packages/spec/src/conversions/registry.ts +++ b/packages/spec/src/conversions/registry.ts @@ -138,6 +138,7 @@ import { permissionRlsTagsRemoved } from './entries/18/permission-rls-tags-remov import { flowDecisionModeInclusiveExplicit } from './entries/18/flow-decision-mode-inclusive-explicit.js'; // Major 19: imported after every major-18 conversion, in `MAJOR_19_CONVERSIONS`'s // identifier order. +import { agentModelProviderRemoved } from './entries/19/agent-model-provider-removed.js'; import { permissionViewAllFieldsBesideRecordBypass } from './entries/19/permission-view-all-fields-beside-record-bypass.js'; /** @@ -314,6 +315,7 @@ const MAJOR_18_CONVERSIONS: readonly OrderedConversion[] = [ * `CONVERSIONS_BY_MAJOR[19]`, which is this list in `order`. */ const MAJOR_19_CONVERSIONS: readonly OrderedConversion[] = [ + { conversion: agentModelProviderRemoved, order: 2 }, { conversion: permissionViewAllFieldsBesideRecordBypass, order: 1 }, ]; diff --git a/packages/spec/src/migrations/entries/retired-keys/19.ai__AIModelConfig__provider.ts b/packages/spec/src/migrations/entries/retired-keys/19.ai__AIModelConfig__provider.ts new file mode 100644 index 00000000000..6bfb1d5b646 --- /dev/null +++ b/packages/spec/src/migrations/entries/retired-keys/19.ai__AIModelConfig__provider.ts @@ -0,0 +1,12 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +// #37712 — ADR-0049 enforce-or-remove: an agent's `model.provider` was parsed +// and never read. The cloud AI runtime, the one runtime that executes agents, +// applies the model name, `temperature` and `maxTokens` from the block and +// nothing else, and the providers a deployment turns on are its own AI +// settings, a list the agent's four-value enum neither matched nor followed. +// Tombstoned with `retiredKey()` on the strict `AIModelConfigSchema`; D2 +// conversion `agent-model-provider-removed` (lossless delete, retired from the +// load path); D3 semantic entry `agent-model-provider-retired`. Registered +// under 19, the spec package's own major. +export const entry = 'ai/AIModelConfig:provider'; diff --git a/packages/spec/src/migrations/entries/semantic/19.agent-model-provider-retired.ts b/packages/spec/src/migrations/entries/semantic/19.agent-model-provider-retired.ts new file mode 100644 index 00000000000..e7082344f03 --- /dev/null +++ b/packages/spec/src/migrations/entries/semantic/19.agent-model-provider-retired.ts @@ -0,0 +1,38 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import type { SemanticMigration } from '../../types.js'; + +// #37712 — ADR-0049 enforce-or-remove — the D3 entry of the `agent.model.provider` +// retirement. The data half is mechanical (the D2 conversion +// `agent-model-provider-removed` deletes the key, losslessly); what it cannot do +// is the judgement this entry carries: an author who wrote a provider meant a +// model from it, and only the author can tell whether the deployment's default +// model or a named one is what the agent should run on. +export const entry: SemanticMigration = { + id: 'agent-model-provider-retired', + surface: 'agent.model.provider — left the shape (the provider is the deployment\'s choice); ' + + 'agent.model.model, temperature, maxTokens and topP are unchanged', + replacement: + 'no provider key: delete `model.provider`, whatever it held. The provider that serves an agent is ' + + 'chosen by the deployment\'s AI settings. An agent that must run on a particular model names it in ' + + '`model.model`, which the deployment resolves among the providers it has turned on; an agent that ' + + 'names no model runs on the deployment\'s default model', + reason: + 'ADR-0049 enforce-or-remove: `model.provider` was parsed and never read. The cloud AI runtime, the ' + + 'one runtime that executes agents, applies the model name, `temperature` and `maxTokens` from the ' + + '`model` block and nothing else, so an agent that declared `anthropic` ran on whatever provider the ' + + 'deployment served. The providers a deployment can turn on are its own AI settings, and the key\'s ' + + 'four values (`openai`, `azure_openai`, `anthropic`, `local`) neither matched that list nor could ' + + 'follow it. Authoring now refuses the key with a prescription, and TypeScript rejects it. The D2 ' + + 'conversion `agent-model-provider-removed` deletes it from existing sources and stored rows, ' + + 'losslessly: no value of it ever chose a provider. What no conversion can decide is whether an ' + + 'agent whose author wrote a provider, and no model name, should now name a model the deployment ' + + 'offers or run on its default model', + acceptanceCriteria: + 'No agent declares `model.provider`; the key is refused at parse with its prescription, and ' + + 'TypeScript rejects it. Every agent that must run on a particular model names it in `model.model`, ' + + 'and that name is one of the models the target deployment\'s AI settings offer. Every agent parses ' + + 'under the new schema.', + conversionIds: ['agent-model-provider-removed'], + relevantWhen: { kind: 'stack-declares', keys: ['agents'] }, +}; diff --git a/packages/spec/src/migrations/registry.ts.template b/packages/spec/src/migrations/registry.ts.template index 7fbbacaa904..747150bb016 100644 --- a/packages/spec/src/migrations/registry.ts.template +++ b/packages/spec/src/migrations/registry.ts.template @@ -3727,6 +3727,8 @@ const step19: MigrationStep = { 'Protocol 19 moves the load-time handshake: a manifest whose `engines.protocol` range admits ' + 'protocol 18 and not 19 is refused before any of its metadata loads, so each manifest an app ' + 'or package declares moves its range to `^19`, together with its `@objectstack/*` versions. ' + + 'An agent\'s `model.provider` leaves the shape: no runtime ever read it, and the provider that ' + + 'serves an agent is the deployment\'s choice, so the key is deleted and the model name stays. ' + 'View All and Modify All stop casting a field vote: `viewAllFields: true` is written beside them ' + 'in every permission set entry of a source that predates the switch, so the migrated source keeps ' + 'the field reads those bits cast; the semantic entry names what it does not keep.', diff --git a/packages/spec/src/migrations/semantic-relevance.test.ts b/packages/spec/src/migrations/semantic-relevance.test.ts index 95bcc4caae1..4ab4fa2c87e 100644 --- a/packages/spec/src/migrations/semantic-relevance.test.ts +++ b/packages/spec/src/migrations/semantic-relevance.test.ts @@ -62,6 +62,7 @@ const EXPECTED_RELEVANCE: Readonly> = { '18:job-timeout-unit-in-key': ['jobs'], '18:mapping-lookup-params-retired': ['mappings'], '18:permission-restore-purge-bits-retired': ['permissions'], + '19:agent-model-provider-retired': ['agents'], }; /** The keys the evaluation reads as carriers of other definitions, never as a family. */ @@ -84,11 +85,12 @@ describe('which entries carry a relevance question (ENUMERATION)', () => { expect(actual).toEqual(EXPECTED_RELEVANCE); }); - it('is 27 entries: 5 of protocol 17 and 22 of protocol 18', () => { + it('is 28 entries: 5 of protocol 17, 22 of protocol 18 and 1 of protocol 19', () => { const keys = Object.keys(EXPECTED_RELEVANCE); - expect(keys).toHaveLength(27); + expect(keys).toHaveLength(28); expect(keys.filter((k) => k.startsWith('17:'))).toHaveLength(5); expect(keys.filter((k) => k.startsWith('18:'))).toHaveLength(22); + expect(keys.filter((k) => k.startsWith('19:'))).toHaveLength(1); }); it('the table names only registered entries (anti-vacuity for the comparison above)', () => { diff --git a/packages/spec/src/shared/retired-key-removal-version.pin.test.ts b/packages/spec/src/shared/retired-key-removal-version.pin.test.ts index 9070b658321..34d03f50495 100644 --- a/packages/spec/src/shared/retired-key-removal-version.pin.test.ts +++ b/packages/spec/src/shared/retired-key-removal-version.pin.test.ts @@ -79,6 +79,7 @@ import { describe, expect, it } from 'vitest'; import { ALL_CONVERSIONS } from '../conversions/registry'; import { MIGRATIONS_BY_MAJOR } from '../migrations/registry'; +import { AIModelConfigSchema } from '../ai/agent.zod'; import { TimeUpdateInterval } from '../data/analytics.zod'; import { CurrencyConfigSchema, FieldSchema } from '../data/field.zod'; import { IndexSchema, ObjectSchema } from '../data/object.zod'; @@ -336,6 +337,8 @@ const JOIN: Readonly> = { refusal("manifest.packaging 'manifest-deps'", () => PluginPackagingSchema.safeParse('manifest-deps')), ], // #35926: a relationship field's boolean `inlineEdit`, refused by the enum's own error map. + // #37712: an agent's `model.provider`, tombstoned on the model block. + 'agent-model-provider-removed': [tombstone(AIModelConfigSchema, 'agent.model', 'provider')], 'field-inline-edit-boolean-removed': [ refusal( 'field.inlineEdit: true', diff --git a/packages/spec/vitest.repo-tests.json b/packages/spec/vitest.repo-tests.json index e815b550888..4f80758a464 100644 --- a/packages/spec/vitest.repo-tests.json +++ b/packages/spec/vitest.repo-tests.json @@ -31,6 +31,7 @@ "scripts/strictness-ledger.test.ts", "src/ai/agent-lifecycle-retirement.test.ts", "src/ai/agent-memory-store-retirement.test.ts", + "src/ai/agent-model-provider-retirement.test.ts", "src/ai/tool-confirmation-prescription-tense.pin.test.ts", "src/api/docs-viewer-keys-retirement.test.ts", "src/api/error-catalog-docs.test.ts", diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/AgentPreview.emptyCollection-8520.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/AgentPreview.emptyCollection-8520.test.tsx index 3888b7cf2f7..b1bf1ce5692 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/AgentPreview.emptyCollection-8520.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/AgentPreview.emptyCollection-8520.test.tsx @@ -41,7 +41,7 @@ const BASE = { name: 'sales_copilot', label: 'Sales Copilot', active: true, - model: { provider: 'openai', model: 'gpt-4o' }, + model: { model: 'gpt-4o' }, instructions: 'You are a helpful sales assistant.', skills: ['summarize_account'], } satisfies Record; diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/AgentPreview.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/AgentPreview.test.tsx index 6407090e94c..448daa75fec 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/AgentPreview.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/AgentPreview.test.tsx @@ -36,7 +36,7 @@ const VALID_DRAFT = { label: 'Sales Copilot', role: 'Assistant for sales reps', active: true, - model: { provider: 'openai', model: 'gpt-4o', temperature: 0.4, maxTokens: 2048 }, + model: { model: 'gpt-4o', temperature: 0.4, maxTokens: 2048 }, instructions: 'You are a helpful sales assistant.', skills: ['summarize_account', 'draft_email'], } satisfies Record; @@ -71,14 +71,14 @@ describe('AgentPreview renders what a spec-valid agent declares', () => { expect(screen.getByText('Sales Copilot')).toBeTruthy(); expect(screen.getByText('sales_copilot')).toBeTruthy(); expect(screen.getByText('Assistant for sales reps')).toBeTruthy(); - expect(screen.getByText('openai · gpt-4o')).toBeTruthy(); + expect(screen.getByText('gpt-4o')).toBeTruthy(); expect(screen.getByText('You are a helpful sales assistant.')).toBeTruthy(); }); - it('shows the model name when the block names no provider', () => { - renderPreview({ ...VALID_DRAFT, model: { model: 'gpt-4o' } }); + it('never shows a provider, even for a stale draft that still carries one (#37712: the key was retired)', () => { + renderPreview({ ...VALID_DRAFT, model: { provider: 'anthropic', model: 'gpt-4o' } }); expect(screen.getByText('gpt-4o')).toBeTruthy(); - expect(screen.queryByText(/openai/)).toBeNull(); + expect(screen.queryByText(/anthropic/)).toBeNull(); }); it('shows no model pill for a block that names neither, so the environment default is not given a name', () => { diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/AgentPreview.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/AgentPreview.tsx index 0d68864c886..a4e35498c25 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/AgentPreview.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/AgentPreview.tsx @@ -6,7 +6,9 @@ * Shows the configuration an operator needs to sanity-check an agent * before saving: * • Persona header (avatar, label, role, active flag). - * • Model config (provider, model id, temperature, max tokens). + * • Model config (model id, temperature, max tokens). Never a provider: an + * agent's `model.provider` was retired (#37712, ADR-0049): the deployment's + * AI settings choose the provider, and the key never had an effect. * • System prompt / instructions in a scrollable monospace block. * • Skills as a chip list. * • Planning + guardrails callouts. @@ -54,7 +56,6 @@ import { t as tr, tFormat } from '../i18n.js'; import { PreviewShell, PreviewMessage, PreviewErrorBoundary } from './PreviewShell.js'; interface ModelConfig { - provider?: string; model?: string; temperature?: number; maxTokens?: number; @@ -153,9 +154,7 @@ export function AgentPreview({ name, draft, locale }: MetadataPreviewProps) { label={tr(active ? 'engine.agentPreview.active' : 'engine.agentPreview.disabled', locale)} tone={active ? 'green' : 'gray'} /> - {(model.provider || model.model) && ( - - )} + {model.model && } {model.temperature != null && ( )} From 8655944d13aaea85def9fce116b232dc4f52cac2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 03:14:52 +0000 Subject: [PATCH 2/4] test(ui): agent fixtures stop writing the retired model provider; the preview pill reads the model name Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgTnm6d4W7ugSacDJ3j --- ui/apps/console/src/preview-samples.ts | 2 +- .../ResourceListPage.servedListColumns-36860.test.tsx | 2 +- .../previews/automationPreviews.i18n-10862.test.tsx | 4 ++-- .../metadata-admin/previews/emptyCollection-8526.test.tsx | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ui/apps/console/src/preview-samples.ts b/ui/apps/console/src/preview-samples.ts index 95062e73a82..eeb24dec282 100644 --- a/ui/apps/console/src/preview-samples.ts +++ b/ui/apps/console/src/preview-samples.ts @@ -347,7 +347,7 @@ export const SAMPLES: Record> = { label: 'Sales Copilot', role: 'Assistant for sales reps', active: true, - model: { provider: 'openai', model: 'gpt-4o', temperature: 0.4, maxTokens: 2048 }, + model: { model: 'gpt-4o', temperature: 0.4, maxTokens: 2048 }, instructions: 'You are a helpful sales assistant. Answer questions about accounts and orders, and draft follow-up emails. Always cite the record you used.', // An agent reaches exactly the tools its surface-compatible skills declare diff --git a/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.servedListColumns-36860.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.servedListColumns-36860.test.tsx index 47634f4f36d..ab740441995 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.servedListColumns-36860.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.servedListColumns-36860.test.tsx @@ -34,7 +34,7 @@ const HOOKS: Record[] = [ // `priority` and `async` left at their schema defaults: stored rows omit them. { name: 'audit_all', label: 'Audit all', object: ['account', 'contact'], events: ['afterDelete'] }, ]; -const AGENTS: Record[] = [{ name: 'helper', label: 'Helper', model: { provider: 'openai', model: 'gpt-4o' } }]; +const AGENTS: Record[] = [{ name: 'helper', label: 'Helper', model: { model: 'gpt-4o' } }]; const QUEUES: Record[] = [{ name: 'tier1', label: 'Tier 1', members: [{ type: 'user', id: 'a' }, { type: 'user', id: 'b' }] }]; const SKILLS: Record[] = [{ name: 'triage', label: 'Triage', tools: ['a', 'b'] }]; diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/automationPreviews.i18n-10862.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/automationPreviews.i18n-10862.test.tsx index 12191e11dfb..2e01589990a 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/automationPreviews.i18n-10862.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/automationPreviews.i18n-10862.test.tsx @@ -314,7 +314,7 @@ const AGENT_FULL = { label: 'Sales Copilot', role: 'Account assistant', instructions: 'Be kind.', - model: { provider: 'openai', model: 'gpt-x', temperature: 0.2, maxTokens: 1000 }, + model: { model: 'gpt-x', temperature: 0.2, maxTokens: 1000 }, skills: [], planning: { maxIterations: 5 }, memory: { shortTerm: {} }, @@ -352,7 +352,7 @@ describe('AgentPreview — the designer words read engine.agentPreview.* (object { key: 'engine.agentPreview.guardrails' }, { key: 'engine.agentPreview.permissions' }, ]); - expectAsWritten(['Sales Copilot', 'Account assistant', 'Be kind.', 'openai · gpt-x', 'maxIterations', 'maxCost', 'ai.use']); + expectAsWritten(['Sales Copilot', 'Account assistant', 'Be kind.', 'gpt-x', 'maxIterations', 'maxCost', 'ai.use']); }); it(`${lang}: a disabled agent with no prompt and nothing on the rail`, () => { diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/emptyCollection-8526.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/emptyCollection-8526.test.tsx index cd07bee7d3c..0d56342506e 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/emptyCollection-8526.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/emptyCollection-8526.test.tsx @@ -109,7 +109,7 @@ function expectPopulated(block: HTMLElement, sentence: string) { const AGENT = { name: 'sales_copilot', label: 'Sales Copilot', - model: { provider: 'openai', model: 'gpt-4o' }, + model: { model: 'gpt-4o' }, instructions: 'Be kind.', skills: ['summarize_account'], planning: { maxIterations: 8 }, From ef13630dfde5760518c9ea63c303d866aa5681d9 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 03:52:37 +0000 Subject: [PATCH 3/4] chore(changeset): the console preview sample ships too; skills follow-up card named Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgTnm6d4W7ugSacDJ3j --- .changeset/37712-agent-model-provider-retired.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.changeset/37712-agent-model-provider-retired.md b/.changeset/37712-agent-model-provider-retired.md index 4e9db898b65..08b9d441388 100644 --- a/.changeset/37712-agent-model-provider-retired.md +++ b/.changeset/37712-agent-model-provider-retired.md @@ -3,13 +3,14 @@ '@objectstack/cli': patch '@objectstack/platform-objects': patch '@object-ui/app-shell': patch +'@object-ui/console': patch --- feat(spec)!: retire an agent's `model.provider` — no runtime read it; the deployment's AI settings choose the provider Clause-②: no (narrowing) Metadata-protocol: narrowed -Skills-docs: follow-up owed +Skills-docs: follow-up #37796 @@ -27,4 +28,5 @@ The retirement kit: - **`@objectstack/spec`**: `provider` is a `retiredKey()` tombstone on `AIModelConfigSchema`, and the 18.x emitted default is stripped by `acceptRetiredDefaultResidue`. The D2 conversion `agent-model-provider-removed` (lossless, retired from the load path) deletes the key from `agents[]` on every data-at-rest seam (stored rows, built artifacts, `os migrate meta`); the D3 entry `agent-model-provider-retired` names what the upgrade still owes: whether an agent whose author wrote a provider should now name a model the deployment offers or run on its default model. The key is registered in `RETIRED_KEYS_BY_MAJOR[19]`. The liveness ledger's `model` row records the removal. The agent form's model help text no longer names a provider. - **`@objectstack/platform-objects`**: the agent form's regenerated help-text labels. - **`@object-ui/app-shell`**: the agent metadata preview shows the model name alone and never a provider pill. +- **`@object-ui/console`**: the agent preview sample no longer writes `provider`. - **`@objectstack/cli`**: `os explain agent` describes the `model` block without `provider`, and its example drops it. From a610db7a0b656eba611b617cc84209e2908374db Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 04:30:54 +0000 Subject: [PATCH 4/4] fix(spec): a provider at the agent's top level is answered with the retirement, never pointed at model.provider - AgentSchema's wrong-layer guidance for `provider` now says there is no provider key at either level and names `agent.model.model`; pinned - D3 reason names the judgement an upgrader really owes (is the named model one the deployment offers); the changeset drops the never-accepted provider-without-model row and says AIModelConfigSchema is a pipe now - DEFAULT_CHANGES_BY_MAJOR[19] reason and the unreleased model-optional changeset agree with the retirement Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgTnm6d4W7ugSacDJ3j --- .changeset/37686-agent-model-name-optional.md | 6 +++--- .../37712-agent-model-provider-retired.md | 3 +-- packages/spec/scripts/lib/default-changes.ts | 6 +++--- .../ai/agent-model-provider-retirement.test.ts | 18 ++++++++++++++++++ packages/spec/src/ai/agent.zod.ts | 14 +++++++++++++- .../19.agent-model-provider-retired.ts | 6 +++--- 6 files changed, 41 insertions(+), 12 deletions(-) diff --git a/.changeset/37686-agent-model-name-optional.md b/.changeset/37686-agent-model-name-optional.md index 026c9727966..fe22d8f99d0 100644 --- a/.changeset/37686-agent-model-name-optional.md +++ b/.changeset/37686-agent-model-name-optional.md @@ -11,10 +11,10 @@ Skills-docs: follow-up #37711 `AIModelConfigSchema.model` (the `model` key inside an agent's `model` block) is now optional. An agent that only tunes sampling can write `model: { temperature: 0.2 }` without naming a model; the host then runs it on its default model for the environment. Before, the block refused a missing `model`, so such an agent had to invent a model name it did not mean. -`AIModelConfigSchema.provider` loses its `openai` default. A block that names no model also names no provider, so the parse no longer stamps `provider: 'openai'` onto it — that would assert a provider for a model the host picks. The key and its enum are unchanged, and a written `provider` is carried as written. No runtime reads an agent's `model.provider`, so no deployed agent changes behaviour; what changes is the parsed value. +`AIModelConfigSchema.provider` loses its `openai` default. A block that names no model also names no provider, so the parse no longer stamps `provider: 'openai'` onto it — that would assert a provider for a model the host picks. The key itself leaves the spec in the same major (`agent-model-provider-removed`, see that changeset): delete `provider`, the deployment's AI settings choose the provider. No runtime reads an agent's `model.provider`, so no deployed agent changes behaviour; what changes is the parsed value. Unchanged: an explicit `model: { model: 'gpt-4o' }` parses and is carried as written; the block is still strict, so an unknown key is refused; `temperature` still defaults to `0.7`. There is no sentinel value and no tier key. -`@object-ui/app-shell`: the agent preview's model pill appears when the block names a model or a provider, and reads `PROVIDER · MODEL`, `MODEL` or `PROVIDER` from what is written. Before, it keyed on `provider` alone, so a block that named only a model showed no model at all. +`@object-ui/app-shell`: the agent preview's model pill appears when the block names a model, and reads the model name. Before, it keyed on `provider` alone, so a block that named only a model showed no model at all. -What to do: nothing for existing agents. Code that reads `agent.model.model` gets `string | undefined` from the `Agent` type and treats `undefined` as "use the host's default model". Code that read `model.provider` from a parsed agent and relied on `openai` when the author wrote none now reads `undefined`; to keep `openai`, write `provider: 'openai'` in the agent. +What to do: nothing for existing agents. Code that reads `agent.model.model` gets `string | undefined` from the `Agent` type and treats `undefined` as "use the host's default model". Code that read `model.provider` from a parsed agent and relied on `openai` when the author wrote none now reads nothing there: the provider is the deployment's choice. diff --git a/.changeset/37712-agent-model-provider-retired.md b/.changeset/37712-agent-model-provider-retired.md index 08b9d441388..5613a34228a 100644 --- a/.changeset/37712-agent-model-provider-retired.md +++ b/.changeset/37712-agent-model-provider-retired.md @@ -19,13 +19,12 @@ Skills-docs: follow-up #37796 | FROM | TO | |:--|:--| | `model: { provider: 'anthropic', model: 'claude-sonnet-4' }` | `model: { model: 'claude-sonnet-4' }` — the deployment resolves the name among the providers it has turned on | -| `model: { provider: 'openai' }` (a provider and no model name) | `model: {}` or no `model` block — the agent runs on the deployment's default model — or name a model the deployment offers | The one-line fix: delete `provider` from every agent's `model` block; `os migrate meta --from 18 --write` deletes it from agent sources. Writing it after upgrade fails `tsc` (the input type is `never`) and fails the parse with that prescription. `provider: 'openai'`, the default every released 18.x toolchain wrote into a parsed agent's `model` block, is accepted as inert residue and stripped, so agents built and stored by 18.x keep loading. The model name, `temperature`, `maxTokens` and `topP` are unchanged. The retirement kit: -- **`@objectstack/spec`**: `provider` is a `retiredKey()` tombstone on `AIModelConfigSchema`, and the 18.x emitted default is stripped by `acceptRetiredDefaultResidue`. The D2 conversion `agent-model-provider-removed` (lossless, retired from the load path) deletes the key from `agents[]` on every data-at-rest seam (stored rows, built artifacts, `os migrate meta`); the D3 entry `agent-model-provider-retired` names what the upgrade still owes: whether an agent whose author wrote a provider should now name a model the deployment offers or run on its default model. The key is registered in `RETIRED_KEYS_BY_MAJOR[19]`. The liveness ledger's `model` row records the removal. The agent form's model help text no longer names a provider. +- **`@objectstack/spec`**: `provider` is a `retiredKey()` tombstone on `AIModelConfigSchema`, and the 18.x emitted default is stripped by `acceptRetiredDefaultResidue`. The D2 conversion `agent-model-provider-removed` (lossless, retired from the load path) deletes the key from `agents[]` on every data-at-rest seam (stored rows, built artifacts, `os migrate meta`); the D3 entry `agent-model-provider-retired` names what the upgrade still owes: whether the model each agent names is one the target deployment offers. The key is registered in `RETIRED_KEYS_BY_MAJOR[19]`. The liveness ledger's `model` row records the removal. The agent form's model help text no longer names a provider, and a `provider` written at the agent's top level is answered with the same fact instead of a pointer to `model.provider`. The `AIModelConfigSchema` export is now the residue stage's preprocess pipe with a read-through `shape` (the `ViewSharingSchema` shape), so `.extend()`, `.pick()`, `.omit()` and `.partial()` are no longer available on it; extend the inner shape instead. - **`@objectstack/platform-objects`**: the agent form's regenerated help-text labels. - **`@object-ui/app-shell`**: the agent metadata preview shows the model name alone and never a provider pill. - **`@object-ui/console`**: the agent preview sample no longer writes `provider`. diff --git a/packages/spec/scripts/lib/default-changes.ts b/packages/spec/scripts/lib/default-changes.ts index fc37c42842c..9e4a87c3640 100644 --- a/packages/spec/scripts/lib/default-changes.ts +++ b/packages/spec/scripts/lib/default-changes.ts @@ -809,9 +809,9 @@ export const DEFAULT_CHANGES_BY_MAJOR: Readonly { + for (const provider of ['openai', 'anthropic']) { + const r = AgentSchema.safeParse({ ...MODEL_AGENT, provider }); + expect(r.success, provider).toBe(false); + const issues = r.error!.issues; + expect(issues).toHaveLength(1); + expect(issues[0].code).toBe('unrecognized_keys'); + expect(issues[0].path).toEqual([]); + expect(issues[0].message).toContain('there is no provider key on an agent, at the top level or under `model`'); + expect(issues[0].message).toContain('name it in `agent.model.model`'); + expect(issues[0].message).not.toMatch(/model: \{ provider/); + } + // CONTROL: the neighbouring wrong-layer pointer still points. + const temp = AgentSchema.safeParse({ ...MODEL_AGENT, temperature: 0.2 }); + expect(temp.success).toBe(false); + expect(temp.error!.issues[0].message).toContain('write `model: { temperature: … }`'); + }); + it('the walked shape keeps `provider` as a key — the tombstone stays reachable for its refusal', () => { expect(Object.keys(AIModelConfigSchema.shape)).toContain('provider'); expect(Object.keys(AIModelConfigSchema.shape), 'CONTROL: its live neighbour').toContain('model'); diff --git a/packages/spec/src/ai/agent.zod.ts b/packages/spec/src/ai/agent.zod.ts index 2a2589b6676..6223502050f 100644 --- a/packages/spec/src/ai/agent.zod.ts +++ b/packages/spec/src/ai/agent.zod.ts @@ -44,6 +44,15 @@ const MODEL_PROVIDER_RETIRED = + 'and an agent that names no model runs on the deployment\'s default model. ' + 'Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand.'; +// The wrong-layer spelling: `provider` written at the agent's top level. It +// used to point at `model.provider`; with that key retired, it carries the +// same answer (the `memory.longTerm` spellings' precedent below). +const AGENT_PROVIDER_SPELLING_RETIRED = + 'there is no provider key on an agent, at the top level or under `model` — the provider that ' + + 'serves an agent is chosen by the deployment\'s AI settings (`agent.model.provider` was ' + + 'removed in @objectstack/spec 19.0.0, ADR-0049 enforce-or-remove). Delete the key; to pin a ' + + 'model, name it in `agent.model.model`.'; + // [#37712] The default the retired `provider` emitted, captured as a literal // at retirement (`acceptRetiredDefaultResidue`, the #12840 rule for a retired // DEFAULTED key). Every agent a released 18.x toolchain parsed with a `model` @@ -368,7 +377,10 @@ export const AgentSchema = lazySchema(() => strictObject({ + 'with `access` / `permissions`.', // ── Wrong-layer pointers ────────────────────────────────────────────── temperature: 'model settings live under `model` — write `model: { temperature: … }`', - provider: 'model settings live under `model` — write `model: { provider: … }`', + // Not a wrong-layer pointer any more (#37712): `model.provider` was retired, + // so this answers with the retirement's fact instead of steering an author + // onto the tombstone. + provider: AGENT_PROVIDER_SPELLING_RETIRED, maxTokens: 'ambiguous at this level — per-request model output is `model.maxTokens`; a budget ' + 'ceiling for the whole invocation is `guardrails.maxTokensPerInvocation`', diff --git a/packages/spec/src/migrations/entries/semantic/19.agent-model-provider-retired.ts b/packages/spec/src/migrations/entries/semantic/19.agent-model-provider-retired.ts index e7082344f03..9a646dbc8e3 100644 --- a/packages/spec/src/migrations/entries/semantic/19.agent-model-provider-retired.ts +++ b/packages/spec/src/migrations/entries/semantic/19.agent-model-provider-retired.ts @@ -25,9 +25,9 @@ export const entry: SemanticMigration = { + 'four values (`openai`, `azure_openai`, `anthropic`, `local`) neither matched that list nor could ' + 'follow it. Authoring now refuses the key with a prescription, and TypeScript rejects it. The D2 ' + 'conversion `agent-model-provider-removed` deletes it from existing sources and stored rows, ' - + 'losslessly: no value of it ever chose a provider. What no conversion can decide is whether an ' - + 'agent whose author wrote a provider, and no model name, should now name a model the deployment ' - + 'offers or run on its default model', + + 'losslessly: no value of it ever chose a provider. What no conversion can decide is whether the ' + + 'model an agent names is one the target deployment offers: an author who wrote a provider meant ' + + 'a model from it, and the deployment resolves the name only among the providers it has turned on', acceptanceCriteria: 'No agent declares `model.provider`; the key is refused at parse with its prescription, and ' + 'TypeScript rejects it. Every agent that must run on a particular model names it in `model.model`, '