π€― 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(group): surface per-member start failure reasons in group-management tool errors (#20533)
Arvin Xu03479578e759
diff --git a/apps/server/src/modules/AgentRuntime/executorHelpers.ts b/apps/server/src/modules/AgentRuntime/executorHelpers.tsindex 3101fcaa174..6b20c10c3b8 100644--- a/apps/server/src/modules/AgentRuntime/executorHelpers.ts+++ b/apps/server/src/modules/AgentRuntime/executorHelpers.ts@@ -494,6 +494,7 @@ export const buildServerAgentMemberRunner = (// 3. Fork members.let startedCount = 0;+ const startErrors: string[] = [];await Promise.all(resolvedMembers.map(async (member, i) => {const anchorMessageId = anchorIds[i];@@ -520,7 +521,9 @@ export const buildServerAgentMemberRunner = (startedCount += 1;return;}+ if (result?.error) startErrors.push(result.error);} catch (error) {+ startErrors.push(String(error));log('buildServerAgentMemberRunner: member %s failed to start: %O',member.agentId,@@ -558,7 +561,7 @@ export const buildServerAgentMemberRunner = (log('buildServerAgentMemberRunner: cleanup failed for %s: %O', id, error);}}- return { started: false, startedCount: 0 };+ return { errors: startErrors, started: false, startedCount: 0 };}return { started: true, startedCount };diff --git a/apps/server/src/services/toolExecution/serverRuntimes/__tests__/groupManagement.test.ts b/apps/server/src/services/toolExecution/serverRuntimes/__tests__/groupManagement.test.tsindex c1d3928d480..063e72202e5 100644--- a/apps/server/src/services/toolExecution/serverRuntimes/__tests__/groupManagement.test.ts+++ b/apps/server/src/services/toolExecution/serverRuntimes/__tests__/groupManagement.test.ts@@ -62,6 +62,26 @@ describe('groupManagementRuntime', () => {expect(result.success).toBe(false);expect(result.error?.code).toBe('AGENT_MEMBER_START_FAILED');});++ it('surfaces per-member start failure reasons when the runner reports them', async () => {+ run.mockResolvedValue({+ errors: ['The model provider returned an empty completion.'],+ started: false,+ startedCount: 0,+ });+ const result = await runtime().speak({ agentId: 'agent-a' }, makeCtx());+ expect(result.success).toBe(false);+ expect(result.error?.code).toBe('AGENT_MEMBER_START_FAILED');+ expect(result.content).toContain('The model provider returned an empty completion.');+ });++ it('keeps the opaque fallback message when the runner reports no reasons', async () => {+ run.mockResolvedValue({ started: false, startedCount: 0 });+ const result = await runtime().delegate({ agentId: 'agent-a', reason: 'take over' }, makeCtx());+ expect(result.success).toBe(false);+ expect(result.error?.code).toBe('AGENT_MEMBER_START_FAILED');+ expect(result.content).toBe('Agent member(s) failed to start.');+ });});describe('broadcast', () => {diff --git a/apps/server/src/services/toolExecution/serverRuntimes/groupManagement.ts b/apps/server/src/services/toolExecution/serverRuntimes/groupManagement.tsindex 7cf8dfaf430..87aac6285d1 100644--- a/apps/server/src/services/toolExecution/serverRuntimes/groupManagement.ts+++ b/apps/server/src/services/toolExecution/serverRuntimes/groupManagement.ts@@ -44,7 +44,19 @@ const AGENT_MEMBER_UNAVAILABLE = buildError('AGENT_MEMBER_UNAVAILABLE',);-const START_FAILED = buildError('Agent member(s) failed to start.', 'AGENT_MEMBER_START_FAILED');+/**+ * Inline start-failure error. When the runner reports per-member reasons+ * (e.g. "The model provider returned an empty completion."), surface them so+ * the supervisor can diagnose and adapt instead of retrying blind β mirrors+ * `ServerSubAgentRunResult.error` for callSubAgent (issue #16257).+ */+const startFailed = (errors?: string[]): BuiltinServerRuntimeOutput =>+ errors && errors.length > 0+ ? buildError(+ `Agent member(s) failed to start.\n${errors.map((e) => `- ${e}`).join('\n')}`,+ 'AGENT_MEMBER_START_FAILED',+ )+ : buildError('Agent member(s) failed to start.', 'AGENT_MEMBER_START_FAILED');class GroupManagementExecutionRuntime {// ==================== Communication Coordination ====================@@ -57,12 +69,12 @@ class GroupManagementExecutionRuntime {if (!ctx.agentMember) return AGENT_MEMBER_UNAVAILABLE;if (!params.agentId) return buildError('agentId is required.', 'INVALID_ARGUMENTS');- const { started } = await ctx.agentMember.run({+ const { errors, started } = await ctx.agentMember.run({members: [{ agentId: params.agentId, instruction: params.instruction }],mode: 'in_group',onComplete: params.skipCallSupervisor ? 'finish' : 'resume',});- if (!started) return START_FAILED;+ if (!started) return startFailed(errors);return {content: '',@@ -81,13 +93,13 @@ class GroupManagementExecutionRuntime {const agentIds = params.agentIds ?? [];if (agentIds.length === 0) return buildError('agentIds is required.', 'INVALID_ARGUMENTS');- const { started } = await ctx.agentMember.run({+ const { errors, started } = await ctx.agentMember.run({disableTools: true,members: agentIds.map((agentId) => ({ agentId, instruction: params.instruction })),mode: 'in_group',onComplete: params.skipCallSupervisor ? 'finish' : 'resume',});- if (!started) return START_FAILED;+ if (!started) return startFailed(errors);return {content: '',@@ -105,13 +117,13 @@ class GroupManagementExecutionRuntime {if (!ctx.agentMember) return AGENT_MEMBER_UNAVAILABLE;if (!params.agentId) return buildError('agentId is required.', 'INVALID_ARGUMENTS');- const { started } = await ctx.agentMember.run({+ const { errors, started } = await ctx.agentMember.run({members: [{ agentId: params.agentId, instruction: params.reason }],mode: 'in_group',// Delegate hands control to the member β finish without another supervisor turn.onComplete: 'finish',});- if (!started) return START_FAILED;+ if (!started) return startFailed(errors);return {content: '',@@ -137,13 +149,13 @@ class GroupManagementExecutionRuntime {return buildError('agentId and instruction are required.', 'INVALID_ARGUMENTS');}- const { started } = await ctx.agentMember.run({+ const { errors, started } = await ctx.agentMember.run({members: [{ agentId: params.agentId, instruction: params.instruction }],mode: 'isolated',onComplete: params.skipCallSupervisor ? 'finish' : 'resume',timeout: params.timeout,});- if (!started) return START_FAILED;+ if (!started) return startFailed(errors);return {content: '',@@ -162,14 +174,14 @@ class GroupManagementExecutionRuntime {const tasks = params.tasks ?? [];if (tasks.length === 0) return buildError('tasks is required.', 'INVALID_ARGUMENTS');- const { started } = await ctx.agentMember.run({+ const { errors, started } = await ctx.agentMember.run({members: tasks.map((task) => ({ agentId: task.agentId, instruction: task.instruction })),mode: 'isolated',onComplete: params.skipCallSupervisor ? 'finish' : 'resume',// Per-task timeouts collapse to the longest; the barrier waits for all.timeout: tasks.reduce((max, task) => Math.max(max, task.timeout ?? 0), 0) || undefined,});- if (!started) return START_FAILED;+ if (!started) return startFailed(errors);return {content: '',diff --git a/apps/server/src/services/toolExecution/types.ts b/apps/server/src/services/toolExecution/types.tsindex 7410f886e45..aa7d3c637b7 100644--- a/apps/server/src/services/toolExecution/types.ts+++ b/apps/server/src/services/toolExecution/types.ts@@ -110,6 +110,14 @@ export interface ServerAgentMemberRunParams {}export interface ServerAgentMemberRunResult {+ /**+ * Per-member start failure reasons, parallel to the members that failed to+ * fork. Surfaced to the supervisor's tool result so a speak/broadcast/+ * delegate/executeAgentTask dispatch failure is diagnosable (e.g. "The model+ * provider returned an empty completion.") instead of an opaque "failed to+ * start" β mirrors `ServerSubAgentRunResult.error` (issue #16257).+ */+ errors?: string[];/*** Whether at least one member op was forked. `false` means every member* failed to start β no completion bridge will fire, so the caller must