π€― 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(agent-builder): strip conflicting agent tools in builder mode (#16420)
LiJiana4002f742a71
diff --git a/packages/builtin-agents/package.json b/packages/builtin-agents/package.jsonindex 71fde0eec19..a68305a5a9a 100644--- a/packages/builtin-agents/package.json+++ b/packages/builtin-agents/package.json@@ -10,6 +10,11 @@},"main": "./src/index.ts","types": "./src/index.ts",+ "scripts": {+ "test": "vitest",+ "test:coverage": "vitest --coverage --silent='passed-only'",+ "test:update": "vitest -u"+ },"dependencies": {"@lobechat/builtin-tool-agent-builder": "workspace:*","@lobechat/builtin-tool-agent-documents": "workspace:*",diff --git a/packages/builtin-agents/src/agents/agent-builder/index.test.ts b/packages/builtin-agents/src/agents/agent-builder/index.test.tsnew file mode 100644index 00000000000..abe22e9b73b--- /dev/null+++ b/packages/builtin-agents/src/agents/agent-builder/index.test.ts@@ -0,0 +1,41 @@+import { AgentBuilderIdentifier } from '@lobechat/builtin-tool-agent-builder';+import { describe, expect, it } from 'vitest';++import { getAgentRuntimeConfig } from '../../index';+import { BUILTIN_AGENT_SLUGS } from '../../types';++const resolvePlugins = (plugins?: string[]) =>+ getAgentRuntimeConfig(BUILTIN_AGENT_SLUGS.agentBuilder, { plugins })?.plugins ?? [];++describe('AGENT_BUILDER runtime plugins', () => {+ it('always includes the Agent Builder tool', () => {+ expect(resolvePlugins()).toEqual([AgentBuilderIdentifier]);+ });++ it('strips conflicting agent-editing / orchestration tools', () => {+ const plugins = resolvePlugins([+ 'lobe-agent-management',+ 'lobe-group-management',+ 'lobe-group-agent-builder',+ 'lobe-agent',+ ]);++ expect(plugins).toEqual([AgentBuilderIdentifier]);+ });++ it('keeps functional plugins (web browsing, Gmail/Composio, etc.)', () => {+ const plugins = resolvePlugins([+ 'lobe-web-browsing',+ 'lobe-image-generation',+ 'gmail',+ 'lobe-agent-management', // conflicting β removed+ ]);++ expect(plugins).toEqual([+ AgentBuilderIdentifier,+ 'lobe-web-browsing',+ 'lobe-image-generation',+ 'gmail',+ ]);+ });+});diff --git a/packages/builtin-agents/src/agents/agent-builder/index.ts b/packages/builtin-agents/src/agents/agent-builder/index.tsindex 36284154885..0db97ecd9ce 100644--- a/packages/builtin-agents/src/agents/agent-builder/index.ts+++ b/packages/builtin-agents/src/agents/agent-builder/index.ts@@ -6,6 +6,37 @@ import type { BuiltinAgentDefinition } from '../../types';import { BUILTIN_AGENT_SLUGS } from '../../types';import { systemRoleTemplate } from './systemRole';+/**+ * Builtin tools that conflict with the Agent Builder when they coexist in the+ * same conversation. In Agent Builder mode the Agent Builder tool is the SOLE+ * authority for editing the agent being configured, so these agent-editing /+ * orchestration tools are stripped from `ctx.plugins`:+ *+ * - `lobe-agent-management`: duplicate edit APIs (updatePrompt / updateAgent /+ * installPlugin) PLUS a `<self_management>` prompt whose `<current_agent>`+ * points at the builder ITSELF and tells the model to "prefer Agent Management+ * and modify the current agent (yourself)". With both toolsets present this is+ * what makes an ambiguous "help me change ..." edit the builder's own config+ * instead of the agent on the left.+ * - `lobe-group-management` / `lobe-group-agent-builder`: group agent CRUD /+ * callAgent β a second, overlapping "edit/orchestrate agents" surface.+ * - `lobe-agent`: sub-agent dispatch / planning / todos β orchestration noise+ * that competes with the builder's single "configure this agent" job.+ *+ * Functional plugins the edited agent carries (web browsing, image generation,+ * Gmail / Composio integrations, marketplace MCP, etc.) are intentionally kept β+ * the builder may still use them, and only the conflicting tools above are+ * removed. Identifiers are the stable persisted plugin ids (see each tool's+ * `*Identifier`); using literals here mirrors `EXCLUDED_TOOLS` in the tool-store+ * selectors and avoids pulling extra package deps into builtin-agents.+ */+const AGENT_BUILDER_CONFLICTING_TOOLS = new Set<string>([+ 'lobe-agent-management',+ 'lobe-group-management',+ 'lobe-group-agent-builder',+ 'lobe-agent',+]);+/*** Agent Builder - used for configuring AI agents through natural conversation*/@@ -20,7 +51,10 @@ export const AGENT_BUILDER: BuiltinAgentDefinition = {// Runtime config - static systemRoleruntime: (ctx) => ({- plugins: [AgentBuilderIdentifier, ...(ctx.plugins || [])],+ plugins: [+ AgentBuilderIdentifier,+ ...(ctx.plugins || []).filter((id) => !AGENT_BUILDER_CONFLICTING_TOOLS.has(id)),+ ],systemRole: systemRoleTemplate,}),diff --git a/packages/builtin-agents/vitest.config.mts b/packages/builtin-agents/vitest.config.mtsnew file mode 100644index 00000000000..52f86e133c7--- /dev/null+++ b/packages/builtin-agents/vitest.config.mts@@ -0,0 +1,11 @@+import { defineConfig } from 'vitest/config';++export default defineConfig({+ test: {+ coverage: {+ provider: 'v8',+ reporter: ['text', 'json', 'lcov', 'text-summary'],+ },+ environment: 'node',+ },+});