mastra-ai/mastra · error

Parallel ${operation} returned no output

Error message

Parallel ${operation} returned no output

What it means

requireParallelOutput normalizes results of parallel web search/extract sub-calls. When the underlying tool call returns undefined (no output at all), it throws this error instead of letting undefined flow into the schema result. It exists so parallel batch results always carry a concrete payload or a descriptive error.

Source

Thrown at mastracode/sdk/src/tools/web-search.ts:20

import { createParallelSearchTool, createParallelExtractTool } from '@mastra/parallel';
import { createTavilySearchTool, createTavilyExtractTool } from '@mastra/tavily';
import { z } from 'zod';

import { loadSettings, type WebSearchProviderSetting } from '../onboarding/settings.js';
import { truncateStringForTokenEstimate } from '../utils/token-estimator.js';

const MAX_WEB_SEARCH_TOKENS = 2_000;
const MAX_WEB_EXTRACT_TOKENS = 2_000;

const MIN_RELEVANCE_SCORE = 0.25;

const parallelWebSearchInputSchema = z.object({
  query: z.string().min(1).describe('The search query'),
});

function requireParallelOutput<T>(output: T | ValidationError | void, operation: 'search' | 'extract'): T {
  if (output === undefined) {
    throw new Error(`Parallel ${operation} returned no output`);
  }

  if (isValidationError(output)) {
    throw new Error(output.message);
  }

  return output;
}

/**
 * Check whether a Tavily API key is available in the environment.
 * Used to select model-independent web tools before falling back to
 * model-native web search.
 */
export function hasTavilyKey(): boolean {
  return !!process.env.TAVILY_API_KEY;
}

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Retry the operation; transient provider failures are the most common cause.
  2. Verify the search provider/API key is valid and returning results (test a direct query).
  3. Inspect the parallel sub-operation implementation to ensure it returns its result rather than an implicit undefined.

Example fix

// before: custom provider path that can fall through
async function search(q) { if (!apiKey) return; }
// after
async function search(q) {
  if (!apiKey) throw new Error('web search provider not configured');
  return await doSearch(q);
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!process.env.SEARCH_PROVIDER_API_KEY) throw new Error('search provider unconfigured — parallel search will return no output');

Type guard

function hasOutput<T>(o: T | undefined | null): o is T { return o !== undefined && o !== null; }

Try / catch

try { const res = await parallelWebSearch(query); } catch (e) { if (String(e.message).includes('returned no output')) { /* retry or fall back to single search */ } else throw e; }

Prevention

When it happens

Trigger: Calling the parallel web-search/extract tool path where a single search or extract sub-operation resolves to undefined — e.g. the model/tool returned void or the provider produced no result object.

Common situations: Provider outages or rate limits yielding empty tool results; a model that answered with no tool output; bug in a custom search provider returning nothing.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/3a612815ad869237. Report an issue: GitHub.