diff --git a/packages/local-runtime-v2/src/service/model-system/resolution/local-model-resolver.test.ts b/packages/local-runtime-v2/src/service/model-system/resolution/local-model-resolver.test.ts index b3bd4e53c..a9124e94a 100644 --- a/packages/local-runtime-v2/src/service/model-system/resolution/local-model-resolver.test.ts +++ b/packages/local-runtime-v2/src/service/model-system/resolution/local-model-resolver.test.ts @@ -1448,6 +1448,8 @@ describe('LocalModelResolver custom provider compat overrides', () => { }); it.each([ + 'https://api.siliconflow.cn/v1', + 'https://api.siliconflow.com/v1', 'https://dashscope.aliyuncs.com/compatible-mode/v1', 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1', 'https://dashscope-us.aliyuncs.com/compatible-mode/v1', @@ -1471,6 +1473,11 @@ describe('LocalModelResolver custom provider compat overrides', () => { it.each([ ['https://api.openai.com/v1', 'developer'], + ['https://api.deepseek.com/v1', 'system'], + ['https://api.siliconflow.cn.example/v1', 'developer'], + ['https://gateway.example/api.siliconflow.cn/v1', 'developer'], + ['https://api.siliconflow.com.example/v1', 'developer'], + ['https://gateway.example/api.siliconflow.com/v1', 'developer'], ['https://api.moonshot.cn/v1', 'system'], ['https://api.moonshot.ai/v1', 'system'], ['https://dashscope.aliyuncs.com.example/v1', 'developer'], @@ -1487,6 +1494,8 @@ describe('LocalModelResolver custom provider compat overrides', () => { }); it.each([ + 'https://api.siliconflow.cn/v1', + 'https://api.siliconflow.com/v1', 'https://dashscope.aliyuncs.com/compatible-mode/v1', 'https://coding.dashscope.aliyuncs.com/v1', 'https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1', diff --git a/third_party/pi-mono/MINIMAX_CHANGES.md b/third_party/pi-mono/MINIMAX_CHANGES.md index 66bfb52cf..10dd06116 100644 --- a/third_party/pi-mono/MINIMAX_CHANGES.md +++ b/third_party/pi-mono/MINIMAX_CHANGES.md @@ -13,6 +13,15 @@ This directory vendors `pi-mono` as source so MiniMax can patch, validate, and s No upstream source files are changed in the baseline import. +### 2026-09-19 — preserve the system role for SiliconFlow + +- Reason: thinking-enabled OpenAI-compatible requests sent the `developer` role, which is absent from SiliconFlow's documented message schema. +- Affected package: `packages/ai` (`@earendil-works/pi-ai`), OpenAI Completions compatibility detection. +- 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. +- 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). +- Upstream PR: not opened. +- 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. + ### 2026-09-19 — preserve the system role for DashScope - Reason: DashScope endpoints were treated as supporting the `developer` role, causing thinking-enabled OpenAI-compatible conversations to send an unsupported system-prompt role. diff --git a/third_party/pi-mono/packages/ai/src/providers/openai-completions.ts b/third_party/pi-mono/packages/ai/src/providers/openai-completions.ts index 2b3a94283..2c08bf0cf 100644 --- a/third_party/pi-mono/packages/ai/src/providers/openai-completions.ts +++ b/third_party/pi-mono/packages/ai/src/providers/openai-completions.ts @@ -1094,6 +1094,7 @@ function detectCompat(model: Model<"openai-completions">): ResolvedOpenAIComplet const isDashScope = /^https?:\/\/(?:dashscope(?:-intl|-us)?|(?:coding(?:-intl)?|cn-hongkong)\.dashscope)\.aliyuncs\.com(?::\d+)?(?:\/|$)/i.test(baseUrl) || /^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); + const isSiliconFlow = /^https?:\/\/api\.siliconflow\.(?:cn|com)(?::\d+)?(?:\/|$)/i.test(baseUrl); const isOpenRouter = provider === "openrouter" || baseUrl.includes("openrouter.ai"); const isCloudflareWorkersAI = provider === "cloudflare-workers-ai" || baseUrl.includes("api.cloudflare.com"); const isCloudflareAiGateway = provider === "cloudflare-ai-gateway" || baseUrl.includes("gateway.ai.cloudflare.com"); @@ -1129,7 +1130,7 @@ function detectCompat(model: Model<"openai-completions">): ResolvedOpenAIComplet return { supportsStore: !isNonStandard, supportsDeveloperRole: - !isKimiCoding && !isDashScope && (isOpenRouterDeveloperRoleModel || (!isNonStandard && !isOpenRouter)), + !isKimiCoding && !isDashScope && !isSiliconFlow && (isOpenRouterDeveloperRoleModel || (!isNonStandard && !isOpenRouter)), supportsReasoningEffort: !isGrok && !isZai && !isMoonshot && !isTogether && !isCloudflareAiGateway && !isNvidia && !isAntLing, supportsUsageInStreaming: true,