🤯 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(skills): restore on-demand builtins for legacy agents (#23475)
AmAzing-556bdefffa8b
diff --git a/apps/server/src/services/agent/index.ts b/apps/server/src/services/agent/index.tsindex a00031d01bb..c20372de8a4 100644--- a/apps/server/src/services/agent/index.ts+++ b/apps/server/src/services/agent/index.ts@@ -54,6 +54,7 @@ const touchesShareModel = (value: PartialDeep<AgentItem>): boolean =>* Used when returning agent config from database (id is always present).*/export type AgentConfigWithId = LobeAgentConfig &+ Partial<Pick<AgentItem, 'createdAt'>> &Pick<AgentItem, 'id' | 'slug' | 'userId' | 'visibility' | 'workspaceId'> & {/*** Raw callSubAgent chatConfig override, stamped by execAgent alongside thediff --git a/apps/server/src/services/aiAgent/__tests__/execAgent.pinnedSkillContent.test.ts b/apps/server/src/services/aiAgent/__tests__/execAgent.pinnedSkillContent.test.tsindex 8a0b3f31b1e..42233bd7ccf 100644--- a/apps/server/src/services/aiAgent/__tests__/execAgent.pinnedSkillContent.test.ts+++ b/apps/server/src/services/aiAgent/__tests__/execAgent.pinnedSkillContent.test.ts@@ -371,6 +371,40 @@ describe('AiAgentService.execAgent - pinned skill content injection', () => {},);+ it.each([+ { createdAt: '2026-11-17T08:00:00Z', offered: true },+ { createdAt: '2026-11-18T15:53:51Z', offered: false },+ { createdAt: '2026-11-17T08:00:00Z', disabled: true, offered: false },+ { createdAt: '2026-11-17T08:00:00Z', manual: true, offered: false },+ { createdAt: '2026-11-17T08:00:00Z', exclusive: true, offered: false },+ { createdAt: '2026-11-17T08:00:00Z', uninstalled: true, offered: false },+ ])('resolves implicit builtin skills for the original profile: %o', async (scenario) => {+ const settings = {+ tool: { uninstalledBuiltinTools: scenario.uninstalled ? ['lobe-artifacts'] : [] },+ };+ service = new AiAgentService(+ {+ query: { userSettings: { findFirst: vi.fn().mockResolvedValue(settings) } },+ } as any,+ 'test-user-id',+ );+ mockGetAgentConfig.mockResolvedValue({+ ...createAgentConfig(+ scenario.disabled ? [{ identifier: 'lobe-artifacts', mode: 'disabled' }] : ['docs-mcp'],+ ),+ chatConfig: { skillActivateMode: scenario.manual ? 'manual' : 'auto' },+ createdAt: new Date(scenario.createdAt),+ });+ await service.execAgent({+ agentId: 'agent-1',+ exclusivePluginIds: scenario.exclusive ? [] : undefined,+ prompt: 'Make a game',+ });+ expect(!!skillById('lobe-artifacts')).toBe(scenario.offered);+ expect(skillById('lobe-artifacts')?.content).toBeUndefined();+ expect(skillById('db-skill-auto')).toBeUndefined();+ });+it('does not attach content when no skill is pinned', async () => {mockGetAgentConfig.mockResolvedValue(createAgentConfig([]));diff --git a/apps/server/src/services/aiAgent/pipeline/execTurn.ts b/apps/server/src/services/aiAgent/pipeline/execTurn.tsindex c275b4c65dc..45ca96aba7d 100644--- a/apps/server/src/services/aiAgent/pipeline/execTurn.ts+++ b/apps/server/src/services/aiAgent/pipeline/execTurn.ts@@ -1,6 +1,7 @@import type { SandboxStorageClaim } from '@lobechat/builtin-tool-cloud-sandbox';import { isOnDemandBuiltinTool } from '@lobechat/builtin-tools';import type { LobeChatDatabase } from '@lobechat/database';+import { getImplicitBuiltinSkillIds } from '@lobechat/mecha/builtinSkillGate';import type { AgentSenderMetadata, ExecAgentResult, UserInterventionConfig } from '@lobechat/types';import {agentShareFileAccessScope,@@ -631,7 +632,15 @@ export const execAgentTurn = async (resolveRunSettings({ agentConfig, runFacts, shareGate, workspaceId: deps.workspaceId }),);if (!shareGate && !exclusivePluginIds && resolveToolMode(agentConfig.chatConfig) === 'agent') {- disabledPluginIds.push(...uninstalledBuiltinIds.filter(isOnDemandBuiltinTool));+ const implicitSkills = getImplicitBuiltinSkillIds(+ agentConfig.createdAt,+ agentConfig.chatConfig,+ );+ disabledPluginIds.push(+ ...uninstalledBuiltinIds.filter(+ (id) => isOnDemandBuiltinTool(id) || implicitSkills.includes(id),+ ),+ );}log('execAgent: globalMemoryEnabled=%s, timezone=%s',diff --git a/apps/server/src/services/aiAgent/pipeline/operationPrep.ts b/apps/server/src/services/aiAgent/pipeline/operationPrep.tsindex 339c4b4d847..a7344710727 100644--- a/apps/server/src/services/aiAgent/pipeline/operationPrep.ts+++ b/apps/server/src/services/aiAgent/pipeline/operationPrep.ts@@ -849,6 +849,7 @@ export const prepareOperation = async (agentConfig,agentPlugins,autoSkillIds: ctx.autoSkillIds,+ implicitBuiltinSkillIds: discovery.implicitBuiltinSkillIds,disabledPluginIds,executionPlan,prompt,diff --git a/apps/server/src/services/aiAgent/pipeline/operationSkillSet.ts b/apps/server/src/services/aiAgent/pipeline/operationSkillSet.tsindex 74e4eb9600f..17f38773e80 100644--- a/apps/server/src/services/aiAgent/pipeline/operationSkillSet.ts+++ b/apps/server/src/services/aiAgent/pipeline/operationSkillSet.ts@@ -40,6 +40,7 @@ export interface OperationSkillSetInput {/** Tri-state disabled plugin identifiers — excluded from the skill pool. */disabledPluginIds: string[];executionPlan: ToolDiscoveryResult['executionPlan'];+ implicitBuiltinSkillIds?: readonly string[];prompt: ExecRunContext['prompt'];resolvedAgentId: ExecRunContext['resolvedAgentId'];/**@@ -277,6 +278,7 @@ export const buildOperationSkillSet = async (// skill grant is the creator opting the visitor in by name, so a// granted skill stays reachable without also being turned on.autoSkillIds: [...autoSkillIds, ...(shareAllowedSkillIds ?? [])],+ implicitBuiltinSkillIds: input.implicitBuiltinSkillIds,canExecuteOnDevice: executionPlan ? isDeviceCapablePlan(executionPlan) : false,disabledIds: disabledPluginIds,// Selected skills join the enabled set so the resolver auto-activatesdiff --git a/apps/server/src/services/aiAgent/pipeline/runSettings.ts b/apps/server/src/services/aiAgent/pipeline/runSettings.tsindex 28615d89c6d..2d028c05b1a 100644--- a/apps/server/src/services/aiAgent/pipeline/runSettings.ts+++ b/apps/server/src/services/aiAgent/pipeline/runSettings.ts@@ -3,6 +3,7 @@ import {resolveUninstalledBuiltinTools,type UninstalledBuiltinToolsScope,} from '@lobechat/builtin-tools';+import { legacyBuiltinSkillIds } from '@lobechat/mecha/builtinSkillGate';import debug from 'debug';import type { AgentConfigWithId } from '@/server/services/agent';@@ -38,7 +39,7 @@ export const resolveRunSettings = async ({let globalMemoryEnabled = agentMemoryEnabled ?? false;let enableExpertise = false;// A failed settings read cannot confirm any optional builtin is installed.- let uninstalledBuiltinIds = onDemandBuiltinToolIds;+ let uninstalledBuiltinIds = [...onDemandBuiltinToolIds, ...legacyBuiltinSkillIds];let userTimezone: string | undefined;try {const settings = await runFacts.userSettings();diff --git a/apps/server/src/services/aiAgent/pipeline/toolDiscovery/index.ts b/apps/server/src/services/aiAgent/pipeline/toolDiscovery/index.tsindex cbbd06e1d17..a48ab693227 100644--- a/apps/server/src/services/aiAgent/pipeline/toolDiscovery/index.ts+++ b/apps/server/src/services/aiAgent/pipeline/toolDiscovery/index.ts@@ -21,6 +21,7 @@ import type {import {applyConnectorActivation,dropInvalidManifests,+ getImplicitBuiltinSkillIds,hasConnectorActivator,initialToolSelection,resolveClientExecutors,@@ -856,6 +857,10 @@ export const discoverTools = async (executionPlan,hasAgentDocuments,credentialFactsPromise,+ implicitBuiltinSkillIds:+ !disableTools && !exclusivePluginIds && !isGoalTurn && !evalConnectorSnapshots && !shareGate+ ? getImplicitBuiltinSkillIds(agentConfig.createdAt, agentConfig.chatConfig)+ : [],hasEnabledKnowledgeBases,lobehubSkillManifests,modelFacts,diff --git a/apps/server/src/services/aiAgent/pipeline/toolDiscovery/types.ts b/apps/server/src/services/aiAgent/pipeline/toolDiscovery/types.tsindex 7a88f5aa4a1..31922d7445b 100644--- a/apps/server/src/services/aiAgent/pipeline/toolDiscovery/types.ts+++ b/apps/server/src/services/aiAgent/pipeline/toolDiscovery/types.ts@@ -105,6 +105,7 @@ export interface ToolDiscoveryResult {executionPlan?: ExecutionPlan;hasAgentDocuments: boolean;hasEnabledKnowledgeBases: boolean;+ implicitBuiltinSkillIds?: readonly string[];lobehubSkillManifests: LobeToolManifest[];/** Model facts read once for the whole operation; see {@link FrozenModelFacts}. */modelFacts: FrozenModelFacts;diff --git a/packages/mecha/src/toolSet/builtinSkillGate.ts b/packages/mecha/src/toolSet/builtinSkillGate.tsindex 7f507428655..e195e1a2692 100644--- a/packages/mecha/src/toolSet/builtinSkillGate.ts+++ b/packages/mecha/src/toolSet/builtinSkillGate.ts@@ -1,4 +1,36 @@-import { AgentBrowserIdentifier } from '@lobechat/builtin-skills/manifests';+import {+ AgentBrowserIdentifier,+ ArtifactsIdentifier,+ LobeHubIdentifier,+} from '@lobechat/builtin-skills/manifests';+import { type LobeAgentChatConfig, resolveToolMode } from '@lobechat/types';++// #23412 changed an absent builtin skill preference from Auto to off. Older+// clients did not write an entry even when a user explicitly chose Auto.+const SKILL_OPT_IN_SINCE = Date.parse('2026-11-18T15:53:51Z');+export const legacyBuiltinSkillIds: readonly string[] = [+ AgentBrowserIdentifier,+ ArtifactsIdentifier,+ LobeHubIdentifier,+];++const noImplicitSkills: readonly string[] = [];++export type SkillDiscoveryChatConfig = Pick<+ LobeAgentChatConfig,+ 'enableAgentMode' | 'skillActivateMode' | 'toolMode'+>;++export const getImplicitBuiltinSkillIds = (+ createdAt: Date | string | undefined,+ chatConfig: SkillDiscoveryChatConfig | null | undefined,+): readonly string[] =>+ createdAt &&+ new Date(createdAt).getTime() < SKILL_OPT_IN_SINCE &&+ chatConfig?.skillActivateMode !== 'manual' &&+ resolveToolMode(chatConfig) === 'agent'+ ? legacyBuiltinSkillIds+ : noImplicitSkills;/** Builtin skills that only work where the run can execute commands on a device. */const DEVICE_ONLY_BUILTIN_SKILLS = new Set<string>([AgentBrowserIdentifier]);diff --git a/packages/mecha/src/toolSet/skillPool.ts b/packages/mecha/src/toolSet/skillPool.tsindex ebd56187b98..f9fe828dd3a 100644--- a/packages/mecha/src/toolSet/skillPool.ts+++ b/packages/mecha/src/toolSet/skillPool.ts@@ -35,6 +35,8 @@ export interface AssembleSkillPoolOptions {* skill matching one is auto-activated and its content injected directly.*/enabledPluginIds?: readonly string[];+ /** Builtins implicitly offered by a legacy Auto profile. */+ implicitBuiltinSkillIds?: readonly string[];/*** Identifiers a share configuration allows. `undefined` means the run is not* shared; an empty list collapses the pool to nothing.@@ -91,7 +93,10 @@ export const assembleSkillPool = (...(sources.project ?? []),...offered(sources.db),...selectable(sources.agentSkills),- ...offered(sources.builtin),+ ...(sources.builtin ?? []).filter(+ (skill) =>+ on.has(skill.identifier) || options.implicitBuiltinSkillIds?.includes(skill.identifier),+ ),];const disabled = new Set(options.disabledIds ?? []);const shareAllowed = options.shareAllowedIds ? new Set(options.shareAllowedIds) : undefined;diff --git a/src/features/ProfileEditor/AgentTool.tsx b/src/features/ProfileEditor/AgentTool.tsxindex 6285486eb87..900acbfe37e 100644--- a/src/features/ProfileEditor/AgentTool.tsx+++ b/src/features/ProfileEditor/AgentTool.tsx@@ -2,6 +2,7 @@import { isOnDemandBuiltinTool, onDemandBuiltinToolIds } from '@lobechat/builtin-tools';import { getConnectorCatalog } from '@lobechat/const';+import { getImplicitBuiltinSkillIds } from '@lobechat/mecha/builtinSkillGate';import {getDisabledPluginIds,getOptedInPluginIds,@@ -166,15 +167,30 @@ const AgentTool = memo<AgentToolProps>((s) => getConnectedConnectorIds(s, effectiveAgentId),isEqual,);+ const installedBuiltinSkills = useToolStore(+ builtinToolSelectors.installedBuiltinSkills,+ isEqual,+ );+ const createdAt = useAgentStore((s) => s.agentMap[effectiveAgentId]?.createdAt);+ const implicitSkills = getImplicitBuiltinSkillIds(createdAt, config?.chatConfig);const implicitToolIds = useMemo(() =>resolveToolMode(config?.chatConfig) === 'agent'? [...profileBuiltinList.map((tool) => tool.identifier).filter(isOnDemandBuiltinTool),...connectedIds,+ ...installedBuiltinSkills+ .map((skill) => skill.identifier)+ .filter((id) => implicitSkills.includes(id)),]: [],- [config?.chatConfig, profileBuiltinList, connectedIds],+ [+ config?.chatConfig,+ profileBuiltinList,+ connectedIds,+ installedBuiltinSkills,+ implicitSkills,+ ],);const enabledIds = useMemo(() => {const ids = new Set([...implicitToolIds, ...getOptedInPluginIds(config?.plugins)]);@@ -201,10 +217,6 @@ const AgentTool = memo<AgentToolProps>(const isLobehubSkillEnabled = useServerConfigStore(serverConfigSelectors.enableLobehubSkill);// Agent Skills-related state- const installedBuiltinSkills = useToolStore(- builtinToolSelectors.installedBuiltinSkills,- isEqual,- );const marketAgentSkills = useToolStore(agentSkillsSelectors.getMarketAgentSkills, isEqual);const userAgentSkills = useToolStore(agentSkillsSelectors.getUserAgentSkills, isEqual);@@ -290,7 +302,9 @@ const AgentTool = memo<AgentToolProps>(// dropped from the array.await updateAgentConfigById(effectiveAgentId, {plugins:- isOnDemandBuiltinTool(pluginId) || connectorIds.has(pluginId)+ isOnDemandBuiltinTool(pluginId) ||+ connectorIds.has(pluginId) ||+ implicitSkills.includes(pluginId)? upsertConnectorEnabled(config?.plugins, pluginId, shouldEnable): shouldEnable && allSkillIdentifiers.has(pluginId)? upsertConnectorEnabled(config?.plugins, pluginId, true)@@ -302,6 +316,7 @@ const AgentTool = memo<AgentToolProps>(effectiveAgentId,enabledIds,connectorIds,+ implicitSkills,allSkillIdentifiers,config?.plugins,updateAgentConfigById,diff --git a/src/services/chat/mecha/contextEngineering.ts b/src/services/chat/mecha/contextEngineering.tsindex 6ea130a2a42..9219468c10f 100644--- a/src/services/chat/mecha/contextEngineering.ts+++ b/src/services/chat/mecha/contextEngineering.ts@@ -36,6 +36,8 @@ import { getChatGroupStoreState } from '@/store/agentGroup';import { agentGroupSelectors } from '@/store/agentGroup/selectors';import { getChatStoreState } from '@/store/chat';import { getServerConfigStoreState, serverConfigSelectors } from '@/store/serverConfig';+import { getToolStoreState } from '@/store/tool';+import { installedImplicitBuiltinSkillIds } from '@/store/tool/slices/builtin/projection';import { useUserStore } from '@/store/user';import { userGeneralSettingsSelectors } from '@/store/user/selectors';@@ -316,11 +318,18 @@ export const contextEngineering = async ({await resolveClientSkills(plugins,disabledPluginIds,- agentChatConfigSelectors.skillActivateMode(agentStoreState),+ respondingChatConfig.skillActivateMode,// Reading another topic (`<refer_topic>` or a raw `tpc_` id) goes through `lh topic view`,// which the lobehub skill teaches.mentionsTopic(messages) ? [LobeHubIdentifier] : undefined,autoSkillIds,+ !shareVisitor && enableAgentMode !== false+ ? installedImplicitBuiltinSkillIds(+ getToolStoreState(),+ agentItem?.createdAt,+ respondingChatConfig,+ )+ : [],)).skills;}diff --git a/src/services/chat/mecha/skillEngineering.ts b/src/services/chat/mecha/skillEngineering.tsindex 6af1a2ac8df..44a6470936b 100644--- a/src/services/chat/mecha/skillEngineering.ts+++ b/src/services/chat/mecha/skillEngineering.ts@@ -21,6 +21,7 @@ export const resolveClientSkills = async (* agent: one that is neither here nor pinned is not listed at all.*/autoSkillIds?: string[],+ implicitBuiltinSkillIds?: readonly string[],): Promise<OperationSkillSet> => {// The list is only fetched by mounted views (tool popover, side panel), so a// send right after a page load would otherwise see no DB skills. A failed@@ -51,6 +52,7 @@ export const resolveClientSkills = async ({autoSkillIds,disabledIds,+ implicitBuiltinSkillIds,// The desktop app is itself the execution device.canExecuteOnDevice: isDesktop,enabledPluginIds: pluginIds,diff --git a/src/store/tool/slices/builtin/executors/clientSkillCatalog.ts b/src/store/tool/slices/builtin/executors/clientSkillCatalog.tsindex 4fb4a04828c..07d8202b5d2 100644--- a/src/store/tool/slices/builtin/executors/clientSkillCatalog.ts+++ b/src/store/tool/slices/builtin/executors/clientSkillCatalog.ts@@ -12,18 +12,24 @@ import {import { filterBuiltinSkills } from '@/helpers/skillFilters';import { agentSkillService } from '@/services/skill';import { getAgentStoreState } from '@/store/agent';-import { agentSelectors } from '@/store/agent/selectors';import { getChatStoreState } from '@/store/chat';import { parseSelectedSkillsFromEditorData } from '@/store/chat/slices/agentRun/actions/entries/commandBus/parseCommands';import { messageMapKey } from '@/store/chat/utils/messageMapKey';+import { getToolStoreState } from '@/store/tool';++import { installedImplicitBuiltinSkillIds } from '../projection';/** Bind both name lookup and the fallback catalog to the calling agent, not the active tab. */export const clientSkillCatalog = (ctx: BuiltinToolContext) => {const { agentId, subAgentId } = ctx;const profileAgentId = subAgentId ?? agentId;- const plugins = profileAgentId- ? agentSelectors.getAgentConfigById(profileAgentId)(getAgentStoreState())?.plugins- : undefined;+ const profile = profileAgentId ? getAgentStoreState().agentMap[profileAgentId] : undefined;+ const plugins = profile?.plugins;+ const implicitBuiltins = installedImplicitBuiltinSkillIds(+ getToolStoreState(),+ profile?.createdAt,+ profile?.chatConfig,+ );const messages = agentId? (getChatStoreState().dbMessagesMap[messageMapKey({@@ -68,7 +74,11 @@ export const clientSkillCatalog = (ctx: BuiltinToolContext) => {};return {- builtinSkills: filterBuiltinSkills(builtinSkills).filter((skill) => offered(skill.identifier)),+ builtinSkills: filterBuiltinSkills(builtinSkills).filter(+ (skill) =>+ offered(skill.identifier) ||+ (!disabled.has(skill.identifier) && implicitBuiltins.includes(skill.identifier)),+ ),lookup,};};diff --git a/src/store/tool/slices/builtin/projection.ts b/src/store/tool/slices/builtin/projection.tsindex eae444cd7da..534c06dc662 100644--- a/src/store/tool/slices/builtin/projection.ts+++ b/src/store/tool/slices/builtin/projection.ts@@ -1,4 +1,8 @@import { onDemandBuiltinToolIds } from '@lobechat/builtin-tools';+import {+ getImplicitBuiltinSkillIds,+ type SkillDiscoveryChatConfig,+} from '@lobechat/mecha/builtinSkillGate';import { defineReplica } from '@/libs/replica';@@ -56,3 +60,15 @@ export const confirmedUninstalledBuiltinTools = (state: BuiltinToolState) => {export const runtimeUninstalledBuiltinTools = (state: BuiltinToolState) =>confirmedUninstalledBuiltinTools(state) ?? onDemandBuiltinToolIds;++/** A client run confirms the scoped uninstall list before preparing its tools. */+export const installedImplicitBuiltinSkillIds = (+ state: BuiltinToolState,+ createdAt: Date | string | undefined,+ chatConfig: SkillDiscoveryChatConfig | null | undefined,+) => {+ const implicit = getImplicitBuiltinSkillIds(createdAt, chatConfig);+ if (!implicit.length) return implicit;+ const uninstalled = confirmedUninstalledBuiltinTools(state);+ return uninstalled ? implicit.filter((id) => !uninstalled.includes(id)) : [];+};diff --git a/src/store/tool/slices/builtin/replica.test.ts b/src/store/tool/slices/builtin/replica.test.tsindex 6629aa0cfbd..9edc2f2df6e 100644--- a/src/store/tool/slices/builtin/replica.test.ts+++ b/src/store/tool/slices/builtin/replica.test.ts@@ -21,7 +21,11 @@ import { userService } from '@/services/user';import { useToolStore } from '../../store';import { initialBuiltinToolState } from './initialState';-import { UNINSTALLED_BUILTIN_TOOLS_KEY, uninstalledBuiltinToolsResource } from './projection';+import {+ installedImplicitBuiltinSkillIds,+ UNINSTALLED_BUILTIN_TOOLS_KEY,+ uninstalledBuiltinToolsResource,+} from './projection';vi.mock('@/services/user', () => ({userService: {@@ -94,6 +98,22 @@ describe('uninstalled builtin tools replica', () => {expect(userService.getUserState).toHaveBeenCalledTimes(1);});+ it('only offers installed legacy skills after confirming the current scope', async () => {+ const skills = (createdAt: string) =>+ installedImplicitBuiltinSkillIds(useToolStore.getState(), createdAt, undefined);+ const oldAgent = '2026-11-01T00:00:00Z';+ expect(skills(oldAgent)).toEqual([]);+ vi.mocked(userService.getUserState).mockResolvedValue(+ userState({ uninstalledBuiltinTools: ['lobe-agent-browser'] }),+ );+ await useToolStore.getState().getUninstalledBuiltinToolsForRun();+ expect(skills(oldAgent)).toContain('lobe-artifacts');+ expect(skills(oldAgent)).not.toContain('lobe-agent-browser');+ expect(skills('2026-11-18T15:53:51Z')).toEqual([]);+ useScope(`other-${randomUUID()}:personal`);+ expect(skills(oldAgent)).toEqual([]);+ });+it('withholds on-demand tools after a failed read and retries on the next send', async () => {vi.mocked(userService.getUserState).mockRejectedValueOnce(new Error('settings unavailable'))