Repository navigation
Commit 3e87d7b
feat(spec): an agent's model name becomes optional — absent means the environment's default model (#37697)
<!-- claude-projects-attribution: {"github_login":"hotlong"} -->
_Requested by **Jack** · [project
thread](https://claude.ai/code/project/chan_01EF41AQooqveF2DGD8nqPzS?thread=cmsg_01EF41AQooqveF2DGD8nqPzS4Qk9xEo3NPMmxK8sJfyTfe)_
Fixes #37686
Clause-②: yes (widening)
Metadata-protocol: semantic
Skills-docs: follow-up #37711
## 维护者速读
- 写 agent 元数据的人和 AI:模型块里可以不写模型名,只写温度等参数;不写就用部署的默认模型,写了照旧。没写供应商时也不再自动当成
openai。
- 属于「AI 模型档位」专题第一阶段,按你在决策卡上选的「框架允许省略 model」落地。
- 只放宽不收紧,旧 agent 全部照常解析,运行时行为不变;出问题可直接撤回这个 PR。
- 无。
## What changes
- `packages/spec/src/ai/agent.zod.ts`: `AIModelConfigSchema.model` goes
from a required `z.string()` to `z.string().optional()`. Its description
now says that an absent model name means the host's default model for
the environment. The block stays strict (unknown keys refused);
`temperature` still defaults to `0.7`. No sentinel value, no tier key
(phase 2 of objectstack-ai/cloud#5055).
- Same file, contract review S1 (seat amendment of the order's step 4):
`provider` loses `.default('openai')` and becomes `.optional()`; key and
enum unchanged. A block that names no model no longer parses to
`provider: 'openai'`, which asserted a provider for a model the host
picks. The default move is declared in `DEFAULT_CHANGES_BY_MAJOR` under
`19` (`packages/spec/scripts/lib/default-changes.ts`) with its
consumer-facing reason, and `authorable-defaults/ai.json` drops the
line. No runtime reads an agent's `model.provider`, so no deployed agent
changes behaviour. Not retired: enforce-or-remove for `provider` is
#37712.
- `packages/spec/src/ai/agent.test.ts`: six new cases (temperature-only
block parses with `model` undefined; an explicit name is carried as
written; an unknown key is still refused as `unrecognized_keys`; a
non-string name is still refused; a whole agent with `model: {
temperature: 0.2 }` parses; a block with no `provider` parses without
one, a written one is carried, an off-enum one is refused), and the
minimal-config case now expects no `provider`.
-
`ui/packages/app-shell/src/views/metadata-admin/previews/AgentPreview.tsx`
(contract review S2, file surface widened by the seat): the model pill
showed only when `model.provider` was set, so a block naming a model and
no provider lost the model name once the default was gone. It now shows
when a model or a provider is written and reads `PROVIDER · MODEL`,
`MODEL` or `PROVIDER`; a block that names neither shows no pill, so the
environment default is not given a name. Two new cases in
`AgentPreview.test.tsx`.
- Generated: `content/docs/references/ai/agent.mdx` (`gen:docs`) and
`packages/spec/authorable-defaults/ai.json` (written by the build).
authorable-surface, api-surface, the JSON-schema manifest and the
metadata-form translations needed no change: the key set is unchanged,
and the translations carry only the `model.model` label.
- `.changeset/37686-agent-model-name-optional.md`: `@objectstack/spec`
minor and `@object-ui/app-shell` patch, with the three declaration
lines; `semantic` because a default moved (it outranks `added`).
Read first (by risk): `packages/spec/src/ai/agent.zod.ts` (the two
contract hunks), `packages/spec/scripts/lib/default-changes.ts` (the
declared default move), then the changeset.
## Tests
All at head `b3238ea8`, run through `scripts/pm/os-verify-lock.sh` on a
shared container. The spec readings were taken at `db5f0e7d`; the only
later commit touches `ui/` and the changeset prose.
- `pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2
src/ai/agent.test.ts` → Test Files 1 passed, Tests 70 passed.
- `pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin/previews/AgentPreview.test.tsx
packages/app-shell/src/views/metadata-admin/previews/AgentPreview.emptyCollection-8520.test.tsx`
→ Test Files 2 passed, Tests 24 passed.
- Ablations (each fix committed first, the mutation made on disk, then
restored from HEAD): without `model`'s `.optional()`, Tests 2 failed /
67 passed; with `provider`'s `.default('openai')` restored, Tests 3
failed / 67 passed; with the preview pill keyed on `provider` again,
Tests 1 failed / 17 passed (the name-only case). The other new cases pin
behaviour that holds either way.
- `pnpm --filter @objectstack/spec test` → Test Files 903 passed (903),
Tests 28557 passed, 1 todo.
- `pnpm --filter @objectstack/spec typecheck` → exit 0 (includes
`check:test-typecheck`, 52 files held in the ledger, unchanged).
- `pnpm --filter @objectstack/spec build && pnpm --filter
@objectstack/spec check:generated` → exit 0 after `gen:docs`; the
build's default ratchet accepts the declared `ai/AIModelConfig:provider`
move.
- `@object-ui/app-shell` has no `typecheck` script; its types are `Type
Check UI`'s, read from this PR's check-runs.
<details><summary>Local gate families: 117 derived, 117 run, all exit
0</summary>
`node scripts/pm/dispatch-gates.mjs --commands` derived 117 families for
this change set at `b3238ea8` (the three new ones read `ui/`:
`check-sdui-manifest` and its self-test, and `vitest run scripts/` under
`ui/`); each was run and its exit code captured before any pipe, all 0.
`--ran` reconciliation: "117 derived famil(ies) accounted for — 117 run,
0 NOT-MEASURED (a DERIVED zero — all 117 recorded an exit code and none
of them is 3)". Families outside the derivation (repo-wide lint, UI
lanes, Test Core's repo project) are CI's.
</details>
## Acceptance notes
- Premise re-checked on `origin/main` 6d106a1: the card's `Re-check:`
grep answers 1 hit at `agent.zod.ts:38`.
- Readers of an agent's `model.model` in this repo:
`packages/spec/src/system/metadata-list-registry.ts` (list column;
`valueAtPath` answers `undefined`, so the cell is empty for an agent
with no model, which is the card's "empty/default" outcome);
`AgentPreview.tsx` (its model pill, reworked here for S2, renders only
what is written); tests only otherwise. None breaks on `undefined`. In
cloud (read-only, `origin/main` 63427ae),
`packages/service-ai/src/agent-runtime.ts:1028` assigns `options.model =
agent.model.model`, so an absent name leaves `options.model` undefined
there; how cloud resolves that to its default is the cloud card's
(objectstack-ai/cloud#5055) after a pin move.
- `provider`: declared, not enforced. No runtime in this repo reads an
agent's `model.provider`, and in cloud `origin/main` 63427ae
`agent-runtime.ts` reads only `model`, `temperature` and `maxTokens`
from the agent's block (the `model.provider` read in
`vercel-adapter.ts:391` is the AI SDK model object, not the agent
config). Its default is dropped here (S1); keep-or-retire is #37712.
- Display (S2): the preview reads the raw draft, so a draft that wrote a
model and no provider showed no pill even before this PR; the S2 fix
shows its name either way. A parsed or stored block no longer carries an
invented `openai`.
- Skills docs: `skills/objectstack-ai/SKILL.md` "Model Configuration"
still teaches `model` as a required free string with `provider` default
`openai`, and cites `agent.zod.ts:36-40`; the `skills-tools-knowledge`
eval expects "a free-string `model`". Follow-up #37711.
- Overlap: #37676 also opens a `19` bucket in `default-changes.ts` (and
touches `authorable-defaults/ai.json`); `main` merges cleanly here, the
two PRs conflict textually there, and whichever lands second keeps both
entries.
## Verification
Two-minute check: `pnpm --filter @objectstack/spec exec vitest run
src/ai/agent.test.ts` → 70 passed; revert the `model` `.optional()` and
two of the new cases go red; restore the `provider` default and three go
red.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Q4EjjQgJ62YaG4EAxNLuqP)_
<!-- signed: epic:#5055#1 · hotlong · session_01Q4EjjQgJ62YaG4EAxNLuqP
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ce4d8c7 commit 3e87d7b
8 files changed
Lines changed: 104 additions & 10 deletions
File tree
- .changeset
- content/docs/references/ai
- packages/spec
- authorable-defaults
- scripts/lib
- src/ai
- ui/packages/app-shell/src/views/metadata-admin/previews
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
798 | 798 | | |
799 | 799 | | |
800 | 800 | | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
801 | 817 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
| |||
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
51 | 92 | | |
52 | 93 | | |
53 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
78 | 90 | | |
79 | 91 | | |
80 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
157 | 159 | | |
158 | 160 | | |
159 | 161 | | |
| |||
0 commit comments