🤯 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: slove the execAgent task run error & parse crash problem (#12318)
LiJian7bad8762593b
diff --git a/packages/builtin-tool-group-management/src/client/Inspector/ExecuteAgentTasks/index.tsx b/packages/builtin-tool-group-management/src/client/Inspector/ExecuteAgentTasks/index.tsxindex a1d9f279639..7a2cd301aec 100644--- a/packages/builtin-tool-group-management/src/client/Inspector/ExecuteAgentTasks/index.tsx+++ b/packages/builtin-tool-group-management/src/client/Inspector/ExecuteAgentTasks/index.tsx@@ -2,6 +2,7 @@import { DEFAULT_AVATAR } from '@lobechat/const';import type { AgentGroupMember, BuiltinInspectorProps } from '@lobechat/types';+import { safeParsePartialJSON } from '@lobechat/utils';import { Avatar, Flexbox } from '@lobehub/ui';import { createStaticStyles, cx, useTheme } from 'antd-style';import { memo, useMemo } from 'react';@@ -11,7 +12,7 @@ import { useAgentGroupStore } from '@/store/agentGroup';import { agentGroupSelectors } from '@/store/agentGroup/selectors';import { shinyTextStyles } from '@/styles';-import type { ExecuteTasksParams } from '../../../types';+import type { ExecuteTasksParams, TaskItem } from '../../../types';const styles = createStaticStyles(({ css, cssVar }) => ({root: css`@@ -31,8 +32,19 @@ export const ExecuteAgentTasksInspector = memo<BuiltinInspectorProps<ExecuteTask({ args, partialArgs, isArgumentsStreaming }) => {const { t } = useTranslation('plugin');- const tasks = args?.tasks || partialArgs?.tasks || [];- const agentIds = useMemo(() => tasks.map((task) => task.agentId).filter(Boolean), [tasks]);+ // Handle case where LLM returns tasks as stringified JSON instead of array+ const tasks = useMemo(() => {+ const rawTasks = args?.tasks || partialArgs?.tasks;+ if (!rawTasks) return [];+ if (typeof rawTasks === 'string') {+ return safeParsePartialJSON<TaskItem[]>(rawTasks) || [];+ }+ return rawTasks;+ }, [args?.tasks, partialArgs?.tasks]);++ const agentIds = useMemo(() => {+ return tasks?.map((task) => task?.agentId)?.filter(Boolean);+ }, [tasks]);// Get active group ID and agents from storeconst activeGroupId = useAgentGroupStore(agentGroupSelectors.activeGroupId);diff --git a/packages/builtin-tool-group-management/src/systemRole.ts b/packages/builtin-tool-group-management/src/systemRole.tsindex 97b0344ad93..b1ef884c5a3 100644--- a/packages/builtin-tool-group-management/src/systemRole.ts+++ b/packages/builtin-tool-group-management/src/systemRole.ts@@ -324,6 +324,19 @@ Action:- executeAgentTask: \`agentId\`, \`title\` (brief UI label), \`task\` (detailed instructions with expected deliverables), \`timeout\` (optional, default 30min)- executeAgentTasks: \`tasks\` (array of {agentId, title, task, timeout?}), \`skipCallSupervisor\` (optional)+**⚠️ CRITICAL: JSON Array Format for executeAgentTasks**+The \`tasks\` parameter MUST be a proper JSON array, NOT a stringified JSON string.++✅ Correct format:+\`\`\`json+{"tasks": [{"agentId": "xxx", "title": "...", "instruction": "..."}]}+\`\`\`++❌ Wrong format (DO NOT stringify the array):+\`\`\`json+{"tasks": "[{\\"agentId\\": \\"xxx\\", ...}]"}+\`\`\`+**Flow Control:**- vote: \`question\`, \`options\` (array of {id, label, description}), \`voterAgentIds\` (optional), \`requireReasoning\` (default true)</tool_usage_guidelines>