mastra-ai/mastra · error · Error

Not implemented

Error message

Not implemented

What it means

Inside evaluateCondition for the evented step executor, the ExecutionEngine context handed to condition functions stubs bail() as unimplemented — calling it always throws this Error. bail (early-terminating the workflow with a result) is not supported for condition evaluation in the evented engine yet.

Source

Thrown at packages/core/src/workflows/evented/step-executor.ts:474

  }): Promise<boolean> {
    const callId = randomUUID();
    const outputWriter = this.createOutputWriter(runId);

    return condition(
      createDeprecationProxy(
        {
          workflowId,
          runId,
          mastra: this.mastra!,
          requestContext,
          inputData,
          state,
          retryCount,
          resumeData: resumeData,
          getInitData: () => stepResults?.input as any,
          getStepResult: getStepResult.bind(this, stepResults),
          bail: (_result: any) => {
            throw new Error('Not implemented');
          },
          writer: new ToolStream(
            {
              prefix: 'workflow-step',
              callId,
              name: 'condition',
              runId,
            },
            outputWriter,
          ),
          abort: () => {
            abortController?.abort();
          },
          [PUBSUB_SYMBOL]: this.mastra!.pubsub,
          [STREAM_FORMAT_SYMBOL]: undefined, // TODO
          engine: {},
          abortSignal: abortController?.signal,
          // TODO

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Remove the bail() call from the condition; return a boolean that controls whether the step runs.
  2. Use suspend/resume or step output routing to model early termination instead of bail.
  3. Run the workflow on the standard engine if bail semantics are required.
  4. Track Mastra releases for evented-engine bail support before relying on it.

Example fix

// before
when: async ({ bail }) => { if (done) bail({ done: true }); return true; }
// after
when: async ({ getStepResult }) => !getStepResult('finish')?.done
Defensive patterns

Strategy: validation

Validate before calling

// statically disallow bail in conditions meant for the evented engine
if (conditionFn.toString().includes('bail(')) {
  throw new Error('bail() is not supported in evented-engine conditions');
}

Try / catch

try { await eventedWf.run({ input }); } catch (e) { if (e.message === 'Not implemented' && usingEventedEngine) { return runOnStandardEngine(input); } throw e; }

Prevention

When it happens

Trigger: A workflow step's when/condition function calls ctx.bail(result) while executing on the evented engine.

Common situations: Reusing condition logic written for the standard engine (where bail works) in an evented workflow; authors using bail to short-circuit a run from a condition.

Related errors


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