🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
💄 style(moonshot): enhance preserveThinking support for kimi models (#15722)
sxjeruf1e06012b193
diff --git a/apps/server/src/modules/AgentRuntime/RuntimeExecutors.ts b/apps/server/src/modules/AgentRuntime/RuntimeExecutors.tsindex de7c8541f80..af390b8d433 100644--- a/apps/server/src/modules/AgentRuntime/RuntimeExecutors.ts+++ b/apps/server/src/modules/AgentRuntime/RuntimeExecutors.ts@@ -42,6 +42,7 @@ import {applyModelExtendParams,type ChatStreamPayload,consumeStreamUntilDone,+ isKimiAlwaysPreserveThinkingModel,type ModelExtendParams,} from '@lobechat/model-runtime';import {@@ -935,15 +936,23 @@ export const createRuntimeExecutors = (const modelSupportsPreserveThinkingFromCard =Array.isArray(modelExtendParams) && modelExtendParams.includes('preserveThinking');+ // Kimi K2.7+ Code has preserved thinking always active and cannot opt out.+ const modelForcesPreserveThinking =+ (provider === 'moonshot' || provider === BRANDING_PROVIDER) &&+ isKimiAlwaysPreserveThinkingModel(model);const providerSupportsPreserveThinkingFallback =- provider === 'qwen' || provider === 'zhipu';+ provider === 'qwen' || provider === 'zhipu' || provider === 'moonshot';const modelSupportsPreserveThinking =+ modelForcesPreserveThinking ||modelSupportsPreserveThinkingFromCard ||(!modelCard && providerSupportsPreserveThinkingFallback);- shouldReplayAssistantReasoning = preserveThinkingRequested && modelSupportsPreserveThinking;- preserveThinkingForPayload =- modelSupportsPreserveThinking && typeof preserveThinkingConfigured === 'boolean'+ shouldReplayAssistantReasoning =+ (modelForcesPreserveThinking || preserveThinkingRequested) &&+ modelSupportsPreserveThinking;+ preserveThinkingForPayload = modelForcesPreserveThinking+ ? true+ : modelSupportsPreserveThinking && typeof preserveThinkingConfigured === 'boolean'? preserveThinkingConfigured: undefined;diff --git a/apps/server/src/modules/AgentRuntime/__tests__/RuntimeExecutors.test.ts b/apps/server/src/modules/AgentRuntime/__tests__/RuntimeExecutors.test.tsindex 3f4dbf850cc..a1e83f9518a 100644--- a/apps/server/src/modules/AgentRuntime/__tests__/RuntimeExecutors.test.ts+++ b/apps/server/src/modules/AgentRuntime/__tests__/RuntimeExecutors.test.ts@@ -1,4 +1,5 @@import { type AgentState } from '@lobechat/agent-runtime';+import { BRANDING_PROVIDER } from '@lobechat/business-const';import { consumeStreamUntilDone } from '@lobechat/model-runtime';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';@@ -23,6 +24,11 @@ const mockBuiltinModels = vi.hoisted(() => [providerId: 'qwen',settings: { extendParams: ['preserveThinking'] },},+ {+ abilities: { functionCall: true, video: true, vision: true },+ id: 'kimi-k2.7-code',+ providerId: 'moonshot',+ },{abilities: { functionCall: false, video: false, vision: false },id: 'no-tools-model',@@ -68,6 +74,8 @@ vi.mock('@lobechat/model-runtime', () => ({// retry classifier path.ERROR_CODE_SPECS: {},getErrorCodeSpec: () => undefined,+ isKimiAlwaysPreserveThinkingModel: (model: string) =>+ /^kimi-k2\.(?:[7-9]|\d{2,})-code(?:$|-)/.test(model),refineErrorCode: () => undefined,}));@@ -562,6 +570,98 @@ describe('RuntimeExecutors', () => {);});+ it('should force assistant reasoning replay for Kimi K2.7 Code even when preserveThinking is disabled', async () => {+ const mockChat = vi.fn().mockImplementation(async (_payload, options) => {+ await options?.callback?.onThinking?.('kimi preserved reasoning');+ await options?.callback?.onText?.('answer');+ return new Response('done');+ });+ vi.mocked(initModelRuntimeFromDB).mockResolvedValueOnce({ chat: mockChat } as any);++ const ctxWithConfig: RuntimeExecutorContext = {+ ...ctx,+ agentConfig: {+ chatConfig: { preserveThinking: false },+ plugins: [],+ systemRole: 'test',+ },+ };++ const executors = createRuntimeExecutors(ctxWithConfig);+ const state = createMockState({+ modelRuntimeConfig: {+ model: 'kimi-k2.7-code',+ provider: 'moonshot',+ },+ });++ const instruction = {+ payload: {+ messages: [{ content: 'Hello', role: 'user' }],+ model: 'kimi-k2.7-code',+ provider: 'moonshot',+ },+ type: 'call_llm' as const,+ };++ const result = await executors.call_llm!(instruction, state);+ const assistant = result.newState.messages.at(-1) as any;++ expect(assistant.reasoning).toEqual({+ content: 'kimi preserved reasoning',+ });+ expect(mockChat).toHaveBeenCalledWith(+ expect.objectContaining({ preserveThinking: true }),+ expect.anything(),+ );+ });++ it('should force assistant reasoning replay for Kimi K2.7 Code under aggregation provider (e.g. lobehub) even when preserveThinking is disabled', async () => {+ const mockChat = vi.fn().mockImplementation(async (_payload, options) => {+ await options?.callback?.onThinking?.('kimi preserved reasoning from lobehub');+ await options?.callback?.onText?.('answer');+ return new Response('done');+ });+ vi.mocked(initModelRuntimeFromDB).mockResolvedValueOnce({ chat: mockChat } as any);++ const ctxWithConfig: RuntimeExecutorContext = {+ ...ctx,+ agentConfig: {+ chatConfig: { preserveThinking: false },+ plugins: [],+ systemRole: 'test',+ },+ };++ const executors = createRuntimeExecutors(ctxWithConfig);+ const state = createMockState({+ modelRuntimeConfig: {+ model: 'kimi-k2.7-code',+ provider: BRANDING_PROVIDER,+ },+ });++ const instruction = {+ payload: {+ messages: [{ content: 'Hello', role: 'user' }],+ model: 'kimi-k2.7-code',+ provider: BRANDING_PROVIDER,+ },+ type: 'call_llm' as const,+ };++ const result = await executors.call_llm!(instruction, state);+ const assistant = result.newState.messages.at(-1) as any;++ expect(assistant.reasoning).toEqual({+ content: 'kimi preserved reasoning from lobehub',+ });+ expect(mockChat).toHaveBeenCalledWith(+ expect.objectContaining({ preserveThinking: true }),+ expect.anything(),+ );+ });+it('should replay reasoning for unknown custom deployments on supported providers', async () => {const mockChat = vi.fn().mockImplementation(async (_payload, options) => {await options?.callback?.onThinking?.('custom deployment reasoning');diff --git a/packages/model-bank/src/aiModels/ai302.ts b/packages/model-bank/src/aiModels/ai302.tsindex c6da23c70a2..56972663b63 100644--- a/packages/model-bank/src/aiModels/ai302.ts+++ b/packages/model-bank/src/aiModels/ai302.ts@@ -47,16 +47,7 @@ const ai302ChatModels: AIChatModelCard[] = [knowledgeCutoff: '2024-08',type: 'chat',},- {- contextWindowTokens: 200_000,- displayName: 'claude-3-7-sonnet-20250219',- enabled: true,- family: 'claude-sonnet',- generation: 'claude-3.7',- id: 'claude-3-7-sonnet-20250219',- knowledgeCutoff: '2024-10',- type: 'chat',- },+{contextWindowTokens: 200_000,displayName: 'claude-3-7-sonnet-latest',@@ -165,26 +156,6 @@ const ai302ChatModels: AIChatModelCard[] = [knowledgeCutoff: '2025-01',type: 'chat',},- {- contextWindowTokens: 200_000,- displayName: 'claude-sonnet-4-20250514',- enabled: true,- family: 'claude-sonnet',- generation: 'claude-4',- id: 'claude-sonnet-4-20250514',- knowledgeCutoff: '2025-01',- type: 'chat',- },- {- contextWindowTokens: 200_000,- displayName: 'claude-opus-4-20250514',- enabled: true,- family: 'claude-opus',- generation: 'claude-4',- id: 'claude-opus-4-20250514',- knowledgeCutoff: '2025-01',- type: 'chat',- },{contextWindowTokens: 1_000_000,displayName: 'gemini-2.5-pro',diff --git a/packages/model-bank/src/aiModels/aihubmix.ts b/packages/model-bank/src/aiModels/aihubmix.tsindex 673687969c5..a1fe32b117f 100644--- a/packages/model-bank/src/aiModels/aihubmix.ts+++ b/packages/model-bank/src/aiModels/aihubmix.ts@@ -1168,43 +1168,6 @@ const aihubmixChatModels: AIChatModelCard[] = [},type: 'chat',},- {- abilities: {- functionCall: true,- reasoning: true,- search: true,- structuredOutput: true,- vision: true,- },- contextWindowTokens: 200_000,- description:- 'Claude Opus 4 is Anthropic’s most powerful model for highly complex tasks, excelling in performance, intelligence, fluency, and comprehension.',- displayName: 'Claude Opus 4',- family: 'claude-opus',- generation: 'claude-4',- id: 'claude-opus-4-20250514',- knowledgeCutoff: '2025-01',- maxOutput: 32_000,- pricing: {- units: [- { name: 'textInput', rate: 16.8, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textOutput', rate: 84, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textInput_cacheRead', rate: 1.5, strategy: 'fixed', unit: 'millionTokens' },- {- lookup: { prices: { '5m': 20.625 }, pricingParams: ['ttl'] },- name: 'textInput_cacheWrite',- strategy: 'lookup',- unit: 'millionTokens',- },- ],- },- releasedAt: '2025-05-23',- settings: {- extendParams: ['disableContextCaching', 'enableReasoning', 'reasoningBudgetToken'],- searchImpl: 'params',- },- type: 'chat',- },{abilities: {functionCall: true,@@ -1285,78 +1248,6 @@ const aihubmixChatModels: AIChatModelCard[] = [},type: 'chat',},- {- abilities: {- functionCall: true,- reasoning: true,- search: true,- vision: true,- },- contextWindowTokens: 200_000,- description:- 'Claude Sonnet 4 can produce near-instant responses or extended step-by-step reasoning that users can see. API users can finely control how long the model thinks.',- displayName: 'Claude Sonnet 4',- family: 'claude-sonnet',- generation: 'claude-4',- id: 'claude-sonnet-4-20250514',- knowledgeCutoff: '2025-01',- maxOutput: 64_000,- pricing: {- units: [- { name: 'textInput', rate: 3.3, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textOutput', rate: 16.5, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textInput_cacheRead', rate: 0.3, strategy: 'fixed', unit: 'millionTokens' },- {- lookup: { prices: { '5m': 4.125 }, pricingParams: ['ttl'] },- name: 'textInput_cacheWrite',- strategy: 'lookup',- unit: 'millionTokens',- },- ],- },- releasedAt: '2025-05-23',- settings: {- extendParams: ['disableContextCaching', 'enableReasoning', 'reasoningBudgetToken'],- searchImpl: 'params',- },- type: 'chat',- },- {- abilities: {- functionCall: true,- reasoning: true,- search: true,- vision: true,- },- contextWindowTokens: 200_000,- description:- 'Claude 3.7 Sonnet is Anthropic’s most intelligent model and the first hybrid reasoning model on the market. It can produce near-instant responses or extended step-by-step reasoning that users can see. Sonnet is especially strong at coding, data science, vision, and agent tasks.',- displayName: 'Claude 3.7 Sonnet',- family: 'claude-sonnet',- generation: 'claude-3.7',- id: 'claude-3-7-sonnet-20250219',- knowledgeCutoff: '2024-10',- maxOutput: 64_000,- pricing: {- units: [- { name: 'textInput', rate: 3.3, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textOutput', rate: 16.5, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textInput_cacheRead', rate: 0.3, strategy: 'fixed', unit: 'millionTokens' },- {- lookup: { prices: { '5m': 4.125 }, pricingParams: ['ttl'] },- name: 'textInput_cacheWrite',- strategy: 'lookup',- unit: 'millionTokens',- },- ],- },- releasedAt: '2025-02-24',- settings: {- extendParams: ['disableContextCaching', 'enableReasoning', 'reasoningBudgetToken'],- searchImpl: 'params',- },- type: 'chat',- },{abilities: {functionCall: true,@@ -1395,39 +1286,6 @@ const aihubmixChatModels: AIChatModelCard[] = [},type: 'chat',},- {- abilities: {- functionCall: true,- vision: true,- },- contextWindowTokens: 200_000,- description:- 'Claude 3.5 Haiku is Anthropic’s fastest next-gen model. Compared to Claude 3 Haiku, it improves across skills and surpasses the previous largest model Claude 3 Opus on many intelligence benchmarks.',- displayName: 'Claude 3.5 Haiku',- family: 'claude-haiku',- generation: 'claude-3.5',- id: 'claude-3-5-haiku-20241022',- knowledgeCutoff: '2024-07',- maxOutput: 8192,- pricing: {- units: [- { name: 'textInput', rate: 1.1, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textOutput', rate: 5.5, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textInput_cacheRead', rate: 0.1, strategy: 'fixed', unit: 'millionTokens' },- {- lookup: { prices: { '5m': 1.1 }, pricingParams: ['ttl'] },- name: 'textInput_cacheWrite',- strategy: 'lookup',- unit: 'millionTokens',- },- ],- },- releasedAt: '2024-11-05',- settings: {- extendParams: ['disableContextCaching'],- },- type: 'chat',- },{abilities: {functionCall: true,diff --git a/packages/model-bank/src/aiModels/anthropic.ts b/packages/model-bank/src/aiModels/anthropic.tsindex 1bf3be9e685..79172ee3d67 100644--- a/packages/model-bank/src/aiModels/anthropic.ts+++ b/packages/model-bank/src/aiModels/anthropic.ts@@ -325,78 +325,6 @@ const anthropicChatModels: AIChatModelCard[] = [},type: 'chat',},- {- abilities: {- functionCall: true,- reasoning: true,- search: true,- vision: true,- },- contextWindowTokens: 200_000,- description:- 'Claude Opus 4 is Anthropic’s most powerful model for highly complex tasks, excelling in performance, intelligence, fluency, and comprehension.',- displayName: 'Claude Opus 4',- family: 'claude-opus',- generation: 'claude-4',- id: 'claude-opus-4-20250514',- knowledgeCutoff: '2025-01',- maxOutput: 32_000,- pricing: {- units: [- { name: 'textInput_cacheRead', rate: 1.5, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textInput', rate: 15, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textOutput', rate: 75, strategy: 'fixed', unit: 'millionTokens' },- {- lookup: { prices: { '1h': 30, '5m': 18.75 }, pricingParams: ['ttl'] },- name: 'textInput_cacheWrite',- strategy: 'lookup',- unit: 'millionTokens',- },- ],- },- releasedAt: '2025-05-23',- settings: {- extendParams: ['disableContextCaching', 'enableReasoning', 'reasoningBudgetToken'],- searchImpl: 'params',- },- type: 'chat',- },- {- abilities: {- functionCall: true,- reasoning: true,- search: true,- vision: true,- },- contextWindowTokens: 200_000,- description:- 'Claude Sonnet 4 can produce near-instant responses or extended step-by-step reasoning that users can see. API users can finely control how long the model thinks.',- displayName: 'Claude Sonnet 4',- family: 'claude-sonnet',- generation: 'claude-4',- id: 'claude-sonnet-4-20250514',- knowledgeCutoff: '2025-01',- maxOutput: 64_000,- pricing: {- units: [- { name: 'textInput_cacheRead', rate: 0.3, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textInput', rate: 3, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textOutput', rate: 15, strategy: 'fixed', unit: 'millionTokens' },- {- lookup: { prices: { '1h': 6, '5m': 3.75 }, pricingParams: ['ttl'] },- name: 'textInput_cacheWrite',- strategy: 'lookup',- unit: 'millionTokens',- },- ],- },- releasedAt: '2025-05-23',- settings: {- extendParams: ['disableContextCaching', 'enableReasoning', 'reasoningBudgetToken'],- searchImpl: 'params',- },- type: 'chat',- },];export const allModels = [...anthropicChatModels];diff --git a/packages/model-bank/src/aiModels/cometapi.ts b/packages/model-bank/src/aiModels/cometapi.tsindex 08a1bc0e8bd..71832cdb630 100644--- a/packages/model-bank/src/aiModels/cometapi.ts+++ b/packages/model-bank/src/aiModels/cometapi.ts@@ -208,36 +208,6 @@ const cometapiChatModels: AIChatModelCard[] = [releasedAt: '2025-08-05',type: 'chat',},- {- abilities: { functionCall: true, vision: true },- contextWindowTokens: 200_000,- description:- 'Claude Sonnet 4 can produce near-instant responses or extended step-by-step thinking with visible process.',- displayName: 'Claude Sonnet 4',- enabled: true,- family: 'claude-sonnet',- generation: 'claude-4',- id: 'claude-sonnet-4-20250514',- knowledgeCutoff: '2025-01',- maxOutput: 64_000,- releasedAt: '2025-05-23',- type: 'chat',- },- {- abilities: { functionCall: true, vision: true },- contextWindowTokens: 200_000,- description:- 'Claude Sonnet 4 Thinking can produce near-instant responses or extended step-by-step thinking with visible process.',- displayName: 'Claude Sonnet 4 Thinking',- enabled: true,- family: 'claude-sonnet',- generation: 'claude-4',- id: 'claude-sonnet-4-20250514-thinking',- knowledgeCutoff: '2025-01',- maxOutput: 64_000,- releasedAt: '2025-05-23',- type: 'chat',- },{abilities: { functionCall: true, vision: true },contextWindowTokens: 200_000,diff --git a/packages/model-bank/src/aiModels/higress.ts b/packages/model-bank/src/aiModels/higress.tsindex dead874bfbd..4250659e5c3 100644--- a/packages/model-bank/src/aiModels/higress.ts+++ b/packages/model-bank/src/aiModels/higress.ts@@ -2593,59 +2593,6 @@ const higressChatModels: AIChatModelCard[] = [releasedAt: '2024-09-05',type: 'chat',},- {- abilities: {- functionCall: true,- },- contextWindowTokens: 200_000,- description:- 'Claude 3.5 Haiku is Anthropic’s fastest next-gen model. Compared to Claude 3 Haiku, it improves across skills and surpasses the prior largest model Claude 3 Opus on many intelligence benchmarks.',- displayName: 'Claude 3.5 Haiku',- enabled: true,- family: 'claude-haiku',- generation: 'claude-3.5',- id: 'claude-3-5-haiku-20241022',- knowledgeCutoff: '2024-07',- maxOutput: 8192,- pricing: {- units: [- { name: 'textInput_cacheRead', rate: 0.1, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textInput', rate: 1, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textOutput', rate: 5, strategy: 'fixed', unit: 'millionTokens' },- {- lookup: { prices: { '5m': 1.25 }, pricingParams: ['ttl'] },- name: 'textInput_cacheWrite',- strategy: 'lookup',- unit: 'millionTokens',- },- ],- },- releasedAt: '2024-11-05',- type: 'chat',- },- {- abilities: {- functionCall: true,- vision: true,- },- contextWindowTokens: 200_000,- description:- 'Claude 3 Haiku is Anthropic’s fastest and most compact model, designed for near-instant responses with fast, accurate performance.',- displayName: 'Claude 3 Haiku',- family: 'claude-haiku',- generation: 'claude-3',- id: 'claude-3-haiku-20240307',- knowledgeCutoff: '2023-08',- maxOutput: 4096,- pricing: {- units: [- { name: 'textInput', rate: 0.25, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textOutput', rate: 1.25, strategy: 'fixed', unit: 'millionTokens' },- ],- },- releasedAt: '2024-03-07',- type: 'chat',- },{abilities: {functionCall: true,diff --git a/packages/model-bank/src/aiModels/moonshot.ts b/packages/model-bank/src/aiModels/moonshot.tsindex 67b9b01cf10..a8424e1add0 100644--- a/packages/model-bank/src/aiModels/moonshot.ts+++ b/packages/model-bank/src/aiModels/moonshot.ts@@ -2,6 +2,61 @@ import type { AIChatModelCard } from '../types/aiModel';// https://platform.kimi.com/docs/pricing/chatconst moonshotChatModels: AIChatModelCard[] = [+ {+ abilities: {+ functionCall: true,+ reasoning: true,+ structuredOutput: true,+ video: true,+ vision: true,+ },+ contextWindowTokens: 262_144,+ description:+ "Kimi K2.7 Code is Kimi's most intelligent coding model to date. It can follow instructions more reliably in long contexts and complete programming tasks with a higher success rate. It also supports text, image and video input, thinking mode, dialogue and Agent tasks.",+ displayName: 'Kimi K2.7 Code',+ enabled: true,+ family: 'kimi',+ generation: 'kimi-k2.7',+ id: 'kimi-k2.7-code',+ maxOutput: 32_768,+ pricing: {+ currency: 'CNY',+ units: [+ { name: 'textInput_cacheRead', rate: 1.3, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textInput', rate: 6.5, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textOutput', rate: 27, strategy: 'fixed', unit: 'millionTokens' },+ ],+ },+ releasedAt: '2026-06-12',+ type: 'chat',+ },+ {+ abilities: {+ functionCall: true,+ reasoning: true,+ structuredOutput: true,+ video: true,+ vision: true,+ },+ contextWindowTokens: 262_144,+ description:+ 'Kimi K2.7 Code HighSpeed ​​is a high-speed model of Kimi K2.7 Code. It is the same model as Kimi K2.7 Code, but the output speed is about 180 Tokens/s, and the short context scenario can reach 260 Tokens/s, bringing a more extreme programming experience.',+ displayName: 'Kimi K2.7 Code HighSpeed',+ family: 'kimi',+ generation: 'kimi-k2.7',+ id: 'kimi-k2.7-code-highspeed',+ maxOutput: 32_768,+ pricing: {+ currency: 'CNY',+ units: [+ { name: 'textInput_cacheRead', rate: 2.6, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textInput', rate: 13, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textOutput', rate: 54, strategy: 'fixed', unit: 'millionTokens' },+ ],+ },+ releasedAt: '2026-06-15',+ type: 'chat',+ },{abilities: {functionCall: true,@@ -29,7 +84,7 @@ const moonshotChatModels: AIChatModelCard[] = [},releasedAt: '2026-04-20',settings: {- extendParams: ['enableReasoning'],+ extendParams: ['enableReasoning', 'preserveThinking'],},type: 'chat',},diff --git a/packages/model-bank/src/aiModels/siliconcloud.ts b/packages/model-bank/src/aiModels/siliconcloud.tsindex a9b27af17e4..79036a4d0cf 100644--- a/packages/model-bank/src/aiModels/siliconcloud.ts+++ b/packages/model-bank/src/aiModels/siliconcloud.ts@@ -568,65 +568,6 @@ const siliconcloudChatModels: AIChatModelCard[] = [},type: 'chat',},- {- abilities: {- functionCall: true,- reasoning: true,- },- contextWindowTokens: 198_000,- description:- "GLM-5 is Zhipu's next-generation large language model, focusing on complex system engineering and long-duration Agent tasks. The model parameters have been expanded to 744B (40B active) and integrate DeepSeek Sparse Attention.",- displayName: 'GLM-5 (Pro)',- family: 'glm',- generation: 'glm-5',- id: 'Pro/zai-org/glm-5',- pricing: {- currency: 'CNY',- units: [- {- lookup: {- prices: {- '[0, 0.032]': 1,- '[0.032, infinity]': 1.5,- },- pricingParams: ['textInput'],- },- name: 'textInput_cacheRead',- strategy: 'lookup',- unit: 'millionTokens',- },- {- lookup: {- prices: {- '[0, 0.032]': 4,- '[0.032, infinity]': 6,- },- pricingParams: ['textInput'],- },- name: 'textInput',- strategy: 'lookup',- unit: 'millionTokens',- },- {- lookup: {- prices: {- '[0, 0.032]': 18,- '[0.032, infinity]': 22,- },- pricingParams: ['textInput'],- },- name: 'textOutput',- strategy: 'lookup',- unit: 'millionTokens',- },- ],- },- releasedAt: '2026-02-12',- settings: {- extendParams: ['enableReasoning', 'reasoningBudgetToken'],- },- type: 'chat',- },{abilities: {functionCall: true,@@ -736,33 +677,6 @@ const siliconcloudChatModels: AIChatModelCard[] = [},type: 'chat',},- {- abilities: {- functionCall: true,- reasoning: true,- vision: true,- video: true,- },- contextWindowTokens: 262_144,- description:- 'Kimi K2.5 is an open-source native multimodal agent model, built on Kimi-K2-Base, trained on approximately 1.5 trillion mixed vision and text tokens. The model adopts an MoE architecture with 1T total parameters and 32B active parameters, supporting a 256K context window, seamlessly integrating vision and language understanding capabilities.',- displayName: 'Kimi-K2.5 (Pro)',- family: 'kimi',- generation: 'kimi-k2.5',- id: 'Pro/moonshotai/Kimi-K2.5',- pricing: {- currency: 'CNY',- units: [- { name: 'textInput', rate: 4, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textOutput', rate: 21, strategy: 'fixed', unit: 'millionTokens' },- ],- },- releasedAt: '2026-01-27',- settings: {- extendParams: ['enableReasoning', 'reasoningBudgetToken'],- },- type: 'chat',- },{abilities: {vision: true,@@ -781,68 +695,6 @@ const siliconcloudChatModels: AIChatModelCard[] = [releasedAt: '2026-01-29',type: 'chat',},- {- abilities: {- functionCall: true,- reasoning: true,- },- contextWindowTokens: 200_000,- description:- "GLM-4.7 is Zhipu's new generation flagship model with 355B total parameters and 32B active parameters, fully upgraded in general dialogue, reasoning, and agent capabilities. GLM-4.7 enhances Interleaved Thinking and introduces Preserved Thinking and Turn-level Thinking.",- displayName: 'GLM-4.7 (Pro)',- family: 'glm',- generation: 'glm-4.7',- id: 'Pro/zai-org/GLM-4.7',- pricing: {- currency: 'CNY',- units: [- {- lookup: {- prices: {- '[0, 0.032]_[0, 0.0002]': 0.4,- '[0, 0.032]_[0.0002, infinity]': 0.6,- '[0.032, infinity]_[0, infinity]': 0.8,- },- pricingParams: ['textInput', 'textOutput'],- },- name: 'textInput_cacheRead',- strategy: 'lookup',- unit: 'millionTokens',- },- {- lookup: {- prices: {- '[0, 0.032]_[0, 0.0002]': 2,- '[0, 0.032]_[0.0002, infinity]': 3,- '[0.032, infinity]_[0, infinity]': 4,- },- pricingParams: ['textInput', 'textOutput'],- },- name: 'textInput',- strategy: 'lookup',- unit: 'millionTokens',- },- {- lookup: {- prices: {- '[0, 0.032]_[0, 0.0002]': 8,- '[0, 0.032]_[0.0002, infinity]': 14,- '[0.032, infinity]_[0, infinity]': 16,- },- pricingParams: ['textInput', 'textOutput'],- },- name: 'textOutput',- strategy: 'lookup',- unit: 'millionTokens',- },- ],- },- releasedAt: '2025-12-22',- settings: {- extendParams: ['enableReasoning', 'reasoningBudgetToken'],- },- type: 'chat',- },{abilities: {functionCall: true,diff --git a/packages/model-runtime/src/core/openaiCompatibleFactory/index.ts b/packages/model-runtime/src/core/openaiCompatibleFactory/index.tsindex c97b790009f..9defac845d3 100644--- a/packages/model-runtime/src/core/openaiCompatibleFactory/index.ts+++ b/packages/model-runtime/src/core/openaiCompatibleFactory/index.ts@@ -290,6 +290,11 @@ export interface OpenAICompatibleFactoryOptions<T extends Record<string, any> =| {transformModel?: (model: OpenAI.Model) => ChatModelCard;};+ /**+ * Additional provider-specific model patterns that support `prompt_cache_key`.+ * OpenAI models are handled by the factory default; other providers must opt in.+ */+ promptCacheKeyModels?: Array<string | RegExp>;provider: string;responses?: {handlePayload?: (@@ -310,6 +315,7 @@ export const createOpenAICompatibleRuntime = <T extends Record<string, any> = anmodels,customClient,responses,+ promptCacheKeyModels,createImage: customCreateImage,createVideo: customCreateVideo,handleCreateVideoWebhook: customHandleCreateVideoWebhook,@@ -478,10 +484,21 @@ export const createOpenAICompatibleRuntime = <T extends Record<string, any> = anprivate resolvePromptCacheKey(model?: string, user?: string) {if (!user) return;- // Keep the default key at {userId}:{model}; {agentId} can be added later if a narrower cache bucket is needed.+ // Keep the default key at {userId}:{model}; {agentId/topicId} can be added later if a narrower cache bucket is needed.if (model?.startsWith('gpt-') || /^o\d/.test(model || '') || model === 'chat-latest') {return `lobe:${user}:${model}`;}++ const matchesProviderPromptCacheModel = promptCacheKeyModels?.some((item) => {+ if (!model) return false;+ if (typeof item === 'string') return model.includes(item);++ item.lastIndex = 0;+ return item.test(model);+ });+ if (matchesProviderPromptCacheModel) {+ return `lobe:${user}:${model}`;+ }}private resolvePromptCacheKeyParams(diff --git a/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.test.ts b/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.test.tsindex 63336a77fd6..061473347a5 100644--- a/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.test.ts+++ b/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.test.ts@@ -976,136 +976,6 @@ describe('computeChatPricing', () => {);expect(cacheWrite?.credits).toBe(0); // No credits when lookup params undefined});-- it('handles simple request without thinking for Claude Sonnet 4', () => {- const pricing = anthropicChatModels.find(- (model: { id: string }) => model.id === 'claude-sonnet-4-20250514',- )?.pricing;- expect(pricing).toBeDefined();-- const usage: ModelTokensUsage = {- inputCacheMissTokens: 8,- totalInputTokens: 8,- totalOutputTokens: 24,- totalTokens: 32,- };-- const result = computeChatCost(pricing, usage);- expect(result).toBeDefined();- expect(result?.issues).toHaveLength(0);-- const { breakdown, totalCost, totalCredits } = result!;- expect(breakdown).toHaveLength(2); // Only input and output-- // Verify input tokens- const input = breakdown.find((item) => item.unit.name === 'textInput');- expect(input?.quantity).toBe(8);- expect(input?.credits).toBe(24); // 8 * 3 = 24-- // Verify output tokens- const output = breakdown.find((item) => item.unit.name === 'textOutput');- expect(output?.quantity).toBe(24);- expect(output?.credits).toBe(360); // 24 * 15 = 360-- // Verify totals match the actual billing log- expect(totalCredits).toBe(384); // 24 + 360 = 384- expect(totalCost).toBeCloseTo(0.000384, 6); // 384 credits = $0.000384- });-- it('handles request with cache read and write for Claude Sonnet 4', () => {- const pricing = anthropicChatModels.find(- (model: { id: string }) => model.id === 'claude-sonnet-4-20250514',- )?.pricing;- expect(pricing).toBeDefined();-- const usage: ModelTokensUsage = {- inputCacheMissTokens: 4,- inputCachedTokens: 1183,- inputWriteCacheTokens: 458,- totalInputTokens: 1645,- totalOutputTokens: 522,- totalTokens: 2167,- };-- const result = computeChatCost(pricing, usage, { lookupParams: { ttl: '5m' } });- expect(result).toBeDefined();- expect(result?.issues).toHaveLength(0);-- const { breakdown, totalCost, totalCredits } = result!;- expect(breakdown).toHaveLength(4); // Input, output, cache read, cache write-- // Verify cache miss tokens (regular input)- const input = breakdown.find((item) => item.unit.name === 'textInput');- expect(input?.quantity).toBe(4);- expect(input?.credits).toBe(12); // 4 * 3 = 12-- // Verify output tokens- const output = breakdown.find((item) => item.unit.name === 'textOutput');- expect(output?.quantity).toBe(522);- expect(output?.credits).toBe(7_830); // 522 * 15 = 7830-- // Verify cached tokens (discounted rate)- const cached = breakdown.find((item) => item.unit.name === 'textInput_cacheRead');- expect(cached?.quantity).toBe(1183);- expect(cached?.credits).toBe(355); // 354.9 rounded = 355-- // Verify cache write tokens- const cacheWrite = breakdown.find((item) => item.unit.name === 'textInput_cacheWrite');- expect(cacheWrite?.quantity).toBe(458);- expect(cacheWrite?.lookupKey).toBe('5m');- expect(cacheWrite?.credits).toBe(1_718); // 1717.5 rounded = 1718-- // Verify totals match the actual billing log- expect(totalCredits).toBe(9_915); // 12 + 7830 + 355 + 1718 = 9915- expect(totalCost).toBeCloseTo(0.009915, 6); // 9915 credits = $0.009915- });-- it('handles complex scenario with all cache types for Claude Sonnet 4 Latest', () => {- const pricing = anthropicChatModels.find(- (model: { id: string }) => model.id === 'claude-sonnet-4-20250514',- )?.pricing;- expect(pricing).toBeDefined();-- const usage: ModelTokensUsage = {- inputCacheMissTokens: 10,- inputCachedTokens: 3021,- inputWriteCacheTokens: 1697,- totalInputTokens: 4728,- totalOutputTokens: 2841,- totalTokens: 7569,- };-- const result = computeChatCost(pricing, usage, { lookupParams: { ttl: '5m' } });- expect(result).toBeDefined();- expect(result?.issues).toHaveLength(0);-- const { breakdown, totalCost, totalCredits } = result!;- expect(breakdown).toHaveLength(4); // Input, output, cache read, cache write-- // Verify cache miss tokens (regular input)- const input = breakdown.find((item) => item.unit.name === 'textInput');- expect(input?.quantity).toBe(10);- expect(input?.credits).toBe(30); // 10 * 3 = 30-- // Verify output tokens- const output = breakdown.find((item) => item.unit.name === 'textOutput');- expect(output?.quantity).toBe(2841);- expect(output?.credits).toBe(42_615); // 2841 * 15 = 42615-- // Verify cached tokens (discounted rate)- const cached = breakdown.find((item) => item.unit.name === 'textInput_cacheRead');- expect(cached?.quantity).toBe(3021);- expect(cached?.credits).toBe(907); // ceil(906.3) = 907-- // Verify cache write tokens (fixed strategy in lobehub model)- const cacheWrite = breakdown.find((item) => item.unit.name === 'textInput_cacheWrite');- expect(cacheWrite?.quantity).toBe(1697);- expect(cacheWrite?.credits).toBe(6_364); // ceil(6363.75) = 6364-- // Verify totals match the actual billing log- expect(totalCredits).toBe(49_916); // 30 + 42615 + 907 + 6364 = 49916- expect(totalCost).toBeCloseTo(0.049916, 6); // 49916 credits = $0.049916- });});describe('Edge Cases', () => {diff --git a/packages/model-runtime/src/index.ts b/packages/model-runtime/src/index.tsindex 02b776b8ce3..6ab1ba1fc61 100644--- a/packages/model-runtime/src/index.ts+++ b/packages/model-runtime/src/index.ts@@ -55,6 +55,7 @@ export { LobeMinimaxAI } from './providers/minimax';export { LobeMinimaxCodingPlanAI } from './providers/minimaxCodingPlan';export { LobeMistralAI } from './providers/mistral';export { LobeMoonshotAI } from './providers/moonshot';+export { isKimiAlwaysPreserveThinkingModel } from './providers/moonshot/kimiModelId';export { LobeNebiusAI } from './providers/nebius';export { LobeNewAPIAI } from './providers/newapi';export { LobeOllamaAI } from './providers/ollama';diff --git a/packages/model-runtime/src/providers/moonshot/index.test.ts b/packages/model-runtime/src/providers/moonshot/index.test.tsindex e540a545f60..f4ea0dc7d16 100644--- a/packages/model-runtime/src/providers/moonshot/index.test.ts+++ b/packages/model-runtime/src/providers/moonshot/index.test.ts@@ -23,8 +23,8 @@ const defaultOpenAIBaseURL = 'https://api.moonshot.cn/v1';const anthropicBaseURL = 'https://api.moonshot.cn/anthropic';// Mock the console.error and console.warn to avoid polluting test output-vi.spyOn(console, 'error').mockImplementation(() => {});-vi.spyOn(console, 'warn').mockImplementation(() => {});+vi.spyOn(console, 'error').mockImplementation(() => { });+vi.spyOn(console, 'warn').mockImplementation(() => { });beforeEach(() => {loadModelsMock.mockResolvedValue([]);@@ -360,6 +360,17 @@ describe('LobeMoonshotOpenAI', () => {expect(payload.temperature).toBe(0.6);expect(payload.thinking).toEqual({ type: 'disabled' });});++ it('should handle kimi-k2.6 model with preserveThinking enabled', async () => {+ await instance.chat({+ messages: [{ content: 'Hello', role: 'user' }],+ model: 'kimi-k2.6',+ preserveThinking: true,+ });++ const payload = getLastRequestPayload();+ expect(payload.thinking).toEqual({ keep: 'all', type: 'enabled' });+ });});describe('kimi-k2-thinking native thinking models', () => {@@ -390,6 +401,21 @@ describe('LobeMoonshotOpenAI', () => {expect(payload.temperature).toBe(1);});+ it('should always enable thinking for kimi-k2.7-code', async () => {+ await instance.chat({+ messages: [{ content: 'Hello', role: 'user' }],+ model: 'kimi-k2.7-code',+ temperature: 0.5,+ });++ const payload = getLastRequestPayload();+ expect(payload.thinking).toEqual({ type: 'enabled' });+ expect(payload.temperature).toBe(1);+ expect(payload.top_p).toBe(0.95);+ expect(payload.frequency_penalty).toBe(0);+ expect(payload.presence_penalty).toBe(0);+ });+it('should ignore thinking disabled for native thinking models', async () => {await instance.chat({messages: [{ content: 'Hello', role: 'user' }],@@ -431,6 +457,24 @@ describe('LobeMoonshotOpenAI', () => {expect(assistantMessage?.reasoning_content).toBe('');});++ it('should force reasoning_content on assistant messages for kimi-k2.7-code', async () => {+ await instance.chat({+ messages: [+ { content: 'Hello', role: 'user' },+ { content: 'Response', role: 'assistant' },+ { content: 'Follow-up', role: 'user' },+ ],+ model: 'kimi-k2.7-code',+ });++ const payload = getLastRequestPayload();+ const assistantMessage = payload.messages.find(+ (message: any) => message.role === 'assistant',+ );++ expect(assistantMessage?.reasoning_content).toBe('');+ });});describe('interleaved thinking', () => {@@ -457,6 +501,31 @@ describe('LobeMoonshotOpenAI', () => {expect(assistantMessage?.reasoning).toBeUndefined();});});++ describe('prompt_cache_key', () => {+ it('should inject prompt_cache_key for kimi- models when user is provided', async () => {+ await instance.chat(+ {+ messages: [{ content: 'Hello', role: 'user' }],+ model: 'kimi-k2.6',+ },+ { user: 'user-abc' },+ );++ const payload = getLastRequestPayload();+ expect(payload.prompt_cache_key).toBe('lobe:user-abc:kimi-k2.6');+ });++ it('should not inject prompt_cache_key when user is not provided', async () => {+ await instance.chat({+ messages: [{ content: 'Hello', role: 'user' }],+ model: 'kimi-k2.6',+ });++ const payload = getLastRequestPayload();+ expect(payload.prompt_cache_key).toBeUndefined();+ });+ });});});@@ -626,6 +695,22 @@ describe('LobeMoonshotAnthropicAI', () => {expect(payload.temperature).toBe(0.6);});+ it('should handle kimi-k2.6 model with preserveThinking enabled', async () => {+ await instance.chat({+ messages: [{ content: 'Hello', role: 'user' }],+ model: 'kimi-k2.6',+ preserveThinking: true,+ });++ const payload = getLastRequestPayload();++ expect(payload.thinking).toEqual({+ budget_tokens: 1024,+ keep: 'all',+ type: 'enabled',+ });+ });+it('should not add thinking params for non-K2-toggle models', async () => {await instance.chat({messages: [{ content: 'Hello', role: 'user' }],@@ -671,6 +756,22 @@ describe('LobeMoonshotAnthropicAI', () => {expect(payload.temperature).toBe(1);});+ it('should always enable thinking for kimi-k2.7-code', async () => {+ await instance.chat({+ messages: [{ content: 'Hello', role: 'user' }],+ model: 'kimi-k2.7-code',+ temperature: 0.5,+ });++ const payload = getLastRequestPayload();+ expect(payload.thinking).toEqual({+ budget_tokens: 1024,+ type: 'enabled',+ });+ expect(payload.temperature).toBe(1);+ expect(payload.top_p).toBe(0.95);+ });+it('should ignore thinking disabled for native thinking models', async () => {await instance.chat({messages: [{ content: 'Hello', role: 'user' }],@@ -721,6 +822,27 @@ describe('LobeMoonshotAnthropicAI', () => {{ type: 'text', text: 'Response' },]);});++ it('should force thinking block on assistant messages for kimi-k2.7-code', async () => {+ await instance.chat({+ messages: [+ { content: 'Hello', role: 'user' },+ { content: 'Response', role: 'assistant' },+ { content: 'Follow-up', role: 'user' },+ ],+ model: 'kimi-k2.7-code',+ });++ const payload = getLastRequestPayload();+ const assistantMessage = payload.messages.find(+ (message: any) => message.role === 'assistant',+ );++ expect(assistantMessage?.content).toEqual([+ { type: 'thinking', thinking: ' ' },+ { type: 'text', text: 'Response' },+ ]);+ });});describe('interleaved thinking', () => {diff --git a/packages/model-runtime/src/providers/moonshot/index.ts b/packages/model-runtime/src/providers/moonshot/index.tsindex f1431708182..4cd2ff71e5b 100644--- a/packages/model-runtime/src/providers/moonshot/index.ts+++ b/packages/model-runtime/src/providers/moonshot/index.ts@@ -14,7 +14,11 @@ import { createRouterRuntime } from '../../core/RouterRuntime';import type { ChatStreamPayload } from '../../types';import { getModelPropertyWithFallback } from '../../utils/getFallbackModelProperty';import { MODEL_LIST_CONFIGS, processModelList } from '../../utils/modelParse';-import { isKimiNativeThinkingModel, isKimiThinkingToggleModel } from './kimiModelId';+import {+ isKimiNativeThinkingModel,+ isKimiPreserveThinkingModel,+ isKimiThinkingToggleModel,+} from './kimiModelId';export interface MoonshotModelCard {context_length?: number;@@ -31,6 +35,7 @@ type MoonshotSDKType = 'anthropic' | 'openai';// Shared constants and helpersconst MOONSHOT_SEARCH_TOOL = { function: { name: '$web_search' }, type: 'builtin_function' } as any;+const isEmptyContent = (content: any) =>content === '' || content === null || content === undefined;const hasValidReasoning = (reasoning: any) => reasoning?.content && !reasoning?.signature;@@ -155,7 +160,15 @@ const buildMoonshotAnthropicPayload = async (: 1024;const thinkingParam =isNativeThinking || payload.thinking?.type !== 'disabled'- ? ({ budget_tokens: resolvedThinkingBudget, type: 'enabled' } as const)+ ? {+ budget_tokens: resolvedThinkingBudget,+ type: 'enabled' as const,+ // Only inject keep:'all' for kimi-k2.6; kimi-k2.5 does not support it and+ // kimi-k2.7-code always has Preserved Thinking active (no need to pass the param)+ ...(payload.preserveThinking && isKimiPreserveThinkingModel(payload.model)+ ? { keep: 'all' as const }+ : {}),+ }: ({ type: 'disabled' } as const);return {@@ -182,7 +195,14 @@ const buildMoonshotOpenAIPayload = (if (isK2Family || isNativeThinking) {const thinkingParam =isNativeThinking || thinking?.type !== 'disabled'- ? { type: 'enabled' }+ ? {+ type: 'enabled',+ // Only inject keep:'all' for kimi-k2.6; kimi-k2.5 does not support it and+ // kimi-k2.7-code always has Preserved Thinking active (no need to pass the param)+ ...(payload.preserveThinking && isKimiPreserveThinkingModel(model)+ ? { keep: 'all' }+ : {}),+ }: { type: 'disabled' };return {@@ -254,6 +274,9 @@ export const LobeMoonshotOpenAI = createOpenAICompatibleRuntime({debug: {chatCompletion: () => process.env.DEBUG_MOONSHOT_CHAT_COMPLETION === '1',},+ // Kimi models support prompt_cache_key for multi-turn session cache optimization.+ // Docs: https://platform.kimi.com/docs/api/chat#body-one-of-0-prompt-cache-key+ promptCacheKeyModels: [/^kimi-/],provider: ModelProvider.Moonshot,});diff --git a/packages/model-runtime/src/providers/moonshot/kimiModelId.test.ts b/packages/model-runtime/src/providers/moonshot/kimiModelId.test.tsindex 430a799ec62..5012b4a1b5e 100644--- a/packages/model-runtime/src/providers/moonshot/kimiModelId.test.ts+++ b/packages/model-runtime/src/providers/moonshot/kimiModelId.test.ts@@ -1,7 +1,9 @@import { describe, expect, it } from 'vitest';import {+ isKimiAlwaysPreserveThinkingModel,isKimiNativeThinkingModel,+ isKimiPreserveThinkingModel,isKimiThinkingToggleModel,parseKimiModelId,} from './kimiModelId';@@ -79,3 +81,28 @@ describe('isKimiNativeThinkingModel', () => {expect(isKimiNativeThinkingModel('kimi-k2.6')).toBe(false);});});++describe('isKimiAlwaysPreserveThinkingModel', () => {+ it('should return true for Kimi K2.7+ code models', () => {+ expect(isKimiAlwaysPreserveThinkingModel('kimi-k2.7-code')).toBe(true);+ expect(isKimiAlwaysPreserveThinkingModel('kimi-k2.7-code-highspeed')).toBe(true);+ expect(isKimiAlwaysPreserveThinkingModel('kimi-k2.8-code-preview')).toBe(true);+ });++ it('should return false for switchable and non-code Kimi models', () => {+ expect(isKimiAlwaysPreserveThinkingModel('kimi-k2.6')).toBe(false);+ expect(isKimiAlwaysPreserveThinkingModel('kimi-k2-thinking')).toBe(false);+ });+});++describe('isKimiPreserveThinkingModel', () => {+ it('should return true for Kimi K2.6 models', () => {+ expect(isKimiPreserveThinkingModel('kimi-k2.6')).toBe(true);+ });++ it('should return false for other Kimi models', () => {+ expect(isKimiPreserveThinkingModel('kimi-k2.5')).toBe(false);+ expect(isKimiPreserveThinkingModel('kimi-k2.7-code')).toBe(false);+ expect(isKimiPreserveThinkingModel('kimi-k2-thinking')).toBe(false);+ });+});diff --git a/packages/model-runtime/src/providers/moonshot/kimiModelId.ts b/packages/model-runtime/src/providers/moonshot/kimiModelId.tsindex 2287c69160c..3ed34b04364 100644--- a/packages/model-runtime/src/providers/moonshot/kimiModelId.ts+++ b/packages/model-runtime/src/providers/moonshot/kimiModelId.ts@@ -72,6 +72,18 @@ export const isKimiNativeThinkingModel = (model: string): boolean => {);};+export const isKimiAlwaysPreserveThinkingModel = (model: string): boolean => {+ const parsed = parseKimiModelId(model);+ if (!parsed) return false;++ return (+ parsed.majorVersion === 2 &&+ hasVariant(parsed, 'code') &&+ parsed.minorVersion !== undefined &&+ parsed.minorVersion >= 7+ );+};+export const isKimiThinkingToggleModel = (model: string): boolean => {const parsed = parseKimiModelId(model);if (!parsed) return false;@@ -82,3 +94,10 @@ export const isKimiThinkingToggleModel = (model: string): boolean => {!isKimiNativeThinkingModel(model));};++export const isKimiPreserveThinkingModel = (model: string): boolean => {+ const parsed = parseKimiModelId(model);+ if (!parsed) return false;++ return parsed.majorVersion === 2 && parsed.minorVersion === 6;+};diff --git a/packages/model-runtime/src/providers/qwen/index.test.ts b/packages/model-runtime/src/providers/qwen/index.test.tsindex bf684bae9ad..0fe59820fea 100644--- a/packages/model-runtime/src/providers/qwen/index.test.ts+++ b/packages/model-runtime/src/providers/qwen/index.test.ts@@ -31,6 +31,22 @@ beforeEach(() => {});describe('LobeQwenAI - custom features', () => {+ describe('prompt_cache_key', () => {+ it('should not inject Moonshot prompt_cache_key for Kimi model ids', async () => {+ await instance.chat(+ {+ messages: [{ content: 'Hello', role: 'user' }],+ model: 'kimi-k2.6',+ },+ { user: 'user-abc' },+ );++ const calledPayload = (instance['client'].chat.completions.create as any).mock.calls[0][0];++ expect(calledPayload.prompt_cache_key).toBeUndefined();+ });+ });+describe('thinking payload mapping', () => {it('should forward enable_thinking and reasoning_effort for deepseek-v4 models', async () => {await instance.chat({