{"record":{"id":"dd77e4e787cb3691","repo":"mastra-ai/mastra","slug":"reflection-blockafter-requires-reflection-bufferac","errorCode":null,"errorMessage":"reflection.blockAfter requires reflection.bufferActivation to be set (blockAfter only applies when async reflection is enabled)","messagePattern":"reflection\\.blockAfter requires reflection\\.bufferActivation to be set \\(blockAfter only applies when async reflection is enabled\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/memory/src/processors/observational-memory/observational-memory.ts","lineNumber":1062,"sourceCode":"    // 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      }\n    }\n  }\n\n  /**\n   * Resolve the effective messageTokens for a record.\n   * Only explicit per-record overrides (stored under `_overrides`) win;\n   * the initial config snapshot written by getOrCreateRecord() is ignored\n   * so that later instance-level changes still take effect.\n   *\n   * Overrides that fall below the instance-level buffering floor\n   * (bufferTokens / absolute bufferActivation) are clamped to the\n   * instance threshold to preserve buffering invariants.\n   */\n  private getEffectiveMessageTokens(record: ObservationalMemoryRecord): number | ThresholdRange {\n    const overrides = (record.config as { _overrides?: { observation?: { messageTokens?: number | ThresholdRange } } })","sourceCodeStart":1044,"sourceCodeEnd":1080,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/processors/observational-memory/observational-memory.ts#L1044-L1080","documentation":"`reflection.blockAfter` only has effect when async reflection is enabled via `reflection.bufferActivation`. If `blockAfter` is set but `bufferActivation` is falsy (undefined/0), the config is contradictory — blocking would never trigger. ObservationalMemory throws at construction to surface this dependency instead of silently ignoring blockAfter.","triggerScenarios":"Constructing ObservationalMemory with `reflection: { blockAfter: 5000 }` but no `bufferActivation`, or with `bufferActivation: 0`, inside the blockAfter validation block (observational-memory.ts:1062).","commonSituations":"Following docs/snippets that show only blockAfter; partially migrating config where bufferActivation was removed in a refactor; assuming blockAfter enables async reflection implicitly.","solutions":["Add a valid `bufferActivation` value in (0, 1] alongside `blockAfter`.","Remove `blockAfter` if you do not intend to use async reflection.","If bufferActivation comes from external config, ensure it is present whenever blockAfter is present (validate together)."],"exampleFix":"// before\nreflection: { blockAfter: 5000 }\n// after\nreflection: { bufferActivation: 0.3, blockAfter: 5000 }","handlingStrategy":"validation","validationCode":"const r = config.reflection ?? {};\nif (r.blockAfter !== undefined && !r.bufferActivation) {\n  throw new Error('reflection.blockAfter requires reflection.bufferActivation');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set bufferActivation and blockAfter as a pair.","Treat blockAfter as an async-reflection-only knob; document it next to bufferActivation in your config schema.","Add a zod/schema refinement enforcing this cross-field invariant before constructing the processor."],"tags":["configuration","validation","observational-memory"],"backgroundTag":"invalid-config-value","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}