mastra-ai/mastra · error

reflection.bufferActivation must be in range (0, 1], got ${t

Error message

reflection.bufferActivation must be in range (0, 1], got ${this.reflectionConfig.bufferActivation}

What it means

ObservationalMemory validates `reflectionConfig.bufferActivation` at construction time. It must be a float in the interval (0, 1] — a proportion of messages that triggers async reflection. The processor throws this error when the value is undefined-able-but-invalid, i.e. <= 0 or > 1, because such a value would either never activate reflection or activate it deterministically beyond the intended probability/portion semantics.

Source

Thrown at packages/memory/src/processors/observational-memory/observational-memory.ts:1047

    // Validate observer context optimization options
    if (
      this.observationConfig.previousObserverTokens !== undefined &&
      this.observationConfig.previousObserverTokens !== false
    ) {
      if (
        !Number.isFinite(this.observationConfig.previousObserverTokens) ||
        this.observationConfig.previousObserverTokens < 0
      ) {
        throw new Error(
          `observation.previousObserverTokens must be false or a finite number >= 0, got ${this.observationConfig.previousObserverTokens}`,
        );
      }
    }

    // Validate reflection bufferActivation (0-1 float range)
    if (this.reflectionConfig.bufferActivation !== undefined) {
      if (this.reflectionConfig.bufferActivation <= 0 || this.reflectionConfig.bufferActivation > 1) {
        throw new Error(
          `reflection.bufferActivation must be in range (0, 1], got ${this.reflectionConfig.bufferActivation}`,
        );
      }
    }

    // Validate reflection blockAfter
    if (this.reflectionConfig.blockAfter !== undefined) {
      const reflectionThreshold = getMaxThreshold(this.reflectionConfig.observationTokens);
      if (this.reflectionConfig.blockAfter < reflectionThreshold) {
        throw new Error(
          `reflection.blockAfter (${this.reflectionConfig.blockAfter}) must be >= reflection.observationTokens (${reflectionThreshold})`,
        );
      }
      if (!this.reflectionConfig.bufferActivation) {
        throw new Error(
          `reflection.blockAfter requires reflection.bufferActivation to be set (blockAfter only applies when async reflection is enabled)`,
        );
      }

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Set `reflection.bufferActivation` to a float in (0, 1], e.g. 0.2.
  2. If you intended a percentage, divide by 100 (50 -> 0.5).
  3. If you do not want async reflection, omit `bufferActivation` entirely instead of passing 0.
  4. Clamp/validate the value before constructing the processor if it is computed at runtime.

Example fix

// before
new ObservationalMemory({
  reflection: { bufferActivation: 50 },
});
// after
new ObservationalMemory({
  reflection: { bufferActivation: 0.5 },
});
Defensive patterns

Strategy: validation

Validate before calling

const ba = config.reflection?.bufferActivation;
if (ba !== undefined && (typeof ba !== 'number' || Number.isNaN(ba) || ba <= 0 || ba > 1)) {
  throw new RangeError(`bufferActivation must be in (0, 1], got ${ba}`);
}

Type guard

function isValidBufferActivation(v: unknown): v is number {
  return typeof v === 'number' && Number.isFinite(v) && v > 0 && v <= 1;
}

Prevention

When it happens

Trigger: Constructing `new ObservationalMemory({ ... reflection: { bufferActivation: 0 } })`, a negative number, a value > 1 (e.g. 1.5 or a percentage like 50 instead of 0.5), or NaN during processor initialization (observational-memory.ts:1047).

Common situations: Passing a percentage (50) instead of a fraction (0.5); computing bufferActivation dynamically and getting 0 (e.g. a division by a larger denominator); copying config from docs with an out-of-range example; JSON config files where the value was hand-edited.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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