Skip to content
Merged
20 changes: 20 additions & 0 deletions .changeset/37686-agent-model-name-optional.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@objectstack/spec': minor
'@object-ui/app-shell': patch
---

feat(spec): an agent's model name is optional — absent means the host's default model for the environment; `provider` no longer defaults to `openai`

Clause-②: yes (widening)
Metadata-protocol: semantic
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.

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.

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.
10 changes: 5 additions & 5 deletions content/docs/references/ai/agent.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const result = AIModelConfigSchema.parse(data);

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **provider** | `Enum<'openai' \| 'azure_openai' \| 'anthropic' \| 'local'>` | optional (default: `"openai"`) | |
| **model** | `string` | ✅ | Model name (e.g. gpt-4, claude-3-opus) |
| **provider** | `Enum<'openai' \| 'azure_openai' \| 'anthropic' \| 'local'>` | optional | |
| **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 | |
| **topP** | `number` | optional | |
Expand All @@ -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** | `{ provider?: Enum<'openai' \| 'azure_openai' \| 'anthropic' \| 'local'>; model?: string; temperature?: number; maxTokens?: 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) |
Expand All @@ -72,8 +72,8 @@ const result = AIModelConfigSchema.parse(data);

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **provider** | `Enum<'openai' \| 'azure_openai' \| 'anthropic' \| 'local'>` | optional (default: `"openai"`) | |
| **model** | `string` | ✅ | Model name (e.g. gpt-4, claude-3-opus) |
| **provider** | `Enum<'openai' \| 'azure_openai' \| 'anthropic' \| 'local'>` | optional | |
| **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 | |
| **topP** | `number` | optional | |
Expand Down
1 change: 0 additions & 1 deletion packages/spec/authorable-defaults/ai.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"description": "Ratchet of the DEFAULT VALUE of every authorable key in one category that has one (#4666) — what a metadata author gets when they omit the key, which for AI-authored metadata is most of the time. Sharded by category like authorable-surface/; the gate reads the whole authorable-defaults/ directory as ONE set. Each line is \"<def>:<key> = <canonical JSON>\". Additions (a NEW key that ships with a default) are auto-recorded — commit the change. CHANGING, ADDING or REMOVING the default of a key that already existed is NOT auto-recorded: it silently alters the behaviour of already-deployed metadata, so it fails check:authorable-surface until it is declared in DEFAULT_CHANGES_BY_MAJOR (scripts/lib/default-changes.ts). Constraints are deliberately NOT recorded here — a tightened bound REJECTS a document loudly, which is a different and self-announcing class (maintainer ruling on #4666, direction B). See #4666, #4661.",
"category": "ai",
"defaults": [
"ai/AIModelConfig:provider = \"openai\"",
"ai/AIModelConfig:temperature = 0.7",
"ai/Agent:active = true",
"ai/Agent:surface = \"ask\"",
Expand Down
16 changes: 16 additions & 0 deletions packages/spec/scripts/lib/default-changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,4 +798,20 @@ export const DEFAULT_CHANGES_BY_MAJOR: Readonly<Record<number, readonly Declared
+ SEED_MODE_CREATE_ONLY_REASON,
},
],
19: [
{
key: 'ai/AIModelConfig:provider',
from: '"openai"',
to: '(none)',
reason:
'An agent\'s `model` block may now omit the model name, and an absent name means the host\'s '
+ 'default model for the environment. 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. No runtime reads an agent\'s `model.provider` (the AI service reads '
+ 'the name, `temperature` and `maxTokens` only), so no deployed agent changes behaviour; what '
+ 'changes is the parsed value. Reading `AgentParsed[\'model\'][\'provider\']` now yields the '
+ 'enum or `undefined` where it yielded the enum, and a display that showed `openai` for a '
+ 'block that never wrote it shows nothing. To keep `openai`, write `provider: \'openai\'`.',
},
],
};
43 changes: 42 additions & 1 deletion packages/spec/src/ai/agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@ describe('AIModelConfigSchema', () => {
};

const result = AIModelConfigSchema.parse(config);
expect(result.provider).toBe('openai');
expect(result.provider).toBeUndefined();
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;

Expand All @@ -48,6 +55,40 @@ describe('AIModelConfigSchema', () => {
expect(() => AIModelConfigSchema.parse(config)).not.toThrow();
});

it('accepts a config that omits the model name — absent means the environment default', () => {
const result = AIModelConfigSchema.parse({ temperature: 0.2 });
expect(result.model).toBeUndefined();
expect(result.temperature).toBe(0.2);
expect(result.provider).toBeUndefined();
expect(AIModelConfigSchema.parse({}).model).toBeUndefined();
});

it('keeps an explicit model name exactly as written', () => {
expect(AIModelConfigSchema.parse({ model: 'x' }).model).toBe('x');
});

it('still refuses an unknown key in a config without a model name', () => {
const result = AIModelConfigSchema.safeParse({ temperature: 0.2, tier: 'fast' });
expect(result.success).toBe(false);
expect(result.error?.issues.some((i) => i.code === 'unrecognized_keys')).toBe(true);
});

it('still refuses a non-string model name', () => {
expect(AIModelConfigSchema.safeParse({ model: 4 }).success).toBe(false);
});

it('an agent whose model block only sets temperature parses', () => {
const agent = AgentSchema.parse({
name: 'ask_helper',
label: 'Ask Helper',
role: 'Helper',
instructions: 'Answer questions.',
model: { temperature: 0.2 },
});
expect(agent.model?.model).toBeUndefined();
expect(agent.model?.temperature).toBe(0.2);
});

it('should enforce temperature constraints', () => {
expect(() => AIModelConfigSchema.parse({
model: 'gpt-4',
Expand Down
8 changes: 6 additions & 2 deletions packages/spec/src/ai/agent.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ export const AIModelConfigSchema = lazySchema(() => strictObject({
top_p: 'topP', nucleus: 'topP',
},
}, {
provider: z.enum(['openai', 'azure_openai', 'anthropic', 'local']).default('openai'),
model: z.string().describe('Model name (e.g. gpt-4, claude-3-opus)'),
provider: z.enum(['openai', 'azure_openai', 'anthropic', 'local']).optional(),
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 '
+ '(e.g. `temperature`) need not name a model.',
),
temperature: z.number().min(0).max(2).default(0.7),
maxTokens: z.number().optional(),
topP: z.number().optional(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ describe('AgentPreview renders what a spec-valid agent declares', () => {
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' } });
expect(screen.getByText('gpt-4o')).toBeTruthy();
expect(screen.queryByText(/openai/)).toBeNull();
});

it('shows no model pill for a block that names neither, so the environment default is not given a name', () => {
renderPreview({ ...VALID_DRAFT, model: { temperature: 0.2 } });
expect(screen.queryByText('gpt-4o')).toBeNull();
expect(screen.queryByText(/openai/)).toBeNull();
});

it('says where tools come from, so the missing TOOLS block is not read as a gap', () => {
renderPreview(VALID_DRAFT);
expect(screen.getByText(/tools come from the attached skills/i)).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ export function AgentPreview({ name, draft, locale }: MetadataPreviewProps) {
label={tr(active ? 'engine.agentPreview.active' : 'engine.agentPreview.disabled', locale)}
tone={active ? 'green' : 'gray'}
/>
{model.provider && <Pill icon={Sparkles} label={`${model.provider}${model.model ? ` · ${model.model}` : ''}`} mono />}
{(model.provider || model.model) && (
<Pill icon={Sparkles} label={[model.provider, model.model].filter(Boolean).join(' · ')} mono />
)}
{model.temperature != null && (
<Pill icon={Gauge} label={tFormat('engine.agentPreview.temperature', locale, { value: String(model.temperature) })} />
)}
Expand Down
Loading