fix: normalize developer role to system for OpenAI-format providers (#1011)

Deepseek API (and likely other providers) reject messages with
role: 'developer' — only accept system, user, assistant, tool.
filterToOpenAIFormat() normalizes content blocks but never touched
message roles, so developer passed through unmodified and caused
400 errors (issue #773).

Fix: add one-line developer → system mapping in filterToOpenAIFormat()
before role-specific logic. This is the common normalization point
called for all targetFormat=openai providers (Deepseek, Groq, Mistral,
Perplexity, Together, Fireworks, Cerebras, xAI, NVIDIA, etc.)

Closes #773
This commit is contained in:
Tran Hoang Nguyen 2026-05-11 15:57:28 +07:00 committed by GitHub
parent 06291b290f
commit 80a2bfcfd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,6 +10,9 @@ export function filterToOpenAIFormat(body) {
if (!body.messages || !Array.isArray(body.messages)) return body;
body.messages = body.messages.map(msg => {
// Normalize developer role to system (many providers don't support developer)
if (msg.role === "developer") msg = { ...msg, role: "system" };
// Keep tool messages as-is (OpenAI format)
if (msg.role === "tool") return msg;