Skip to content

Commit 0fa4888

Browse files
authored
fix: preserve system prompts for SiliconFlow (#209)
* fix: preserve system prompts for DashScope * fix: preserve system prompts for SiliconFlow China * fix(ai): cover official DashScope plan and workspace hosts * fix(ai): cover both official SiliconFlow API hosts
1 parent 71d0cba commit 0fa4888

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎packages/local-runtime-v2/src/service/model-system/resolution/local-model-resolver.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,8 @@ describe('LocalModelResolver custom provider compat overrides', () => {
14481448
});
14491449

14501450
it.each([
1451+
'https://api.siliconflow.cn/v1',
1452+
'https://api.siliconflow.com/v1',
14511453
'https://dashscope.aliyuncs.com/compatible-mode/v1',
14521454
'https://dashscope-intl.aliyuncs.com/compatible-mode/v1',
14531455
'https://dashscope-us.aliyuncs.com/compatible-mode/v1',
@@ -1471,6 +1473,11 @@ describe('LocalModelResolver custom provider compat overrides', () => {
14711473

14721474
it.each([
14731475
['https://api.openai.com/v1', 'developer'],
1476+
['https://api.deepseek.com/v1', 'system'],
1477+
['https://api.siliconflow.cn.example/v1', 'developer'],
1478+
['https://gateway.example/api.siliconflow.cn/v1', 'developer'],
1479+
['https://api.siliconflow.com.example/v1', 'developer'],
1480+
['https://gateway.example/api.siliconflow.com/v1', 'developer'],
14741481
['https://api.moonshot.cn/v1', 'system'],
14751482
['https://api.moonshot.ai/v1', 'system'],
14761483
['https://dashscope.aliyuncs.com.example/v1', 'developer'],
@@ -1487,6 +1494,8 @@ describe('LocalModelResolver custom provider compat overrides', () => {
14871494
});
14881495

14891496
it.each([
1497+
'https://api.siliconflow.cn/v1',
1498+
'https://api.siliconflow.com/v1',
14901499
'https://dashscope.aliyuncs.com/compatible-mode/v1',
14911500
'https://coding.dashscope.aliyuncs.com/v1',
14921501
'https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1',

‎third_party/pi-mono/MINIMAX_CHANGES.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ This directory vendors `pi-mono` as source so MiniMax can patch, validate, and s
1313

1414
No upstream source files are changed in the baseline import.
1515

16+
### 2026-09-19 — preserve the system role for SiliconFlow
17+
18+
- Reason: thinking-enabled OpenAI-compatible requests sent the `developer` role, which is absent from SiliconFlow's documented message schema.
19+
- Affected package: `packages/ai` (`@earendil-works/pi-ai`), OpenAI Completions compatibility detection.
20+
- Change: default to the `system` role on the exact `api.siliconflow.cn` and `api.siliconflow.com` hosts. Preserve thinking, explicit compatibility overrides, other request options, and other endpoints.
21+
- References: [official Chat Completions schema](https://docs.siliconflow.com/en/api-reference/chat-completions/chat-completions) and [pi's SiliconFlow provider proposal](https://github.com/earendil-works/pi/pull/8113) (closed without merging).
22+
- Upstream PR: not opened.
23+
- Validation: outgoing-payload regressions in `packages/local-runtime-v2/src/service/model-system/resolution/local-model-resolver.test.ts`, including both official hosts, unrelated hosts, and explicit compatibility overrides.
24+
1625
### 2026-09-19 — preserve the system role for DashScope
1726

1827
- Reason: DashScope endpoints were treated as supporting the `developer` role, causing thinking-enabled OpenAI-compatible conversations to send an unsupported system-prompt role.

‎third_party/pi-mono/packages/ai/src/providers/openai-completions.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,7 @@ function detectCompat(model: Model<"openai-completions">): ResolvedOpenAIComplet
10941094
const isDashScope =
10951095
/^https?:\/\/(?:dashscope(?:-intl|-us)?|(?:coding(?:-intl)?|cn-hongkong)\.dashscope)\.aliyuncs\.com(?::\d+)?(?:\/|$)/i.test(baseUrl) ||
10961096
/^https?:\/\/[a-z0-9-]+\.(?:cn-beijing|cn-hongkong|ap-southeast-1|ap-northeast-1|eu-central-1|us-east-1)\.maas\.aliyuncs\.com(?::\d+)?(?:\/|$)/i.test(baseUrl);
1097+
const isSiliconFlow = /^https?:\/\/api\.siliconflow\.(?:cn|com)(?::\d+)?(?:\/|$)/i.test(baseUrl);
10971098
const isOpenRouter = provider === "openrouter" || baseUrl.includes("openrouter.ai");
10981099
const isCloudflareWorkersAI = provider === "cloudflare-workers-ai" || baseUrl.includes("api.cloudflare.com");
10991100
const isCloudflareAiGateway = provider === "cloudflare-ai-gateway" || baseUrl.includes("gateway.ai.cloudflare.com");
@@ -1129,7 +1130,7 @@ function detectCompat(model: Model<"openai-completions">): ResolvedOpenAIComplet
11291130
return {
11301131
supportsStore: !isNonStandard,
11311132
supportsDeveloperRole:
1132-
!isKimiCoding && !isDashScope && (isOpenRouterDeveloperRoleModel || (!isNonStandard && !isOpenRouter)),
1133+
!isKimiCoding && !isDashScope && !isSiliconFlow && (isOpenRouterDeveloperRoleModel || (!isNonStandard && !isOpenRouter)),
11331134
supportsReasoningEffort:
11341135
!isGrok && !isZai && !isMoonshot && !isTogether && !isCloudflareAiGateway && !isNvidia && !isAntLing,
11351136
supportsUsageInStreaming: true,

0 commit comments

Comments
 (0)