{"record":{"id":"b67ee60e280e28c7","repo":"mastra-ai/mastra","slug":"reflection-bufferactivation-must-be-in-range-0-1","errorCode":null,"errorMessage":"reflection.bufferActivation must be in range (0, 1], got ${this.reflectionConfig.bufferActivation}","messagePattern":"reflection\\.bufferActivation must be in range \\(0, 1\\], got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/memory/src/processors/observational-memory/observational-memory.ts","lineNumber":1047,"sourceCode":"    // Validate observer context optimization options\n    if (\n      this.observationConfig.previousObserverTokens !== undefined &&\n      this.observationConfig.previousObserverTokens !== false\n    ) {\n      if (\n        !Number.isFinite(this.observationConfig.previousObserverTokens) ||\n        this.observationConfig.previousObserverTokens < 0\n      ) {\n        throw new Error(\n          `observation.previousObserverTokens must be false or a finite number >= 0, got ${this.observationConfig.previousObserverTokens}`,\n        );\n      }\n    }\n\n    // Validate reflection bufferActivation (0-1 float range)\n    if (this.reflectionConfig.bufferActivation !== undefined) {\n      if (this.reflectionConfig.bufferActivation <= 0 || this.reflectionConfig.bufferActivation > 1) {\n        throw new Error(\n          `reflection.bufferActivation must be in range (0, 1], got ${this.reflectionConfig.bufferActivation}`,\n        );\n      }\n    }\n\n    // Validate reflection blockAfter\n    if (this.reflectionConfig.blockAfter !== undefined) {\n      const reflectionThreshold = getMaxThreshold(this.reflectionConfig.observationTokens);\n      if (this.reflectionConfig.blockAfter < reflectionThreshold) {\n        throw new Error(\n          `reflection.blockAfter (${this.reflectionConfig.blockAfter}) must be >= reflection.observationTokens (${reflectionThreshold})`,\n        );\n      }\n      if (!this.reflectionConfig.bufferActivation) {\n        throw new Error(\n          `reflection.blockAfter requires reflection.bufferActivation to be set (blockAfter only applies when async reflection is enabled)`,\n        );\n      }","sourceCodeStart":1029,"sourceCodeEnd":1065,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/processors/observational-memory/observational-memory.ts#L1029-L1065","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Set `reflection.bufferActivation` to a float in (0, 1], e.g. 0.2.","If you intended a percentage, divide by 100 (50 -> 0.5).","If you do not want async reflection, omit `bufferActivation` entirely instead of passing 0.","Clamp/validate the value before constructing the processor if it is computed at runtime."],"exampleFix":"// before\nnew ObservationalMemory({\n  reflection: { bufferActivation: 50 },\n});\n// after\nnew ObservationalMemory({\n  reflection: { bufferActivation: 0.5 },\n});","handlingStrategy":"validation","validationCode":"const ba = config.reflection?.bufferActivation;\nif (ba !== undefined && (typeof ba !== 'number' || Number.isNaN(ba) || ba <= 0 || ba > 1)) {\n  throw new RangeError(`bufferActivation must be in (0, 1], got ${ba}`);\n}","typeGuard":"function isValidBufferActivation(v: unknown): v is number {\n  return typeof v === 'number' && Number.isFinite(v) && v > 0 && v <= 1;\n}","tryCatchPattern":null,"preventionTips":["Express bufferActivation as a fraction (0.2), never a percentage (20).","Clamp computed values: Math.min(Math.max(v, Number.EPSILON), 1).","Omit the field entirely when async reflection is unwanted instead of passing 0."],"tags":["configuration","validation","observational-memory"],"backgroundTag":"invalid-config-value","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}