pi-mono/scripts/model-catalog-minimum-version.mjs
David Brailovsky b82477b7bb
fix(ai,coding-agent): make system the default instruction role in openai-completions (#12134)
TLDR:
On chat-completions api, change the default instruction role from
developer to system.

Inspired by: #12101 by @qoli

---
The trigger was #10741: Groq's qwen/qwen3.8-27b failed on the first
message:
`400: minijinja: rendering failed: raise_exception: Unexpected message
role.`

Problem: openai-completions sent the system messages of every reasoning
model with the `developer` role unless the catalog turned it off.
`developer` is OpenAI's role; many other hosts' chat templates reject
it, as Groq's Qwen template does.

Every new OpenAI-compatible provider or reasoning model hit the same bug
until someone added `supportsDeveloperRole: false` to the catalog; about
20 provider files carried that line. Nothing in models.dev says which
role a model accepts, so the catalog could not get this right on its
own.

Solution: detectCompat() now defaults supportsDeveloperRole to true only
for api.openai.com. Every other host gets `system`. This applies to the
initial system prompt and to mid-conversation system messages.

Built-in models whose role changes from developer to system:
- groq: 5 (gpt-oss and Qwen)
- xiaomi, xiaomi-token-plan-*: 9 MiMo models
- openrouter: 89 openai/* and anthropic/* models; 12 of them (newer GPT
models) also support mid-conversation system messages
(supportsMidConvoSystemMessages), which change role too All other
built-in Chat Completions models already sent `system`.

Why the default is only api.openai.com:
- api.openai.com keeps `developer` because OpenAI documents it as the
role for its reasoning models. In practice this rarely matters: the
built-in OpenAI models all use the Responses API, so it only affects
custom models that call OpenAI through openai-completions.
- Azure is excluded. Its built-in OpenAI models also use the Responses
API; its only built-in Chat Completions model is DeepSeek, which needs
`system`.
- OpenRouter is excluded: its Chat Completions reference accepts
`system` ("System message for setting behavior") and `developer` with
the same fields, and gives no reason to prefer `developer` for any model
(https://openrouter.ai/docs/api/api-reference/chat/create-a-chat-completion).
The openai/* and anthropic/* exception came in with #5309 without a
reported need.
- compat.supportsDeveloperRole still overrides the default.
- The Responses API has its own setting and is unchanged.

The now-redundant `supportsDeveloperRole: false` lines are removed from
the catalog and the llama extension.

How we checked it is safe: live requests to the affected hosts, each
model given the same instruction once as `developer` and once as
`system`:
- Groq qwen/qwen3.8-27b: developer 400, system OK. Groq gpt-oss-20b:
both OK.
- Xiaomi mimo-v2.6-pro and mimo-v2.6-flash: both roles OK.
- OpenRouter openai/gpt-5-mini, openai/gpt-oss-20b,
anthropic/claude-haiku-4.5, moonshotai/kimi-k2.6, qwen/qwen3.6-plus,
deepseek/deepseek-v4-pro: both roles OK.
- OpenRouter openai/gpt-5.4-mini and openai/gpt-5.5 with an instruction
added mid-conversation: both roles OK.

Released clients: they fetch new catalogs from pi.dev and still default
supportsDeveloperRole to true, so the removed `false` lines would make
them send `developer` to hosts that reject it. MINIMUM_PI_VERSION is
raised to 1.5.3 so they keep the last catalog published for them.

closes #10741 #12101
2026-11-20 09:32:28 +01:00

11 lines
782 B
JavaScript

// The oldest pi version that receives model catalogs published from this checkout.
// pi.dev keeps one catalog per minimum version; clients older than this keep the
// last catalog published under the previous minimum and stop receiving updates.
//
// Bump this only when generated model metadata requires behavior unavailable in
// older pi clients, in the same commit as the change that requires it.
// 1.2.1: kimi-coding models use openai-completions at /coding/v1; older clients only
// implement anthropic-messages for kimi-coding and ignore a model's api.
// 1.5.3: Chat Completions models no longer carry supportsDeveloperRole: false; older
// clients default it to true and would send the developer role, which most hosts reject.
export const MINIMUM_PI_VERSION = "1.5.3";