π€― 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: fallback to skill activation when activateTools cannot find identifier (#14010)
LiJianca47d972a49a
diff --git a/packages/builtin-tool-activator/src/ExecutionRuntime/index.ts b/packages/builtin-tool-activator/src/ExecutionRuntime/index.tsindex 7b1d7e8ec51..a05a7f9dfaf 100644--- a/packages/builtin-tool-activator/src/ExecutionRuntime/index.ts+++ b/packages/builtin-tool-activator/src/ExecutionRuntime/index.ts@@ -66,7 +66,28 @@ export class ActivatorExecutionRuntime {const manifests = await this.service.getToolManifests(toActivate);const foundIdentifiers = new Set(manifests.map((m) => m.identifier));- const notFound = toActivate.filter((id) => !foundIdentifiers.has(id));+ const notFoundAsTools = toActivate.filter((id) => !foundIdentifiers.has(id));++ // Fallback: try activating not-found identifiers as skills+ const activatedSkillResults: BuiltinServerRuntimeOutput[] = [];+ const notFound: string[] = [];++ if (notFoundAsTools.length > 0 && this.service.activateSkill) {+ for (const id of notFoundAsTools) {+ try {+ const skillResult = await this.service.activateSkill({ name: id });+ if (skillResult.success) {+ activatedSkillResults.push(skillResult);+ } else {+ notFound.push(id);+ }+ } catch {+ notFound.push(id);+ }+ }+ } else {+ notFound.push(...notFoundAsTools);+ }const activatedTools: ActivatedToolInfo[] = manifests.map((m) => ({apiCount: m.apiDescriptions.length,@@ -99,6 +120,12 @@ export class ActivatorExecutionRuntime {}}+ if (activatedSkillResults.length > 0) {+ for (const skillResult of activatedSkillResults) {+ parts.push(skillResult.content);+ }+ }+if (alreadyActiveList.length > 0) {parts.push(`\nAlready active: ${alreadyActiveList.join(', ')}`);}@@ -110,6 +137,7 @@ export class ActivatorExecutionRuntime {return {content: parts.join('\n'),state: {+ activatedSkills: activatedSkillResults.map((r) => r.state),activatedTools,alreadyActive: alreadyActiveList,notFound,diff --git a/src/store/chat/slices/message/selectors/dbMessage.ts b/src/store/chat/slices/message/selectors/dbMessage.tsindex af573905b6d..9e47ac865e3 100644--- a/src/store/chat/slices/message/selectors/dbMessage.ts+++ b/src/store/chat/slices/message/selectors/dbMessage.ts@@ -208,14 +208,17 @@ export const selectActivatedSkillsFromMessages = (for (const msg of messages) {if (- msg.role === 'tool' &&- (msg.plugin?.identifier === SkillsIdentifier ||+ msg.role !== 'tool' ||+ !(+ msg.plugin?.identifier === SkillsIdentifier ||msg.plugin?.identifier === LobeActivatorIdentifier ||- msg.plugin?.identifier === 'lobe-tools') &&- msg.plugin?.apiName === 'activateSkill' &&- msg.pluginState?.id &&- msg.pluginState?.name- ) {+ msg.plugin?.identifier === 'lobe-tools'+ )+ )+ continue;++ // Direct activateSkill calls β state has top-level id/name+ if (msg.plugin?.apiName === 'activateSkill' && msg.pluginState?.id && msg.pluginState?.name) {const id = msg.pluginState.id as string;skillsMap.set(id, {description: msg.pluginState.description as string | undefined,@@ -223,6 +226,26 @@ export const selectActivatedSkillsFromMessages = (name: msg.pluginState.name as string,});}++ // activateTools fallback β skills nested in pluginState.activatedSkills[]+ if (+ msg.plugin?.apiName === 'activateTools' &&+ Array.isArray(msg.pluginState?.activatedSkills)+ ) {+ for (const skill of msg.pluginState.activatedSkills as Array<{+ description?: string;+ id?: string;+ name?: string;+ }>) {+ if (skill.id && skill.name) {+ skillsMap.set(skill.id, {+ description: skill.description,+ id: skill.id,+ name: skill.name,+ });+ }+ }+ }}return skillsMap.size > 0 ? [...skillsMap.values()] : undefined;