vercel/ai · error

Not implemented

Error message

Not implemented

What it means

WorkflowAgent.generate() is a stub that intentionally throws 'Not implemented'. The WorkflowAgent class only supports token streaming via stream(); synchronous generation was never implemented for workflow-based agents. Calling generate() instead of stream() always throws.

Source

Thrown at packages/workflow/src/workflow-agent.ts:1338

    this.generationSettings = {
      maxOutputTokens: options.maxOutputTokens,
      temperature: options.temperature,
      topP: options.topP,
      topK: options.topK,
      presencePenalty: options.presencePenalty,
      frequencyPenalty: options.frequencyPenalty,
      stopSequences: options.stopSequences,
      seed: options.seed,
      maxRetries: options.maxRetries,
      abortSignal: options.abortSignal,
      headers: options.headers,
      reasoning: options.reasoning,
      providerOptions: options.providerOptions,
    };
  }

  generate() {
    throw new Error('Not implemented');
  }

  async stream<
    TTools extends TBaseTools = TBaseTools,
    OUTPUT = never,
    PARTIAL_OUTPUT = never,
  >(
    options: WorkflowAgentStreamOptions<
      TTools,
      TRuntimeContext,
      OUTPUT,
      PARTIAL_OUTPUT
    >,
  ): Promise<WorkflowAgentStreamResult<TTools, OUTPUT>> {
    const { onFinish, onEnd = onFinish } = options;

    // Call prepareCall to transform parameters before the agent loop
    let effectiveModel: LanguageModel = this.model;

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Call agent.stream(...) (or streamText) instead of generate(...).
  2. Buffer the stream manually if a single string result is needed.
  3. Check whether a newer version of @workflow/ai implements generate() before assuming it exists.

Example fix

// before
const result = await agent.generate({ prompt });
// after
let text = '';
for await (const part of agent.stream({ prompt })) {
  if (part.type === 'text-delta') text += part.delta;
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (typeof agent.generate === 'function' && !agent.constructor.name.includes('Workflow')) {
  await agent.generate(opts);
} else {
  // use stream
}

Type guard

function supportsGenerate(a: unknown): a is { generate: Function } {
  return !!a && typeof (a as any).generate === 'function' &&
    !(a instanceof WorkflowAgent);
}

Try / catch

try {
  await agent.generate(opts);
} catch (e) {
  if (e instanceof Error && e.message === 'Not implemented') {
    for await (const part of agent.stream(opts)) { /* consume */ }
  } else throw e;
}

Prevention

When it happens

Trigger: Calling agent.generate(...) (or an API like generateText that routes to the WorkflowAgent's language model) on a WorkflowAgent instance, which only implements stream().

Common situations: Developers porting code written for standard language models to WorkflowAgent; using a generic helper that calls generate(); copy-pasting examples meant for regular providers.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/c982838ca7dc3dea. Report an issue: GitHub.