Skip to content

🀯 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.

✨ feat(tool): context-aware builtin manifests (resolveManifest) + group/sub-agent gating (#16311)

Arvin Xu9ce5aceb2abd
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 35e43c88dd4..859c6b756cc 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -946,6 +946,7 @@
"tts.action": "Text-to-Speech",
"tts.clear": "Clear Speech",
"turnProcess.done": "Processed",
+ "turnProcess.ranFor": "Ran for {{duration}}",
"untitledAgent": "Untitled Agent",
"untitledGroup": "Untitled Group",
"updateAgent": "Update Agent Information",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 81d46202dd8..a052c14ef0a 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -946,6 +946,7 @@
"tts.action": "θ―­ιŸ³ζœ—θ―»",
"tts.clear": "εˆ ι™€θ―­ιŸ³",
"turnProcess.done": "已倄理",
+ "turnProcess.ranFor": "ε…±θΏθ‘Œ {{duration}}",
"untitledAgent": "ζœͺε‘½εεŠ©η†",
"untitledGroup": "ζœͺ命名羀组",
"updateAgent": "ζ›΄ζ–°εŠ©η†δΏ‘ζ―",
diff --git a/packages/builtin-tool-lobe-agent/src/index.ts b/packages/builtin-tool-lobe-agent/src/index.ts
index 4321213778e..1779b0fb527 100644
--- a/packages/builtin-tool-lobe-agent/src/index.ts
+++ b/packages/builtin-tool-lobe-agent/src/index.ts
@@ -6,6 +6,7 @@ export {
type PlanRuntimeService,
} from './client/executor/PlanRuntime';
export * from './manifest';
+export * from './resolveManifest';
export * from './systemRole';
export * from './types';
export * from './visualMedia';
diff --git a/packages/builtin-tool-lobe-agent/src/resolveManifest.test.ts b/packages/builtin-tool-lobe-agent/src/resolveManifest.test.ts
new file mode 100644
index 00000000000..b4250e05025
--- /dev/null
+++ b/packages/builtin-tool-lobe-agent/src/resolveManifest.test.ts
@@ -0,0 +1,66 @@
+import { describe, expect, it } from 'vitest';
+
+import { LobeAgentManifest } from './manifest';
+import { resolveLobeAgentManifest } from './resolveManifest';
+import { systemPromptWithoutSubAgent } from './systemRole';
+import { LobeAgentApiName } from './types';
+
+const apiNames = (manifest: { api: { name: string }[] }) => manifest.api.map((a) => a.name);
+
+describe('resolveLobeAgentManifest', () => {
+ it('returns the full static manifest in a normal (main, non-sub-agent) turn', () => {
+ const result = resolveLobeAgentManifest({ scope: 'main' });
+
+ // identical reference β€” no trimming, no clone
+ expect(result).toBe(LobeAgentManifest);
+ expect(apiNames(result!)).toContain(LobeAgentApiName.callSubAgent);
+ // full prompt still describes sub-agent dispatch
+ expect(result!.systemRole).toContain('callSubAgent');
+ });
+
+ it('returns the full manifest when no context signals are set', () => {
+ expect(resolveLobeAgentManifest({})).toBe(LobeAgentManifest);
+ });
+
+ it.each(['group', 'group_agent'])(
+ 'hides callSubAgent in both api and systemRole (keeping plan/todo/visual) in scope %s',
+ (scope) => {
+ const result = resolveLobeAgentManifest({ scope })!;
+
+ const names = apiNames(result);
+ expect(names).not.toContain(LobeAgentApiName.callSubAgent);
+ // the rest of lobe-agent stays available
+ expect(names).toContain(LobeAgentApiName.createPlan);
+ expect(names).toContain(LobeAgentApiName.createTodos);
+ expect(names).toContain(LobeAgentApiName.analyzeVisualMedia);
+ // exactly one API removed
+ expect(names).toHaveLength(LobeAgentManifest.api.length - 1);
+
+ // systemRole is rewritten so the prompt no longer mentions the hidden tool
+ expect(result.systemRole).toBe(systemPromptWithoutSubAgent);
+ expect(result.systemRole).not.toContain('callSubAgent');
+ expect(result.systemRole).not.toContain('sub_agents');
+ // plan/todo guidance survives in the rewritten prompt
+ expect(result.systemRole).toContain('plan_and_todos');
+
+ // non-api fields preserved
+ expect(result.identifier).toBe(LobeAgentManifest.identifier);
+ },
+ );
+
+ it('hides callSubAgent (api + systemRole) inside a sub-agent run regardless of scope', () => {
+ const result = resolveLobeAgentManifest({ isSubAgent: true, scope: 'main' })!;
+
+ expect(apiNames(result)).not.toContain(LobeAgentApiName.callSubAgent);
+ expect(apiNames(result)).toContain(LobeAgentApiName.createPlan);
+ expect(result.systemRole).not.toContain('callSubAgent');
+ });
+
+ it('does not mutate the original static manifest', () => {
+ const before = LobeAgentManifest.api.length;
+ resolveLobeAgentManifest({ scope: 'group' });
+ expect(LobeAgentManifest.api).toHaveLength(before);
+ // the full manifest's systemRole still describes sub-agent dispatch
+ expect(LobeAgentManifest.systemRole).toContain('callSubAgent');
+ });
+});
diff --git a/packages/builtin-tool-lobe-agent/src/resolveManifest.ts b/packages/builtin-tool-lobe-agent/src/resolveManifest.ts
new file mode 100644
index 00000000000..37d6d85e8fa
--- /dev/null
+++ b/packages/builtin-tool-lobe-agent/src/resolveManifest.ts
@@ -0,0 +1,36 @@
+import type { BuiltinManifestResolver } from '@lobechat/types';
+
+import { LobeAgentManifest } from './manifest';
+import { systemPromptWithoutSubAgent } from './systemRole';
+import { LobeAgentApiName } from './types';
+
+/**
+ * Context-aware manifest for the lobe-agent tool.
+ *
+ * `lobe-agent` bundles plan / todo / visual-media APIs together with the
+ * `callSubAgent` dispatch. The dispatch must be hidden in two contexts:
+ *
+ * - **Inside a group** (`scope` is `group` / `group_agent`): coordination already
+ * happens through real member agents via GroupManagement; an isolated ad-hoc
+ * sub-agent on top of that is redundant and confusing.
+ * - **Inside a sub-agent** (`isSubAgent`): a nested sub-agent must not spawn
+ * further sub-agents.
+ *
+ * In both cases plan / todo / visual-media stay available, so this returns a
+ * trimmed manifest (not `null`). It rewrites BOTH halves of the manifest in step:
+ * the `api` list drops `callSubAgent`, and `systemRole` switches to the variant
+ * without the sub-agent section β€” otherwise the prompt would keep instructing the
+ * model to dispatch a tool that is no longer in its tool list.
+ */
+export const resolveLobeAgentManifest: BuiltinManifestResolver = (context) => {
+ const inGroup = context.scope === 'group' || context.scope === 'group_agent';
+ const hideSubAgentDispatch = inGroup || context.isSubAgent === true;
+
+ if (!hideSubAgentDispatch) return LobeAgentManifest;
+
+ return {
+ ...LobeAgentManifest,
+ api: LobeAgentManifest.api.filter((api) => api.name !== LobeAgentApiName.callSubAgent),
+ systemRole: systemPromptWithoutSubAgent,
+ };
+};
diff --git a/packages/builtin-tool-lobe-agent/src/systemRole.ts b/packages/builtin-tool-lobe-agent/src/systemRole.ts
index 520a0d57654..fd7da60604c 100644
--- a/packages/builtin-tool-lobe-agent/src/systemRole.ts
+++ b/packages/builtin-tool-lobe-agent/src/systemRole.ts
@@ -213,7 +213,20 @@ Use it only for refs/URLs you cannot inspect directly, or when the active model
</visual_analysis>
`;
-export const systemPrompt = `Use Lobe Agent capabilities only when the active model needs built-in assistance. Prefer the active model's native capabilities whenever they are sufficient. Follow each tool's description and schema, and use tool results to answer the user directly.
+// Sections independent of sub-agent dispatch (visual fallback + plan/todo). Kept
+// as a base so contexts where callSubAgent is unavailable can drop the sub-agent
+// guidance without leaving dangling references to a tool the model can't call.
+const baseSystemPrompt = `Use Lobe Agent capabilities only when the active model needs built-in assistance. Prefer the active model's native capabilities whenever they are sufficient. Follow each tool's description and schema, and use tool results to answer the user directly.
${visualAnalysisSection}
-${planTodoSection}
+${planTodoSection}`;
+
+/** Full prompt, including sub-agent dispatch (callSubAgent) guidance. */
+export const systemPrompt = `${baseSystemPrompt}
${subAgentSection}`;
+
+/**
+ * Prompt variant for contexts where the callSubAgent API is hidden (group /
+ * sub-agent runs). Drops the whole sub-agent section so the systemRole never
+ * instructs the model to use a tool that isn't in its tool list.
+ */
+export const systemPromptWithoutSubAgent = baseSystemPrompt;
diff --git a/packages/builtin-tools/src/index.ts b/packages/builtin-tools/src/index.ts
index 82fc7e0d149..a3b191df82b 100644
--- a/packages/builtin-tools/src/index.ts
+++ b/packages/builtin-tools/src/index.ts
@@ -15,7 +15,7 @@ import { CredsManifest } from '@lobechat/builtin-tool-creds';
import { GroupAgentBuilderManifest } from '@lobechat/builtin-tool-group-agent-builder';
import { GroupManagementManifest } from '@lobechat/builtin-tool-group-management';
import { KnowledgeBaseManifest } from '@lobechat/builtin-tool-knowledge-base';
-import { LobeAgentManifest } from '@lobechat/builtin-tool-lobe-agent';
+import { LobeAgentManifest, resolveLobeAgentManifest } from '@lobechat/builtin-tool-lobe-agent';
import { LobeDeliveryCheckerManifest } from '@lobechat/builtin-tool-lobe-delivery-checker';
import { LocalSystemManifest } from '@lobechat/builtin-tool-local-system';
import { MemoryManifest } from '@lobechat/builtin-tool-memory';
@@ -128,7 +128,7 @@ export const runtimeManagedToolIds = [
WebBrowsingManifest.identifier,
];
-export const builtinTools: LobeBuiltinTool[] = [
+const builtinToolRegistry: LobeBuiltinTool[] = [
{
discoverable: false,
hidden: true,
@@ -326,6 +326,8 @@ export const builtinTools: LobeBuiltinTool[] = [
hidden: true,
identifier: LobeAgentManifest.identifier,
manifest: LobeAgentManifest,
+ // Context-aware: hides the `callSubAgent` API inside group / sub-agent runs.
+ resolveManifest: resolveLobeAgentManifest,
type: 'builtin',
},
{
@@ -335,6 +337,25 @@ export const builtinTools: LobeBuiltinTool[] = [
},
];
+/**
+ * Hoist each tool's `manifest.meta` identity (title / avatar / description / tags)
+ * onto the top level, so context-free consumers (UI lists, discovery, settings,
+ * token estimation) read `tool.title` / `tool.avatar` directly instead of reaching
+ * into `manifest.meta`. This keeps identity stable and decoupled from `manifest`,
+ * which may be produced per-turn by a context-aware `resolveManifest`.
+ *
+ * Optional chaining is defensive: this runs at module load, and tests routinely
+ * mock individual builtin-tool packages (a stubbed manifest may lack `meta`). In
+ * production every builtin manifest has a `meta`, so the hoisted fields are real.
+ */
+export const builtinTools: LobeBuiltinTool[] = builtinToolRegistry.map((tool) => ({
+ ...tool,
+ avatar: tool.manifest?.meta?.avatar,
+ description: tool.manifest?.meta?.description,
+ tags: tool.manifest?.meta?.tags,
+ title: tool.manifest?.meta?.title,
+}));
+
const recommendedBuiltinIds = new Set(
RECOMMENDED_SKILLS.filter((s) => s.type === RecommendedSkillType.Builtin).map((s) => s.id),
);
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 1b9567226a1..8f25378e5fa 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -1042,6 +1042,7 @@ export default {
'tts.action': 'Text-to-Speech',
'tts.clear': 'Clear Speech',
'turnProcess.done': 'Processed',
+ 'turnProcess.ranFor': 'Ran for {{duration}}',
'untitledAgent': 'Untitled Agent',
'untitledGroup': 'Untitled Group',
'updateAgent': 'Update Agent Information',
diff --git a/packages/types/src/tool/builtin.ts b/packages/types/src/tool/builtin.ts
index 1921b48db43..d07c57212a0 100644
--- a/packages/types/src/tool/builtin.ts
+++ b/packages/types/src/tool/builtin.ts
@@ -236,11 +236,62 @@ export const BuiltinToolManifestSchema = z.object({
type: z.literal('builtin').optional(),
});
+/**
+ * Runtime context handed to a builtin tool's manifest resolver so the tool can
+ * self-trim per conversation context instead of relying on scattered, hard-coded
+ * filters in the consuming layers (agentConfigResolver / toolSetComposer).
+ *
+ * Mirror of the builtin-agent `runtime: (ctx) => config` pattern, but for tools.
+ * Extend this with new signals (e.g. isDesktop, isPageEditorReady, groupId) as
+ * more tools migrate their context-based trimming here.
+ */
+export interface BuiltinToolResolveContext {
+ /**
+ * True when running inside a sub-agent execution. A nested sub-agent must not
+ * be able to dispatch further sub-agents.
+ */
+ isSubAgent?: boolean;
+ /**
+ * Conversation scope, e.g. 'main' | 'page' | 'task' | 'group' | 'group_agent'
+ * | 'thread' | 'sub_agent'. Kept as a string to avoid coupling the tool layer
+ * to the operation/message scope unions.
+ */
+ scope?: string;
+}
+
+/**
+ * Context-aware manifest factory for a builtin tool. Return a trimmed manifest
+ * (e.g. with certain APIs filtered out) for the given context, or `null` to make
+ * the tool unavailable entirely in that context.
+ */
+export type BuiltinManifestResolver = (
+ context: BuiltinToolResolveContext,
+) => BuiltinToolManifest | null;
+
export interface LobeBuiltinTool {
+ /** Identity (hoisted from `manifest.meta`): icon shown in UI lists. */
+ avatar?: string;
+ /** Identity (hoisted from `manifest.meta`): short description shown in UI. */
+ description?: string;
discoverable?: boolean;
hidden?: boolean;
identifier: string;
manifest: BuiltinToolManifest;
+ /**
+ * Optional context-aware override for `manifest`. When present AND a resolve
+ * context is supplied (the agent runtime / tools-engine path), the resolver's
+ * result replaces the static `manifest` for that turn, letting the tool gate
+ * its own availability or hide specific APIs based on context.
+ *
+ * The static `manifest` stays the full-capability set used by context-free
+ * consumers (UI tool lists, discovery, settings, token estimation), so adding
+ * a resolver never breaks those synchronous reads.
+ */
+ resolveManifest?: BuiltinManifestResolver;
+ /** Identity (hoisted from `manifest.meta`): tags shown in UI / discovery. */
+ tags?: string[];
+ /** Identity (hoisted from `manifest.meta`): display name. Falls back to `identifier`. */
+ title?: string;
type: 'builtin';
}
diff --git a/src/features/Conversation/Messages/AssistantGroup/components/ProcessFold.tsx b/src/features/Conversation/Messages/AssistantGroup/components/ProcessFold.tsx
index 8b0487852f2..f0379a4501f 100644
--- a/src/features/Conversation/Messages/AssistantGroup/components/ProcessFold.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/components/ProcessFold.tsx
@@ -1,16 +1,7 @@
-import { Accordion, AccordionItem, Flexbox, Text } from '@lobehub/ui';
-import { createStaticStyles, cssVar } from 'antd-style';
+import { Accordion, AccordionItem, Text } from '@lobehub/ui';
import { type Key, memo, type ReactNode, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
-const styles = createStaticStyles(({ css }) => ({
- duration: css`
- flex: none;
- font-size: 12px;
- color: ${cssVar.colorTextQuaternary};
- `,
-}));
-
const PROCESS_KEY = 'process';
interface ProcessFoldProps {
@@ -37,10 +28,9 @@ const ProcessFold = memo<ProcessFoldProps>(
const expandedKeys = useMemo(() => (expanded ? [PROCESS_KEY] : []), [expanded]);
const title = (
- <Flexbox horizontal align={'center'} gap={6} style={{ minWidth: 0 }}>
- <Text type={'secondary'}>{t('turnProcess.done')}</Text>
- {durationText && <span className={styles.duration}>{durationText}</span>}
- </Flexbox>
+ <Text style={{ minWidth: 0 }} type={'secondary'}>
+ {durationText ? t('turnProcess.ranFor', { duration: durationText }) : t('turnProcess.done')}
+ </Text>
);
return (
diff --git a/src/helpers/toolEngineering/index.ts b/src/helpers/toolEngineering/index.ts
index 815ee33919a..a7b62cbd0a0 100644
--- a/src/helpers/toolEngineering/index.ts
+++ b/src/helpers/toolEngineering/index.ts
@@ -9,7 +9,13 @@ import { WebBrowsingManifest } from '@lobechat/builtin-tool-web-browsing';
import { alwaysOnToolIds, chatModeAllowedToolIds, defaultToolIds } from '@lobechat/builtin-tools';
import { createEnableChecker, type PluginEnableChecker } from '@lobechat/context-engine';
import { ToolsEngine } from '@lobechat/context-engine';
-import { type ChatCompletionTool, type ToolManifest, type WorkingModel } from '@lobechat/types';
+import {
+ type BuiltinToolManifest,
+ type BuiltinToolResolveContext,
+ type ChatCompletionTool,
+ type ToolManifest,
+ type WorkingModel,
+} from '@lobechat/types';
import type { ConnectorToolPermission } from '@/database/schemas';
import { isToolAvailableInCurrentEnv } from '@/helpers/toolAvailability';
@@ -40,6 +46,13 @@ export interface ToolsEngineConfig {
defaultToolIds?: string[];
/** Custom enable checker for plugins */
enableChecker?: PluginEnableChecker;
+ /**
+ * Runtime context for context-aware builtin manifests. When provided, each
+ * builtin tool with a `resolveManifest` produces its manifest for this context
+ * (trimming APIs or opting out via `null`). Omit for context-free callers
+ * (e.g. UI token estimation) β€” they get the full static manifests.
+ */
+ manifestContext?: BuiltinToolResolveContext;
}
/**
@@ -83,7 +96,7 @@ const dropInvalidManifests = (manifests: (ToolManifest | undefined)[], source: s
* Initialize ToolsEngine with current manifest schemas and configurable options
*/
export const createToolsEngine = (config: ToolsEngineConfig = {}): ToolsEngine => {
- const { enableChecker, additionalManifests = [], defaultToolIds } = config;
+ const { enableChecker, additionalManifests = [], defaultToolIds, manifestContext } = config;
const toolStoreState = getToolStoreState();
@@ -120,12 +133,23 @@ export const createToolsEngine = (config: ToolsEngineConfig = {}): ToolsEngine =
: m;
});
- // Get all builtin tool manifests
- const builtinManifests = toolStoreState.builtinTools.map((tool) => tool.manifest as ToolManifest);
+ // Get all builtin tool manifests. When a manifest context is supplied (agent
+ // runtime path), context-aware tools resolve their manifest for it β€” trimming
+ // APIs (e.g. lobe-agent hides callSubAgent in groups) or opting out via `null`.
+ // Context-free callers fall back to the full static manifest.
+ const builtinManifests = toolStoreState.builtinTools
+ .map((tool) =>
+ manifestContext && tool.resolveManifest
+ ? tool.resolveManifest(manifestContext)
+ : tool.manifest,
+ )
+ .filter((m): m is BuiltinToolManifest => !!m) as ToolManifest[];
// Get Composio tool manifests
const composioTools = composioStoreSelectors.composioAsLobeTools(toolStoreState);
- const composioManifests = composioTools.map((tool) => tool.manifest as ToolManifest).filter(Boolean);
+ const composioManifests = composioTools
+ .map((tool) => tool.manifest as ToolManifest)
+ .filter(Boolean);
// Get LobeHub Skill tool manifests
const lobehubSkillTools = lobehubSkillStoreSelectors.lobehubSkillAsLobeTools(toolStoreState);
@@ -156,6 +180,8 @@ export const createAgentToolsEngine = (
workingModel: WorkingModel,
/** Runtime-resolved plugin IDs (from agentConfigResolver), may include tools beyond the active agent */
pluginIds?: string[],
+ /** Conversation context for context-aware builtin manifests (scope, isSubAgent). */
+ manifestContext?: BuiltinToolResolveContext,
) => {
const searchConfig = getSearchConfig(workingModel.model, workingModel.provider);
const agentState = getAgentStoreState();
@@ -197,6 +223,7 @@ export const createAgentToolsEngine = (
return createToolsEngine({
defaultToolIds: isChatMode ? chatModeAllowedToolIds : defaultToolIds,
+ manifestContext,
enableChecker: createEnableChecker({
allowExplicitActivation: !isChatMode,
platformFilter: ({ pluginId }) => {
diff --git a/src/routes/(main)/community/(detail)/agent/features/Details/Capabilities/PluginItem.tsx b/src/routes/(main)/community/(detail)/agent/features/Details/Capabilities/PluginItem.tsx
index 8bb5ed4ffea..1cb63e5d823 100644
--- a/src/routes/(main)/community/(detail)/agent/features/Details/Capabilities/PluginItem.tsx
+++ b/src/routes/(main)/community/(detail)/agent/features/Details/Capabilities/PluginItem.tsx
@@ -139,18 +139,18 @@ const PluginItem = memo<PluginItemProps>(({ identifier }) => {
if (builtinTool) {
return {
author: 'LobeHub',
- avatar: builtinTool.manifest.meta.avatar || '',
+ avatar: builtinTool.avatar || '',
category: undefined,
createdAt: '',
- description: builtinTool.manifest.meta.description || '',
+ description: builtinTool.description || '',
homepage: 'https://lobehub.com',
identifier: builtinTool.identifier,
manifest: undefined,
related: [],
schemaVersion: 1,
source: 'builtin' as const,
- tags: builtinTool.manifest.meta.tags || ['builtin-tool'],
- title: builtinTool.manifest.meta.title,
+ tags: builtinTool.tags || ['builtin-tool'],
+ title: builtinTool.title || builtinTool.identifier,
};
}
diff --git a/src/routes/(main)/settings/skill/features/SkillList.tsx b/src/routes/(main)/settings/skill/features/SkillList.tsx
index 2ea9c5229b0..2ae0ce48ba5 100644
--- a/src/routes/(main)/settings/skill/features/SkillList.tsx
+++ b/src/routes/(main)/settings/skill/features/SkillList.tsx
@@ -457,11 +457,11 @@ const SkillList = memo<SkillListProps>(
builtinToolItems.map((item) => {
if (item.type !== 'builtin') return null;
const localizedTitle = t(`tools.builtins.${item.builtinTool.identifier}.title`, {
- defaultValue: item.builtinTool.manifest.meta?.title || item.builtinTool.identifier,
+ defaultValue: item.builtinTool.title || item.builtinTool.identifier,
});
return (
<BuiltinSkillItem
- avatar={item.builtinTool.manifest.meta?.avatar}
+ avatar={item.builtinTool.avatar}
identifier={item.builtinTool.identifier}
isSelected={selectedIdentifier === item.builtinTool.identifier}
key={item.builtinTool.identifier}
diff --git a/src/services/chat/mecha/agentConfigResolver.test.ts b/src/services/chat/mecha/agentConfigResolver.test.ts
index c25145431d8..89958850e2c 100644
--- a/src/services/chat/mecha/agentConfigResolver.test.ts
+++ b/src/services/chat/mecha/agentConfigResolver.test.ts
@@ -1069,12 +1069,17 @@ describe('resolveAgentConfig', () => {
});
});
- describe('sub-agent filtering (isSubAgent)', () => {
+ // lobe-agent's sub-agent / group trimming moved into resolveLobeAgentManifest
+ // (manifest resolver, applied at tools-engine build time). resolveAgentConfig no
+ // longer drops lobe-agent from the plugins list based on isSubAgent β€” it stays so
+ // its plan / todo / visual-media APIs remain available; only callSubAgent is hidden
+ // downstream (covered by resolveManifest.test.ts).
+ describe('isSubAgent keeps lobe-agent in plugins (trimming moved to manifest resolver)', () => {
beforeEach(() => {
vi.spyOn(agentSelectors.agentSelectors, 'getAgentSlugById').mockReturnValue(() => undefined);
});
- it('should filter out lobe-agent when isSubAgent is true for regular agent', () => {
+ it('keeps lobe-agent when isSubAgent is true for regular agent', () => {
vi.spyOn(agentSelectors.agentSelectors, 'getAgentConfigById').mockReturnValue(
() =>
({
@@ -1088,8 +1093,7 @@ describe('resolveAgentConfig', () => {
isSubAgent: true,
});
- expect(result.plugins).not.toContain('lobe-agent');
- expect(result.plugins).toEqual(['plugin-a', 'plugin-b']);
+ expect(result.plugins).toEqual(['lobe-agent', 'plugin-a', 'plugin-b']);
});
it('should keep lobe-agent when isSubAgent is false', () => {
@@ -1124,7 +1128,7 @@ describe('resolveAgentConfig', () => {
expect(result.plugins).toContain('lobe-agent');
});
- it('should filter lobe-agent in page scope when isSubAgent is true', () => {
+ it('keeps lobe-agent in page scope when isSubAgent is true (and still injects page-agent)', () => {
vi.spyOn(agentSelectors.agentSelectors, 'getAgentConfigById').mockReturnValue(
() =>
({
@@ -1142,11 +1146,11 @@ describe('resolveAgentConfig', () => {
isSubAgent: true,
});
- expect(result.plugins).not.toContain('lobe-agent');
+ expect(result.plugins).toContain('lobe-agent');
expect(result.plugins).toContain(PageAgentIdentifier);
});
- it('should filter lobe-agent for builtin agent when isSubAgent is true', () => {
+ it('keeps lobe-agent for builtin agent when isSubAgent is true', () => {
vi.spyOn(agentSelectors.agentSelectors, 'getAgentSlugById').mockReturnValue(
() => 'agent-builder',
);
@@ -1160,7 +1164,7 @@ describe('resolveAgentConfig', () => {
isSubAgent: true,
});
- expect(result.plugins).not.toContain('lobe-agent');
+ expect(result.plugins).toContain('lobe-agent');
expect(result.plugins).toContain('runtime-plugin');
});
diff --git a/src/services/chat/mecha/agentConfigResolver.ts b/src/services/chat/mecha/agentConfigResolver.ts
index 36566d57cdf..b07633f49ac 100644
--- a/src/services/chat/mecha/agentConfigResolver.ts
+++ b/src/services/chat/mecha/agentConfigResolver.ts
@@ -157,8 +157,13 @@ export const resolveAgentConfig = (ctx: AgentConfigResolverContext): ResolvedAge
// Helper to apply plugin filters:
// 1. If disableTools is true, return empty array (for broadcast scenarios)
- // 2. If isSubAgent is true, filter out lobe-agent (which owns the sub-agent
- // dispatch APIs) to prevent nested sub-agent creation.
+ // 2. Drop page-agent outside page scope.
+ //
+ // lobe-agent's context trimming (hide `callSubAgent` in group / sub-agent runs)
+ // now lives in its manifest resolver (resolveLobeAgentManifest), applied at
+ // tools-engine build time. That keeps lobe-agent's plan / todo / visual-media
+ // available to sub-agents β€” only the nested dispatch API is removed β€” instead of
+ // dropping the whole tool here.
const applyPluginFilters = (pluginIds: string[]) => {
if (disableTools) {
log('disableTools is true, returning empty plugins');
@@ -171,7 +176,7 @@ export const resolveAgentConfig = (ctx: AgentConfigResolverContext): ResolvedAge
nextPluginIds = nextPluginIds.filter((id) => id !== PageAgentIdentifier);
}
- return isSubAgent ? nextPluginIds.filter((id) => id !== 'lobe-agent') : nextPluginIds;
+ return nextPluginIds;
};
const agentStoreState = getAgentStoreState();
diff --git a/src/store/chat/slices/agentRun/actions/transports/client/streamingExecutor.ts b/src/store/chat/slices/agentRun/actions/transports/client/streamingExecutor.ts
index f15f8ec7df1..0a6e2ee524b 100644
--- a/src/store/chat/slices/agentRun/actions/transports/client/streamingExecutor.ts
+++ b/src/store/chat/slices/agentRun/actions/transports/client/streamingExecutor.ts
@@ -218,6 +218,10 @@ export class StreamingExecutorActionImpl {
const toolsEngine = createAgentToolsEngine(
{ model: agentConfigData.model, provider: agentConfigData.provider! },
effectivePluginIds,
+ // Context-aware builtin manifests: lobe-agent hides callSubAgent in group /
+ // sub-agent runs. Replaces the former dropSubAgentInGroup + applyPluginFilters
+ // isSubAgent hard-coding.
+ { isSubAgent, scope },
);
// When skillActivateMode is 'manual':
// Exclude only discovery tools (activator, skill-store) so runtime-managed defaults
diff --git a/src/store/tool/selectors/tool.ts b/src/store/tool/selectors/tool.ts
index 30814e8d225..47c89c0b6f3 100644
--- a/src/store/tool/selectors/tool.ts
+++ b/src/store/tool/selectors/tool.ts
@@ -134,9 +134,9 @@ const availableToolsForDiscovery = (s: ToolStoreState): AvailableToolForDiscover
.filter((tool) => !builtinSkillIds.has(tool.identifier))
.filter((tool) => isToolAvailableInCurrentEnv(tool.identifier))
.map((tool) => ({
- description: tool.manifest.meta?.description || '',
+ description: tool.description || '',
identifier: tool.identifier,
- name: tool.manifest.meta?.title || tool.identifier,
+ name: tool.title || tool.identifier,
}));
// 2. User-installed plugins β€” directly from s.installedPlugins
diff --git a/src/store/tool/slices/builtin/executors/lobe-activator.ts b/src/store/tool/slices/builtin/executors/lobe-activator.ts
index dcf60c9f0dc..8f9dbb04d65 100644
--- a/src/store/tool/slices/builtin/executors/lobe-activator.ts
+++ b/src/store/tool/slices/builtin/executors/lobe-activator.ts
@@ -58,9 +58,9 @@ const service: ActivatorRuntimeService = {
description: a.description,
name: a.name,
})),
- avatar: builtin.manifest.meta?.avatar,
+ avatar: builtin.avatar,
identifier: builtin.identifier,
- name: builtin.manifest.meta?.title ?? builtin.identifier,
+ name: builtin.title ?? builtin.identifier,
systemRole: builtin.manifest.systemRole,
});
continue;