Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1384,19 +1384,22 @@ describe('LocalModelResolver custom provider compat overrides', () => {
});

// The incident was a wire-level symptom: pi chooses the system prompt role from the
// resolved compat, so these two cases pin the request pi would actually send.
// resolved compat, so these cases pin the request pi would actually send.
const reasoningModelConfig: LocalModelConfig = {
reasoning: true,
thinking: { effortOptions: ['low', 'light', 'max'] },
};

const systemPromptRoleFor = async (compat: LocalModelConfig['compat']) => {
const systemPromptRoleFor = async (
compat: LocalModelConfig['compat'],
baseURL = 'https://gateway.example/v1',
) => {
const resolver = new LocalModelResolver({
byokConfigGetter: () => ({
custom_provider: {
gateway: {
api: 'openai-completions',
options: { apiKey: 'gateway-key', baseURL: 'https://gateway.example/v1' },
options: { apiKey: 'gateway-key', baseURL },
models: { 'kimi-k2-thinking': { ...reasoningModelConfig, compat } },
},
},
Expand Down Expand Up @@ -1443,4 +1446,30 @@ describe('LocalModelResolver custom provider compat overrides', () => {
it('still sends `developer` when the gateway declares nothing, reproducing the incident', async () => {
expect(await systemPromptRoleFor(undefined)).toBe('developer');
});

it.each([
'https://api.kimi.com/coding/v1',
'https://api.kimi.ai/coding/v1',
])('keeps the system role for a thinking model at %s', async (baseURL) => {
expect(await systemPromptRoleFor(undefined, baseURL)).toBe('system');
});

it.each([
['https://api.openai.com/v1', 'developer'],
['https://api.moonshot.cn/v1', 'system'],
['https://api.moonshot.ai/v1', 'system'],
['https://api.kimi.com.example/v1', 'developer'],
['https://gateway.example/api.kimi.com/coding/v1', 'developer'],
])('preserves the system prompt role for %s', async (baseURL, role) => {
expect(await systemPromptRoleFor(undefined, baseURL)).toBe(role);
});

it('honors an explicit developer-role override on a Kimi Coding endpoint', async () => {
expect(
await systemPromptRoleFor(
{ supportsDeveloperRole: true },
'https://api.kimi.com/coding/v1',
),
).toBe('developer');
});
});
8 changes: 8 additions & 0 deletions third_party/pi-mono/MINIMAX_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ 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 Kimi Coding

- Reason: Kimi Coding endpoints were treated as supporting the `developer` role, causing thinking-enabled OpenAI-compatible conversations to send an unsupported system-prompt role.
- Affected package: `packages/ai` (`@earendil-works/pi-ai`), OpenAI Completions compatibility detection.
- Change: default to the `system` role for `api.kimi.com` and `api.kimi.ai`. Preserve thinking, other request options, explicit compatibility overrides, and other providers.
- Upstream PR: not opened.
- Validation: offline request-payload regressions in `packages/local-runtime-v2/src/service/model-system/resolution/local-model-resolver.test.ts`. Live Kimi Coding validation requires a Coding Plan key and remains untested.

### 2026-08-31 — Windows PowerShell ConstrainedLanguage compatibility

- Reason: the Windows PowerShell 5.1 stdin wrapper called `Parser.ParseInput`, `ScriptBlock.Create`, and other restricted .NET APIs before user commands. Under enterprise App Control / AppLocker `ConstrainedLanguage`, the wrapper therefore failed before commands such as Python could run.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,7 @@ function detectCompat(model: Model<"openai-completions">): ResolvedOpenAIComplet
const isTogether =
provider === "together" || baseUrl.includes("api.together.ai") || baseUrl.includes("api.together.xyz");
const isMoonshot = provider === "moonshotai" || provider === "moonshotai-cn" || baseUrl.includes("api.moonshot.");
const isKimiCoding = /^https?:\/\/api\.kimi\.(?:com|ai)(?::\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");
Expand Down Expand Up @@ -1124,7 +1125,7 @@ function detectCompat(model: Model<"openai-completions">): ResolvedOpenAIComplet

return {
supportsStore: !isNonStandard,
supportsDeveloperRole: isOpenRouterDeveloperRoleModel || (!isNonStandard && !isOpenRouter),
supportsDeveloperRole: !isKimiCoding && (isOpenRouterDeveloperRoleModel || (!isNonStandard && !isOpenRouter)),
supportsReasoningEffort:
!isGrok && !isZai && !isMoonshot && !isTogether && !isCloudflareAiGateway && !isNvidia && !isAntLing,
supportsUsageInStreaming: true,
Expand Down
Loading