{"record":{"id":"767256330dba8ff1","repo":"mastra-ai/mastra","slug":"no-result-received-from-agent-execution","errorCode":null,"errorMessage":"No result received from agent execution","messagePattern":"No result received from agent execution","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent-builder/src/workflows/workflow-builder/workflow-builder.ts","lineNumber":448,"sourceCode":"          break;\n        }\n\n        // If agent claims completed but taskManager shows pending tasks, continue loop\n        if (finalResult.status === 'completed' && !allTasksCompleted) {\n          console.info(\n            `Agent claimed completion but taskManager shows pending tasks: ${postPendingTasks.map(t => t.id).join(', ')}`,\n          );\n          // Continue to next iteration\n        }\n      }\n\n      if (iterationCount >= maxIterations && !allTasksCompleted) {\n        finalResult.error = `Maximum iterations (${maxIterations}) reached but not all tasks completed`;\n        finalResult.status = 'in_progress';\n      }\n\n      if (!finalResult) {\n        throw new Error('No result received from agent execution');\n      }\n\n      // If the agent needs clarification, suspend the workflow\n      if (finalResult.status === 'needs_clarification' && finalResult.questions && finalResult.questions.length > 0) {\n        console.info(`Agent needs clarification: ${finalResult.questions.length} questions`);\n\n        console.info('finalResult', JSON.stringify(finalResult, null, 2));\n        return suspend({\n          questions: finalResult.questions,\n          currentProgress: finalResult.progress,\n          completedTasks: finalResult.completedTasks || [],\n          message: finalResult.message,\n        });\n      }\n\n      const finalTaskStatus = await AgentBuilderDefaults.manageTaskList({ action: 'list' });\n      const finalCompletedTasks = finalTaskStatus.tasks.filter(task => task.status === 'completed');\n      const finalPendingTasks = finalTaskStatus.tasks.filter(task => task.status !== 'completed');","sourceCodeStart":430,"sourceCodeEnd":466,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/agent-builder/src/workflows/workflow-builder/workflow-builder.ts#L430-L466","documentation":"After the iteration loop, the workflow re-checks that finalResult exists before reading finalResult.status/questions; if it is still falsy it throws 'No result received from agent execution'. This is the end-of-run guard: it fires when the loop finished without ever producing a usable structured result (note: the preceding max-iterations branch assumes finalResult exists, so reaching here falsy means no iteration yielded a result at all).","triggerScenarios":"Every iteration's stream.object was falsy (see the per-iteration variant) or the loop body never executed/assigned finalResult, so the variable remains undefined after the loop.","commonSituations":"Persistent provider outages or refusals across all iterations, misconfigured model credentials causing immediate stream failures each iteration, or an edge case where maxIterations allowed zero iterations.","solutions":["Fix the per-iteration failure cause (model, schema, credentials) so at least one iteration produces a result","Verify model configuration/credentials — repeated stream failures usually indicate auth or provider issues","Ensure maxIterations is at least 1 in the workflow input","Retry the workflow after checking provider status; log raw stream output per iteration to find why no object ever parsed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"export function assertWorkflowInput(input: { maxIterations?: number }) {\n  if (input.maxIterations != null && input.maxIterations < 1) {\n    throw new Error('maxIterations must be >= 1');\n  }\n}\n// validate workflow input before start()","typeGuard":"export function isAgentRunResult(r: unknown): r is { status: string; error?: string; questions?: unknown[] } {\n  return r != null && typeof r === 'object' && typeof (r as any).status === 'string';\n}\n// guard before reading status/questions: if (!isAgentRunResult(finalResult)) throw ...","tryCatchPattern":"try {\n  await run.start(input);\n} catch (e) {\n  if (e instanceof Error && e.message === 'No result received from agent execution') {\n    // loop never produced a result: check model credentials/provider health and retry\n  }\n  throw e;\n}","preventionTips":["Set maxIterations >= 1 and monitor per-iteration result logging","Validate model credentials/config before starting the run","Check provider status when every iteration yields no result","Treat per-iteration 'No result' errors as the early signal — fix before the loop drains"],"tags":["agent","workflow-builder","streaming"],"backgroundTag":"empty-agent-result","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}