mastra-ai/mastra · error

observation.bufferActivation must be > 0, got ${this.observa

Error message

observation.bufferActivation must be > 0, got ${this.observationConfig.bufferActivation}

What it means

observation.bufferActivation supports two modes: a ratio in (0, 1] of the threshold, or an absolute token count >= 1000. Values in between (0, 1] exclusive — i.e. > 1 but < 1000 — and values <= 0 are ambiguous or meaningless, so the constructor rejects them to prevent silently misinterpreting a ratio as tokens.

Source

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

    }

    // Validate observation bufferTokens
    const observationThreshold = getMaxThreshold(this.observationConfig.messageTokens);
    if (this.observationConfig.bufferTokens !== undefined) {
      if (this.observationConfig.bufferTokens <= 0) {
        throw new Error(`observation.bufferTokens must be > 0, got ${this.observationConfig.bufferTokens}`);
      }
      if (this.observationConfig.bufferTokens >= observationThreshold) {
        throw new Error(
          `observation.bufferTokens (${this.observationConfig.bufferTokens}) must be less than messageTokens (${observationThreshold})`,
        );
      }
    }

    // Validate observation bufferActivation: (0, 1] for ratio, or >= 1000 for absolute retention tokens
    if (this.observationConfig.bufferActivation !== undefined) {
      if (this.observationConfig.bufferActivation <= 0) {
        throw new Error(`observation.bufferActivation must be > 0, got ${this.observationConfig.bufferActivation}`);
      }
      if (this.observationConfig.bufferActivation > 1 && this.observationConfig.bufferActivation < 1000) {
        throw new Error(
          `observation.bufferActivation must be <= 1 (ratio) or >= 1000 (absolute token retention), got ${this.observationConfig.bufferActivation}`,
        );
      }
      if (
        this.observationConfig.bufferActivation >= 1000 &&
        this.observationConfig.bufferActivation >= observationThreshold
      ) {
        throw new Error(
          `observation.bufferActivation as absolute retention (${this.observationConfig.bufferActivation}) must be less than messageTokens (${observationThreshold})`,
        );
      }
    }

    // Validate observation blockAfter
    if (this.observationConfig.blockAfter !== undefined) {

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Use a decimal ratio for proportional activation, e.g. bufferActivation: 0.5.
  2. Use an absolute token count >= 1000, e.g. bufferActivation: 2000.
  3. Remove bufferActivation to use the default activation behavior.

Example fix

// before
new ObservationalMemory({ observation: { bufferActivation: 50 } }); // dead zone
// after
new ObservationalMemory({ observation: { bufferActivation: 0.5 } }); // 50% ratio
Defensive patterns

Strategy: validation

Validate before calling

const ba = observationConfig.bufferActivation;
if (ba !== undefined && (ba <= 0 || (ba > 1 && ba < 1000))) {
  throw new Error(`bufferActivation must be <= 1 (ratio) or >= 1000 (absolute), got ${ba}`);
}

Type guard

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

Prevention

When it happens

Trigger: new ObservationalMemory({ observation: { bufferActivation: 0 } }) or bufferActivation: -1 (<=0), or bufferActivation: 50 / 500 (any value > 1 and < 1000).

Common situations: Entering a percentage like 50 intending '50% of threshold' instead of 0.5; passing 0 to mean 'disabled' instead of omitting the option; copy-pasting a token count from a small config that falls in the dead zone.

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/b63f1fda53d454f3. Report an issue: GitHub.