🤯 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
🐛 fix: Automatic topic creation switch does not work (#9693)
sxjerua02b301904db
diff --git a/packages/model-bank/src/aiModels/ollamacloud.ts b/packages/model-bank/src/aiModels/ollamacloud.tsindex 7e0a38ec792..44131a4418b 100644--- a/packages/model-bank/src/aiModels/ollamacloud.ts+++ b/packages/model-bank/src/aiModels/ollamacloud.ts@@ -70,12 +70,22 @@ const ollamaCloudModels: AIChatModelCard[] = [functionCall: true,},contextWindowTokens: 262_144,- description:- '阿里巴巴针对代理和编码任务的高性能长上下文模型。',+ description: '阿里巴巴针对代理和编码任务的高性能长上下文模型。',displayName: 'Qwen3 Coder 480B',id: 'qwen3-coder:480b',type: 'chat',},+ {+ abilities: {+ functionCall: true,+ reasoning: true,+ vision: true,+ },+ contextWindowTokens: 128_000,+ displayName: 'Qwen3 VL 235B',+ id: 'qwen3-vl:235b',+ type: 'chat',+ },];export const allModels = [...ollamaCloudModels];diff --git a/packages/model-bank/src/aiModels/qwen.ts b/packages/model-bank/src/aiModels/qwen.tsindex 8eb24166612..5e2de2056b1 100644--- a/packages/model-bank/src/aiModels/qwen.ts+++ b/packages/model-bank/src/aiModels/qwen.ts@@ -1258,6 +1258,130 @@ const qwenChatModels: AIChatModelCard[] = [},type: 'chat',},+ {+ abilities: {+ vision: true,+ reasoning: true,+ },+ contextWindowTokens: 131_072,+ description:+ 'Qwen-VL(开源版)提供视觉理解与文本生成能力,支持智能体交互、视觉编码、空间感知、长视频理解与深度思考,并在复杂场景下具备更强的文字识别与多语言支持。',+ displayName: 'Qwen3 VL 30B A3B Thinking',+ id: 'qwen3-vl-30b-a3b-thinking',+ maxOutput: 32_768,+ organization: 'Qwen',+ pricing: {+ currency: 'CNY',+ units: [+ { name: 'textInput', rate: 0.75, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textOutput', rate: 7.5, strategy: 'fixed', unit: 'millionTokens' },+ ],+ },+ settings: {+ extendParams: ['reasoningBudgetToken'],+ },+ type: 'chat',+ },+ {+ abilities: {+ vision: true,+ },+ contextWindowTokens: 131_072,+ description: 'Qwen3 VL 30B 非思考模式(Instruct),面向普通指令跟随场景,保持较高的多模态理解与生成能力。',+ displayName: 'Qwen3 VL 30B A3B Instruct',+ id: 'qwen3-vl-30b-a3b-instruct',+ maxOutput: 32_768,+ organization: 'Qwen',+ pricing: {+ currency: 'CNY',+ units: [+ { name: 'textInput', rate: 0.75, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textOutput', rate: 3, strategy: 'fixed', unit: 'millionTokens' },+ ],+ },+ type: 'chat',+ },+ {+ abilities: {+ vision: true,+ reasoning: true,+ },+ contextWindowTokens: 131_072,+ description: 'Qwen3 VL 8B 思考模式,面向轻量级多模态推理与交互场景,保留长上下文理解能力。',+ displayName: 'Qwen3 VL 8B Thinking',+ id: 'qwen3-vl-8b-thinking',+ maxOutput: 32_768,+ organization: 'Qwen',+ pricing: {+ currency: 'CNY',+ units: [+ { name: 'textInput', rate: 0.5, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textOutput', rate: 5, strategy: 'fixed', unit: 'millionTokens' },+ ],+ },+ type: 'chat',+ },+ {+ abilities: {+ vision: true,+ },+ contextWindowTokens: 131_072,+ description: 'Qwen3 VL 8B 非思考模式(Instruct),适合常规多模态生成与识别任务。',+ displayName: 'Qwen3 VL 8B Instruct',+ id: 'qwen3-vl-8b-instruct',+ maxOutput: 32_768,+ organization: 'Qwen',+ pricing: {+ currency: 'CNY',+ units: [+ { name: 'textInput', rate: 0.5, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textOutput', rate: 2, strategy: 'fixed', unit: 'millionTokens' },+ ],+ },+ type: 'chat',+ },+ {+ abilities: {+ vision: true,+ reasoning: true,+ },+ contextWindowTokens: 131_072,+ description: 'Qwen3 VL 235B A22B 思考模式(开源版),针对高难度强推理与长视频理解场景,提供顶尖的视觉+文本推理能力。',+ displayName: 'Qwen3 VL 235B A22B Thinking',+ id: 'qwen3-vl-235b-a22b-thinking',+ maxOutput: 32_768,+ organization: 'Qwen',+ pricing: {+ currency: 'CNY',+ units: [+ { name: 'textInput', rate: 2, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textOutput', rate: 20, strategy: 'fixed', unit: 'millionTokens' },+ ],+ },+ settings: {+ extendParams: ['enableReasoning', 'reasoningBudgetToken'],+ },+ type: 'chat',+ },+ {+ abilities: {+ vision: true,+ },+ contextWindowTokens: 131_072,+ description: 'Qwen3 VL 235B A22B 非思考模式(Instruct),适用于非思考指令场景,保持强大的视觉理解能力。',+ displayName: 'Qwen3 VL 235B A22B Instruct',+ id: 'qwen3-vl-235b-a22b-instruct',+ maxOutput: 32_768,+ organization: 'Qwen',+ pricing: {+ currency: 'CNY',+ units: [+ { name: 'textInput', rate: 2, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textOutput', rate: 8, strategy: 'fixed', unit: 'millionTokens' },+ ],+ },+ type: 'chat',+ },{config: {deploymentName: 'qwen-math-turbo-latest',diff --git a/packages/model-bank/src/aiModels/siliconcloud.ts b/packages/model-bank/src/aiModels/siliconcloud.tsindex 4e9bf476163..4bcb04e1441 100644--- a/packages/model-bank/src/aiModels/siliconcloud.ts+++ b/packages/model-bank/src/aiModels/siliconcloud.ts@@ -2,6 +2,48 @@ import { AIChatModelCard, AIImageModelCard } from '../types/aiModel';// https://siliconflow.cn/zh-cn/modelsconst siliconcloudChatModels: AIChatModelCard[] = [+ {+ abilities: {+ functionCall: true,+ reasoning: true,+ },+ contextWindowTokens: 131_072,+ description:+ 'Ring-1T 是一款由百灵(Bailing)团队发布的万亿参数规模的开源思想模型。它基于 Ling 2.0 架构和 Ling-1T-base 基础模型训练,总参数量达 1 万亿,激活参数量为 500 亿,并支持高达 128K 的上下文窗口。该模型通过大规模可验证奖励强化学习进行优化。',+ displayName: 'Ring-1T',+ id: 'inclusionAI/Ring-1T',+ pricing: {+ currency: 'CNY',+ units: [+ { name: 'textInput', rate: 4, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textOutput', rate: 16, strategy: 'fixed', unit: 'millionTokens' },+ ],+ },+ releasedAt: '2025-10-14',+ settings: {+ extendParams: ['reasoningBudgetToken'],+ },+ type: 'chat',+ },+ {+ abilities: {+ functionCall: true,+ },+ contextWindowTokens: 131_072,+ description:+ 'Ling-1T 是"灵 2.0"系列的首款旗舰级 non-thinking 模型,拥有 1 万亿总参数和每 token 约 500 亿个活动参数。基于灵 2.0 架构构建,Ling-1T 旨在突破高效推理和可扩展认知的极限。Ling-1T-base 在超过 20 万亿个高质量、推理密集的 token 上进行训练。',+ displayName: 'Ling-1T',+ id: 'inclusionAI/Ling-1T',+ pricing: {+ currency: 'CNY',+ units: [+ { name: 'textInput', rate: 4, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textOutput', rate: 16, strategy: 'fixed', unit: 'millionTokens' },+ ],+ },+ releasedAt: '2025-10-09',+ type: 'chat',+ },{abilities: {functionCall: true,diff --git a/packages/model-bank/src/aiModels/vercelaigateway.ts b/packages/model-bank/src/aiModels/vercelaigateway.tsindex f4151637314..0a32574553f 100644--- a/packages/model-bank/src/aiModels/vercelaigateway.ts+++ b/packages/model-bank/src/aiModels/vercelaigateway.ts@@ -647,7 +647,6 @@ const vercelAIGatewayChatModels: AIChatModelCard[] = [{abilities: {functionCall: true,- reasoning: true,vision: true,},contextWindowTokens: 1_048_576,@@ -657,8 +656,8 @@ const vercelAIGatewayChatModels: AIChatModelCard[] = [id: 'google/gemini-2.0-flash',pricing: {units: [- { name: 'textInput', rate: 0.15, strategy: 'fixed', unit: 'millionTokens' },- { name: 'textOutput', rate: 0.6, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textInput', rate: 0.1, strategy: 'fixed', unit: 'millionTokens' },+ { name: 'textOutput', rate: 0.4, strategy: 'fixed', unit: 'millionTokens' },],},type: 'chat',@@ -666,7 +665,6 @@ const vercelAIGatewayChatModels: AIChatModelCard[] = [{abilities: {functionCall: true,- reasoning: true,vision: true,},contextWindowTokens: 1_048_576,diff --git a/packages/types/src/aiChat.ts b/packages/types/src/aiChat.tsindex cd5932db896..c95035cc698 100644--- a/packages/types/src/aiChat.ts+++ b/packages/types/src/aiChat.ts@@ -48,7 +48,7 @@ export const AiSendMessageServerSchema = z.object({export interface SendMessageServerResponse {assistantMessageId: string;- isCreatNewTopic: boolean;+ isCreateNewTopic: boolean;messages: ChatMessage[];topicId: string;topics?: ChatTopic[];diff --git a/src/server/routers/lambda/aiChat.test.ts b/src/server/routers/lambda/aiChat.test.tsindex b255f543cf9..4c9d8c5eea7 100644--- a/src/server/routers/lambda/aiChat.test.ts+++ b/src/server/routers/lambda/aiChat.test.ts@@ -71,7 +71,7 @@ describe('aiChatRouter', () => {expect(mockGet).toHaveBeenCalledWith({ includeTopic: true, sessionId: 's1', topicId: 't1' });expect(res.assistantMessageId).toBe('m-assistant');expect(res.userMessageId).toBe('m-user');- expect(res.isCreatNewTopic).toBe(true);+ expect(res.isCreateNewTopic).toBe(true);expect(res.topicId).toBe('t1');expect(res.messages?.length).toBe(2);expect(res.topics?.length).toBe(1);@@ -102,7 +102,7 @@ describe('aiChatRouter', () => {sessionId: 's1',topicId: 't-exist',});- expect(res.isCreatNewTopic).toBe(false);+ expect(res.isCreateNewTopic).toBe(false);expect(res.topicId).toBe('t-exist');});});diff --git a/src/server/routers/lambda/aiChat.ts b/src/server/routers/lambda/aiChat.tsindex 453a88c0a55..879ff607e20 100644--- a/src/server/routers/lambda/aiChat.ts+++ b/src/server/routers/lambda/aiChat.ts@@ -77,7 +77,7 @@ export const aiChatRouter = router({let messageId: string;let topicId = input.topicId!;- let isCreatNewTopic = false;+ let isCreateNewTopic = false;// create topic if there should be a new topicif (input.newTopic) {@@ -88,7 +88,7 @@ export const aiChatRouter = router({title: input.newTopic.title,});topicId = topicItem.id;- isCreatNewTopic = true;+ isCreateNewTopic = true;log('new topic created with id: %s', topicId);}@@ -125,7 +125,7 @@ export const aiChatRouter = router({// retrieve latest messages and topic withlog('retrieving messages and topics');const { messages, topics } = await ctx.aiChatService.getMessagesAndTopics({- includeTopic: isCreatNewTopic,+ includeTopic: isCreateNewTopic,sessionId: input.sessionId,topicId,});@@ -134,7 +134,7 @@ export const aiChatRouter = router({return {assistantMessageId: assistantMessageItem.id,- isCreatNewTopic,+ isCreateNewTopic,messages,topicId,topics,diff --git a/src/store/chat/slices/aiChat/actions/__tests__/generateAIChatV2.test.ts b/src/store/chat/slices/aiChat/actions/__tests__/generateAIChatV2.test.tsindex a34f87ec758..e0e9b5617a2 100644--- a/src/store/chat/slices/aiChat/actions/__tests__/generateAIChatV2.test.ts+++ b/src/store/chat/slices/aiChat/actions/__tests__/generateAIChatV2.test.ts@@ -3,7 +3,7 @@ import { TRPCClientError } from '@trpc/client';import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { LOADING_FLAT } from '@/const/message';-import { DEFAULT_MODEL, DEFAULT_PROVIDER } from '@/const/settings';+import { DEFAULT_AGENT_CHAT_CONFIG, DEFAULT_MODEL, DEFAULT_PROVIDER } from '@/const/settings';import { aiChatService } from '@/services/aiChat';import { chatService } from '@/services/chat';import { messageService } from '@/services/message';@@ -12,8 +12,9 @@ import { ChatMessage } from '@/types/message';import { useChatStore } from '../../../../store';import { messageMapKey } from '../../../../utils/messageMapKey';-import { TEST_CONTENT, TEST_IDS } from './fixtures';+import { TEST_CONTENT, TEST_IDS, createMockStoreState } from './fixtures';import { resetTestEnvironment, setupMockSelectors, spyOnMessageService } from './helpers';+import { agentChatConfigSelectors } from '@/store/agent/selectors';// Keep zustand mock as it's needed globallyvi.mock('zustand/traditional');@@ -56,7 +57,7 @@ vi.mock('@/services/aiChat', () => ({topicId,userMessageId: userId,assistantMessageId: assistantId,- isCreatNewTopic: !params.topicId,+ isCreateNewTopic: !params.topicId,} as any;}),},@@ -156,6 +157,76 @@ describe('generateAIChatV2 actions', () => {expect(result.current.internal_execAgentRuntime).toHaveBeenCalled();});+ it('should skip creating new topic when auto-create topic is disabled', async () => {+ const { result } = renderHook(() => useChatStore());++ (agentChatConfigSelectors.currentChatConfig as Mock).mockReturnValue({+ ...DEFAULT_AGENT_CHAT_CONFIG,+ enableAutoCreateTopic: false,+ });++ await act(async () => {+ useChatStore.setState({+ ...createMockStoreState(),+ activeTopicId: undefined,+ messagesMap: {},+ });++ await result.current.sendMessage({ message: 'disable auto create' });+ });++ const callArgs = (aiChatService.sendMessageInServer as Mock).mock.calls[0][0];+ expect(callArgs.newTopic).toBeUndefined();+ });++ it('should include newTopic payload when auto-create topic is enabled and threshold is reached', async () => {+ const { result } = renderHook(() => useChatStore());++ (agentChatConfigSelectors.currentChatConfig as Mock).mockReturnValue({+ ...DEFAULT_AGENT_CHAT_CONFIG,+ enableAutoCreateTopic: true,+ autoCreateTopicThreshold: 1,+ });++ await act(async () => {+ useChatStore.setState({+ ...createMockStoreState(),+ activeTopicId: undefined,+ messagesMap: {},+ });++ await result.current.sendMessage({ message: 'auto create topic' });+ });++ const callArgs = (aiChatService.sendMessageInServer as Mock).mock.calls[0][0];+ expect(callArgs.newTopic).toMatchObject({+ topicMessageIds: [],+ });+ });++ it('should not create new topic when threshold is not reached', async () => {+ const { result } = renderHook(() => useChatStore());++ (agentChatConfigSelectors.currentChatConfig as Mock).mockReturnValue({+ ...DEFAULT_AGENT_CHAT_CONFIG,+ enableAutoCreateTopic: true,+ autoCreateTopicThreshold: 10,+ });++ await act(async () => {+ useChatStore.setState({+ ...createMockStoreState(),+ activeTopicId: undefined,+ messagesMap: {},+ });++ await result.current.sendMessage({ message: 'threshold not met' });+ });++ const callArgs = (aiChatService.sendMessageInServer as Mock).mock.calls[0][0];+ expect(callArgs.newTopic).toBeUndefined();+ });+it('should send message with files attached', async () => {const { result } = renderHook(() => useChatStore());const files = [{ id: TEST_IDS.FILE_ID } as UploadFileItem];@@ -365,7 +436,7 @@ describe('generateAIChatV2 actions', () => {const { result } = renderHook(() => useChatStore());vi.spyOn(aiChatService, 'sendMessageInServer').mockResolvedValueOnce({- isCreatNewTopic: true,+ isCreateNewTopic: true,topicId: TEST_IDS.TOPIC_ID,messages: [{}, {}] as any,topics: [{}] as any,@@ -516,7 +587,7 @@ describe('generateAIChatV2 actions', () => {expect(result.current.mainSendMessageOperations[- messageMapKey(TEST_IDS.SESSION_ID, TEST_IDS.TOPIC_ID)+ messageMapKey(TEST_IDS.SESSION_ID, TEST_IDS.TOPIC_ID)],).toBeUndefined();});diff --git a/src/store/chat/slices/aiChat/actions/generateAIChatV2.ts b/src/store/chat/slices/aiChat/actions/generateAIChatV2.tsindex 1a6da616fc9..1e4f72161a3 100644--- a/src/store/chat/slices/aiChat/actions/generateAIChatV2.ts+++ b/src/store/chat/slices/aiChat/actions/generateAIChatV2.ts@@ -15,6 +15,7 @@ import { t } from 'i18next';import { produce } from 'immer';import { StateCreator } from 'zustand/vanilla';+import { DEFAULT_AGENT_CHAT_CONFIG } from '@/const/settings';import { aiChatService } from '@/services/aiChat';import { chatService } from '@/services/chat';import { messageService } from '@/services/message';@@ -109,6 +110,13 @@ export const generateAIChatV2: StateCreator<}const messages = chatSelectors.activeBaseChats(get());+ const chatConfig = agentChatConfigSelectors.currentChatConfig(getAgentStoreState());+ const autoCreateThreshold =+ chatConfig.autoCreateTopicThreshold ?? DEFAULT_AGENT_CHAT_CONFIG.autoCreateTopicThreshold;+ const shouldCreateNewTopic =+ !activeTopicId &&+ !!chatConfig.enableAutoCreateTopic &&+ messages.length + 2 >= autoCreateThreshold;// 构造服务端模式临时消息的本地媒体预览(优先使用 S3 URL)const filesInStore = getFileStoreState().chatUploadFileList;@@ -166,7 +174,7 @@ export const generateAIChatV2: StateCreator<// if there is activeTopicId,then add topicId to messagetopicId: activeTopicId,threadId: activeThreadId,- newTopic: !activeTopicId+ newTopic: shouldCreateNewTopic? {topicMessageIds: messages.map((m) => m.id),title: t('defaultTitle', { ns: 'topic' }),@@ -185,8 +193,8 @@ export const generateAIChatV2: StateCreator<topicId: data.topicId,});- if (!activeTopicId) {- await get().switchTopic(data.topicId!, true);+ if (data.isCreateNewTopic && data.topicId) {+ await get().switchTopic(data.topicId, true);}} catch (e) {if (e instanceof TRPCClientError) {@@ -203,7 +211,7 @@ export const generateAIChatV2: StateCreator<}// remove temporally message- if (data?.isCreatNewTopic) {+ if (data?.isCreateNewTopic) {get().internal_dispatchMessage({ type: 'deleteMessage', id: tempId },{ topicId: activeTopicId, sessionId: activeId },@@ -232,7 +240,7 @@ export const generateAIChatV2: StateCreator<const summaryTitle = async () => {// check activeTopic and then auto update topic title- if (data.isCreatNewTopic) {+ if (data.isCreateNewTopic) {await get().summaryTopicTitle(data.topicId, data.messages);return;}@@ -388,7 +396,8 @@ export const generateAIChatV2: StateCreator<)(aiInfraStoreState);const useModelBuiltinSearch = agentChatConfigSelectors.useModelBuiltinSearch(agentStoreState);const useModelSearch =- ((isProviderHasBuiltinSearch || isModelHasBuiltinSearch) && useModelBuiltinSearch) || isModelBuiltinSearchInternal;+ ((isProviderHasBuiltinSearch || isModelHasBuiltinSearch) && useModelBuiltinSearch) ||+ isModelBuiltinSearchInternal;const isAgentEnableSearch = agentChatConfigSelectors.isAgentEnableSearch(agentStoreState);if (isAgentEnableSearch && !useModelSearch && !isModelSupportToolUse) {