fix: inject system prompt as role:system message (server ignores top-level system field)

Verified via behavior test against Qoder API (ultimate model):
- system field with a directive: model ignores it (prompt_tokens=15, normal reply)
- same directive in messages[0] role:system: model obeys (prompt_tokens=97, marker reply)

The server's top-level `system` field in the request body is never fed to
the model, so pi's systemPrompt (language prefs, tool rules, agent instructions)
was silently dropped. Inject it as a leading role:system message instead, which
the server honors.
This commit is contained in:
liyanan
2026-07-26 07:16:40 +08:00
parent b8980b68b8
commit 6964615056
2 changed files with 8 additions and 3 deletions
+7 -2
View File
@@ -189,8 +189,13 @@ export function streamQoder(
chat_prompt: "",
image_urls: null,
aliyun_user_type: "",
system: systemText,
messages: normalizedMessages,
// Qoder's server ignores the top-level `system` field (verified: the
// model never sees it). Inject the system prompt as a leading
// role:system message instead, which the server does honor.
system: "",
messages: systemText
? [{ role: "system", content: systemText }, ...normalizedMessages]
: normalizedMessages,
tools: toolsRaw || [],
parameters: { max_tokens: maxTokens },
chat_context: {