{"record":{"id":"73eab9f4bdf7330b","repo":"mastra-ai/mastra","slug":"no-result-received-from-agent-execution-on-iterati","errorCode":null,"errorMessage":"No result received from agent execution on iteration ${iterationCount}","messagePattern":"No result received from agent execution on iteration (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent-builder/src/workflows/workflow-builder/workflow-builder.ts","lineNumber":412,"sourceCode":"            finalMessage = '';\n          }\n\n          if (chunk.type === 'tool-result') {\n            console.info(JSON.stringify(chunk, null, 2));\n          }\n\n          if (chunk.type === 'finish') {\n            console.info(chunk);\n          }\n        }\n\n        await stream.consumeStream();\n        finalResult = await stream.object;\n\n        console.info(`Iteration ${iterationCount} result:`, { finalResult });\n\n        if (!finalResult) {\n          throw new Error(`No result received from agent execution on iteration ${iterationCount}`);\n        }\n\n        const postIterationTaskStatus = await AgentBuilderDefaults.manageTaskList({ action: 'list' });\n        const postCompletedTasks = postIterationTaskStatus.tasks.filter(task => task.status === 'completed');\n        const postPendingTasks = postIterationTaskStatus.tasks.filter(task => task.status !== 'completed');\n\n        allTasksCompleted = postPendingTasks.length === 0;\n\n        console.info(\n          `After iteration ${iterationCount}: ${postCompletedTasks.length}/${expectedTaskIds.length} tasks completed in taskManager`,\n        );\n\n        // If agent needs clarification, break out and suspend\n        if (finalResult.status === 'needs_clarification' && finalResult.questions && finalResult.questions.length > 0) {\n          console.info(\n            `Agent needs clarification on iteration ${iterationCount}: ${finalResult.questions.length} questions`,\n          );\n          break;","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/agent-builder/src/workflows/workflow-builder/workflow-builder.ts#L394-L430","documentation":"During each loop iteration, the workflow consumes the agent's structured-output stream and awaits stream.object; if the parsed result is falsy, this error declares that no structured result was produced for the current iteration. It guards downstream logic (task-status diffing, completion checks) from operating on a nonexistent result.","triggerScenarios":"The model stream ended without emitting a valid object matching the response schema: empty/refused completion, output failing schema validation so stream.object resolves to undefined, or the stream erroring/finishing early after consumeStream().","commonSituations":"Model refusing or returning empty output (content filter, overlong context), a model that does not reliably support structured output, malformed schema causing silent parse failure, or provider timeouts producing truncated streams.","solutions":["Retry the iteration/run — empty structured outputs are often transient model behavior","Use a model that supports structured/object output reliably and check provider logs for refusals or truncation","Validate the response schema is correct and not over-constrained (unsatisfiable schemas yield no valid object)","Reduce input size or split tasks if the context window is being exceeded","Add logging around stream.text/error before awaiting stream.object to capture what the model actually returned"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// before the run: confirm the model supports structured output and the schema compiles\nexport function assertStructuredOutputCapable(modelId: string, allowed: string[]) {\n  if (!allowed.includes(modelId)) throw new Error(`${modelId} may not support structured object output`);\n}","typeGuard":"export function hasResult(r: unknown): r is { status: string; [k: string]: unknown } {\n  return r != null && typeof r === 'object' && 'status' in r;\n}\n// after await stream.object: if (!hasResult(finalResult)) retry or fail fast","tryCatchPattern":"let finalResult = await stream.object;\nif (!finalResult) {\n  if (attempt < maxAttempts) { await sleep(backoff(attempt)); return retryIteration(); }\n  throw new Error(`No result received from agent execution on iteration ${iterationCount}`);\n}","preventionTips":["Use models with reliable structured/object output support","Keep the response schema satisfiable — avoid over-constrained fields","Log stream.text/stream error before awaiting stream.object to see raw model output","Watch for context-window overflow; trim inputs when refusals/empty outputs repeat","Retry empty iterations with backoff before failing the run"],"tags":["agent","streaming","structured-output","workflow-builder"],"backgroundTag":"empty-agent-result","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}