π€― 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: add the lost tools into manual agent runtime mode (#13918)
LiJian828175f8f017
diff --git a/packages/builtin-tool-activator/src/manifest.ts b/packages/builtin-tool-activator/src/manifest.tsindex b25386bcc89..a091d8e455f 100644--- a/packages/builtin-tool-activator/src/manifest.ts+++ b/packages/builtin-tool-activator/src/manifest.ts@@ -25,28 +25,12 @@ export const LobeActivatorManifest: BuiltinToolManifest = {type: 'object',},},- {- description:- 'Activate a skill by name to load its instructions. Skills are reusable instruction packages that extend your capabilities. Returns the skill content that you should follow to complete the task. If the skill is not found, returns a list of available skills.',- humanIntervention: 'required',- name: ActivatorApiName.activateSkill,- parameters: {- properties: {- name: {- description: 'The exact name of the skill to activate.',- type: 'string',- },- },- required: ['name'],- type: 'object',- },- },],identifier: LobeActivatorIdentifier,meta: {avatar: 'π§',- description: 'Discover and activate tools and skills',- title: 'Tools & Skills Activator',+ description: 'Discover and activate tools',+ title: 'Tools Activator',},systemRole: systemPrompt,type: 'builtin',diff --git a/packages/builtin-tool-activator/src/systemRole.ts b/packages/builtin-tool-activator/src/systemRole.tsindex c8c0469953e..9fd5ccd335d 100644--- a/packages/builtin-tool-activator/src/systemRole.ts+++ b/packages/builtin-tool-activator/src/systemRole.ts@@ -1,4 +1,4 @@-export const systemPrompt = `You have access to a Tools & Skills Activator that allows you to dynamically activate tools and skills on demand. Not all tools are loaded by default β you must activate them before use. Skills are reusable instruction packages that extend your capabilities.+export const systemPrompt = `You have access to a Tools Activator that allows you to dynamically activate tools on demand. Not all tools are loaded by default β you must activate them before use.<how_it_works>1. Available tools are listed in the \`<available_tools>\` section of your system prompt@@ -6,7 +6,7 @@ export const systemPrompt = `You have access to a Tools & Skills Activator that3. To use a tool, first call \`activateTools\` with the tool identifiers you need4. After activation, the tool's full API schemas become available as native function calls in subsequent turns5. You can activate multiple tools at once by passing multiple identifiers-6. To activate a skill, call \`activateSkill\` with the skill name β it returns instructions to follow+6. To activate a skill, use the \`activateSkill\` tool from lobe-skills β it returns instructions to follow</how_it_works><tool_selection_guidelines>@@ -16,10 +16,7 @@ export const systemPrompt = `You have access to a Tools & Skills Activator that- After activation, the tools' APIs will be available for you to call directly- Tools that are already active will be noted in the response- If an identifier is not found, it will be reported in the response-- **activateSkill**: Call this when the user's task matches one of the available skills- - Provide the exact skill name- - Returns the skill content (instructions, templates, guidelines) that you should follow- - If the skill is not found, you'll receive a list of available skills+- **activateSkill** (provided by lobe-skills): Use this when the user's task matches one of the available skills- **IMPORTANT**: If a skill's content is already provided in \`<selected_skill_context>\` within the user message, do NOT call activateSkill for that skill β its instructions are already loaded and ready to use</tool_selection_guidelines>diff --git a/packages/builtin-tool-skills/src/manifest.desktop.ts b/packages/builtin-tool-skills/src/manifest.desktop.tsindex 0b8172f94a7..3cc56655e14 100644--- a/packages/builtin-tool-skills/src/manifest.desktop.ts+++ b/packages/builtin-tool-skills/src/manifest.desktop.ts@@ -1,11 +1,17 @@import type { BuiltinToolManifest } from '@lobechat/types';-import { execScriptBaseParams, manifestMeta, readReferenceApi } from './manifest.base';+import {+ activateSkillApi,+ execScriptBaseParams,+ manifestMeta,+ readReferenceApi,+} from './manifest.base';import { systemPrompt } from './systemRole';import { SkillsApiName, SkillsIdentifier } from './types';export const SkillsManifest: BuiltinToolManifest = {api: [+ activateSkillApi,readReferenceApi,{description:diff --git a/packages/builtin-tool-skills/src/manifest.ts b/packages/builtin-tool-skills/src/manifest.tsindex c634716ddc2..fad56c6c674 100644--- a/packages/builtin-tool-skills/src/manifest.ts+++ b/packages/builtin-tool-skills/src/manifest.ts@@ -1,6 +1,7 @@import type { BuiltinToolManifest } from '@lobechat/types';import {+ activateSkillApi,execScriptBaseParams,exportFileApi,manifestMeta,@@ -12,6 +13,7 @@ import { SkillsApiName, SkillsIdentifier } from './types';export const SkillsManifest: BuiltinToolManifest = {api: [+ activateSkillApi,readReferenceApi,runCommandApi,{diff --git a/packages/builtin-tool-skills/src/systemRole.desktop.ts b/packages/builtin-tool-skills/src/systemRole.desktop.tsindex 9e1b5e9b135..b35a798fd58 100644--- a/packages/builtin-tool-skills/src/systemRole.desktop.ts+++ b/packages/builtin-tool-skills/src/systemRole.desktop.ts@@ -1,17 +1,25 @@-export const systemPrompt = `You have access to a Skills execution tool that provides runtime capabilities for activated skills. Use these tools when a skill's instructions tell you to read files or run commands.+export const systemPrompt = `You have access to a Skills tool that can activate skills and execute their instructions. Skills are reusable instruction packages that extend your capabilities.<core_capabilities>-1. Read reference files attached to a skill (readReference)-2. Execute shell commands specified in a skill's instructions (execScript)+1. Activate a skill by name to load its instructions (activateSkill)+2. Read reference files attached to a skill (readReference)+3. Execute shell commands specified in a skill's instructions (execScript)</core_capabilities><workflow>-1. After a skill has been activated, follow its instructions to complete the task-2. If the skill content references additional files, use readReference to load them-3. If the skill content instructs you to run CLI commands, use execScript to execute them+1. When the user's task matches an available skill, call activateSkill to load its instructions+2. Follow the skill's instructions to complete the task+3. If the skill content references additional files, use readReference to load them+4. If the skill content instructs you to run CLI commands, use execScript to execute them</workflow><tool_selection_guidelines>+- **activateSkill**: Call this when the user's task matches one of the available skills+ - Provide the exact skill name+ - Returns the skill content (instructions, templates, guidelines) that you should follow+ - If the skill is not found, you'll receive a list of available skills+ - **IMPORTANT**: If a skill's content is already provided in \`<selected_skill_context>\` within the user message, do NOT call activateSkill for that skill β its instructions are already loaded and ready to use+- **readReference**: Call this to read reference files mentioned in a skill's content- Requires the id (returned by activateSkill) and the file path- Returns the file content for you to use as contextdiff --git a/packages/builtin-tool-skills/src/systemRole.ts b/packages/builtin-tool-skills/src/systemRole.tsindex 35be45155c7..5360430c3ac 100644--- a/packages/builtin-tool-skills/src/systemRole.ts+++ b/packages/builtin-tool-skills/src/systemRole.ts@@ -1,21 +1,29 @@-export const systemPrompt = `You have access to a Skills execution tool that provides runtime capabilities for activated skills. Use these tools when a skill's instructions tell you to read files, run commands, or export results.+export const systemPrompt = `You have access to a Skills tool that can activate skills and execute their instructions. Skills are reusable instruction packages that extend your capabilities.<core_capabilities>-1. Read reference files attached to a skill (readReference)-2. Execute shell commands in the cloud sandbox (runCommand)-3. Execute skill-specific scripts with resource context (execScript)-4. Export files generated during skill execution to cloud storage (exportFile)+1. Activate a skill by name to load its instructions (activateSkill)+2. Read reference files attached to a skill (readReference)+3. Execute shell commands in the cloud sandbox (runCommand)+4. Execute skill-specific scripts with resource context (execScript)+5. Export files generated during skill execution to cloud storage (exportFile)</core_capabilities><workflow>-1. After a skill has been activated, follow its instructions to complete the task-2. If the skill content references additional files, use readReference to load them-3. If the skill content instructs you to run CLI commands, use runCommand to execute them-4. If the command requires skill-bundled resources, use execScript instead-5. If the skill execution generates output files, use exportFile to save them for the user+1. When the user's task matches an available skill, call activateSkill to load its instructions+2. Follow the skill's instructions to complete the task+3. If the skill content references additional files, use readReference to load them+4. If the skill content instructs you to run CLI commands, use runCommand to execute them+5. If the command requires skill-bundled resources, use execScript instead+6. If the skill execution generates output files, use exportFile to save them for the user</workflow><tool_selection_guidelines>+- **activateSkill**: Call this when the user's task matches one of the available skills+ - Provide the exact skill name+ - Returns the skill content (instructions, templates, guidelines) that you should follow+ - If the skill is not found, you'll receive a list of available skills+ - **IMPORTANT**: If a skill's content is already provided in \`<selected_skill_context>\` within the user message, do NOT call activateSkill for that skill β its instructions are already loaded and ready to use+- **readReference**: Call this to read reference files mentioned in a skill's content- Requires the id (returned by activateSkill) and the file path- Returns the file content for you to use as contextdiff --git a/src/services/chat/mecha/contextEngineering.ts b/src/services/chat/mecha/contextEngineering.tsindex 588c9a67097..71c9301a1f7 100644--- a/src/services/chat/mecha/contextEngineering.ts+++ b/src/services/chat/mecha/contextEngineering.ts@@ -661,9 +661,20 @@ export const contextEngineering = async ({selectedSkills: initialContext?.selectedSkills,selectedTools: initialContext?.selectedTools,- // Skills configuration β expose all installed skills so the AI can discover and activate them+ // Skills configuration+ // In auto mode: expose all installed skills so the AI can discover and activate them+ // In manual mode: only expose user-selected skills (filtered by pluginIds)skillsConfig: {- enabledSkills: plugins ? resolveClientSkills(plugins).skills : undefined,+ enabledSkills: plugins+ ? (() => {+ const skillSet = resolveClientSkills(plugins);+ if (!isInAutoSkillMode) {+ const selectedIds = new Set(plugins);+ return skillSet.skills.filter((s) => selectedIds.has(s.identifier));+ }+ return skillSet.skills;+ })()+ : undefined,},// Tool Discovery configurationdiff --git a/src/store/chat/slices/aiChat/actions/__tests__/streamingExecutor.test.ts b/src/store/chat/slices/aiChat/actions/__tests__/streamingExecutor.test.tsindex 178142473a0..52d32ec37e5 100644--- a/src/store/chat/slices/aiChat/actions/__tests__/streamingExecutor.test.ts+++ b/src/store/chat/slices/aiChat/actions/__tests__/streamingExecutor.test.ts@@ -900,6 +900,144 @@ describe('StreamingExecutor actions', () => {);});+ it('should use excludeDefaultToolIds (not skipDefaultTools) in manual mode for builtin agents', () => {+ act(() => {+ useChatStore.setState({ internal_execAgentRuntime: realExecAgentRuntime });+ });++ const { result } = renderHook(() => useChatStore());+ const userMessage = {+ id: TEST_IDS.USER_MESSAGE_ID,+ role: 'user',+ content: TEST_CONTENT.USER_MESSAGE,+ sessionId: TEST_IDS.SESSION_ID,+ topicId: TEST_IDS.TOPIC_ID,+ } as UIChatMessage;++ const generateToolsDetailed = vi.fn().mockReturnValue({+ enabledManifests: [],+ enabledToolIds: [],+ tools: [],+ });++ vi.spyOn(agentConfigResolver, 'resolveAgentConfig').mockReturnValue({+ agentConfig: createMockAgentConfig(),+ chatConfig: createMockChatConfig({ skillActivateMode: 'manual' }),+ isBuiltinAgent: true,+ plugins: [],+ });+ vi.spyOn(toolEngineering, 'createAgentToolsEngine').mockReturnValue({+ generateToolsDetailed,+ } as any);++ result.current.internal_createAgentState({+ messages: [userMessage],+ parentMessageId: userMessage.id,+ agentId: TEST_IDS.SESSION_ID,+ topicId: TEST_IDS.TOPIC_ID,+ });++ expect(generateToolsDetailed).toHaveBeenCalledWith(+ expect.objectContaining({+ // Must NOT use skipDefaultTools for builtin agents in manual mode+ skipDefaultTools: undefined,+ // Must use excludeDefaultToolIds to only exclude discovery tools+ excludeDefaultToolIds: expect.arrayContaining(['lobe-activator', 'lobe-skill-store']),+ }),+ );+ });++ it('should use excludeDefaultToolIds in manual mode for regular agents', () => {+ act(() => {+ useChatStore.setState({ internal_execAgentRuntime: realExecAgentRuntime });+ });++ const { result } = renderHook(() => useChatStore());+ const userMessage = {+ id: TEST_IDS.USER_MESSAGE_ID,+ role: 'user',+ content: TEST_CONTENT.USER_MESSAGE,+ sessionId: TEST_IDS.SESSION_ID,+ topicId: TEST_IDS.TOPIC_ID,+ } as UIChatMessage;++ const generateToolsDetailed = vi.fn().mockReturnValue({+ enabledManifests: [],+ enabledToolIds: [],+ tools: [],+ });++ vi.spyOn(agentConfigResolver, 'resolveAgentConfig').mockReturnValue({+ agentConfig: createMockAgentConfig(),+ chatConfig: createMockChatConfig({ skillActivateMode: 'manual' }),+ isBuiltinAgent: false,+ plugins: [],+ });+ vi.spyOn(toolEngineering, 'createAgentToolsEngine').mockReturnValue({+ generateToolsDetailed,+ } as any);++ result.current.internal_createAgentState({+ messages: [userMessage],+ parentMessageId: userMessage.id,+ agentId: TEST_IDS.SESSION_ID,+ topicId: TEST_IDS.TOPIC_ID,+ });++ expect(generateToolsDetailed).toHaveBeenCalledWith(+ expect.objectContaining({+ skipDefaultTools: undefined,+ excludeDefaultToolIds: expect.arrayContaining(['lobe-activator', 'lobe-skill-store']),+ }),+ );+ });++ it('should not set excludeDefaultToolIds in auto mode', () => {+ act(() => {+ useChatStore.setState({ internal_execAgentRuntime: realExecAgentRuntime });+ });++ const { result } = renderHook(() => useChatStore());+ const userMessage = {+ id: TEST_IDS.USER_MESSAGE_ID,+ role: 'user',+ content: TEST_CONTENT.USER_MESSAGE,+ sessionId: TEST_IDS.SESSION_ID,+ topicId: TEST_IDS.TOPIC_ID,+ } as UIChatMessage;++ const generateToolsDetailed = vi.fn().mockReturnValue({+ enabledManifests: [],+ enabledToolIds: [],+ tools: [],+ });++ vi.spyOn(agentConfigResolver, 'resolveAgentConfig').mockReturnValue({+ agentConfig: createMockAgentConfig(),+ chatConfig: createMockChatConfig(),+ isBuiltinAgent: true,+ plugins: [],+ });+ vi.spyOn(toolEngineering, 'createAgentToolsEngine').mockReturnValue({+ generateToolsDetailed,+ } as any);++ result.current.internal_createAgentState({+ messages: [userMessage],+ parentMessageId: userMessage.id,+ agentId: TEST_IDS.SESSION_ID,+ topicId: TEST_IDS.TOPIC_ID,+ });++ // In auto mode, no tools should be excluded from defaults+ expect(generateToolsDetailed).toHaveBeenCalledWith(+ expect.objectContaining({+ skipDefaultTools: undefined,+ excludeDefaultToolIds: undefined,+ }),+ );+ });+it('should preserve default model/provider payload when initialContext is provided', () => {act(() => {useChatStore.setState({ internal_execAgentRuntime: realExecAgentRuntime });diff --git a/src/store/chat/slices/aiChat/actions/streamingExecutor.ts b/src/store/chat/slices/aiChat/actions/streamingExecutor.tsindex e4a7027f713..65b22ca9e07 100644--- a/src/store/chat/slices/aiChat/actions/streamingExecutor.ts+++ b/src/store/chat/slices/aiChat/actions/streamingExecutor.ts@@ -186,17 +186,15 @@ export class StreamingExecutorActionImpl {effectivePluginIds,);// When skillActivateMode is 'manual':- // - Builtin agents: skip all default tools (they define their own precise tool set)- // - Regular agents: exclude only discovery tools so externally enabled tools remain available+ // Exclude only discovery tools (activator, skill-store) so runtime-managed defaults+ // (skills, web-browsing, sandbox, memory, etc.) remain available for all agents.const isManualMode = agentConfig.chatConfig?.skillActivateMode === 'manual';- const shouldSkipDefaultForBuiltin = isManualMode && agentConfig.isBuiltinAgent;const toolsDetailed = toolsEngine.generateToolsDetailed({- excludeDefaultToolIds:- isManualMode && !agentConfig.isBuiltinAgent ? manualModeExcludeToolIds : undefined,+ excludeDefaultToolIds: isManualMode ? manualModeExcludeToolIds : undefined,model: agentConfigData.model,provider: agentConfigData.provider!,- skipDefaultTools: disableTools || shouldSkipDefaultForBuiltin || undefined,+ skipDefaultTools: disableTools || undefined,toolIds: mergedToolIds,});