{"record":{"id":"c5f7e44c801cb1c3","repo":"mastra-ai/mastra","slug":"observation-blockafter-this-observationconfig-b","errorCode":null,"errorMessage":"observation.blockAfter (${this.observationConfig.blockAfter}) must be >= messageTokens (${observationThreshold})","messagePattern":"observation\\.blockAfter \\((.+?)\\) must be >= messageTokens \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/memory/src/processors/observational-memory/observational-memory.ts","lineNumber":1018,"sourceCode":"      if (this.observationConfig.bufferActivation > 1 && this.observationConfig.bufferActivation < 1000) {\n        throw new Error(\n          `observation.bufferActivation must be <= 1 (ratio) or >= 1000 (absolute token retention), got ${this.observationConfig.bufferActivation}`,\n        );\n      }\n      if (\n        this.observationConfig.bufferActivation >= 1000 &&\n        this.observationConfig.bufferActivation >= observationThreshold\n      ) {\n        throw new Error(\n          `observation.bufferActivation as absolute retention (${this.observationConfig.bufferActivation}) must be less than messageTokens (${observationThreshold})`,\n        );\n      }\n    }\n\n    // Validate observation blockAfter\n    if (this.observationConfig.blockAfter !== undefined) {\n      if (this.observationConfig.blockAfter < observationThreshold) {\n        throw new Error(\n          `observation.blockAfter (${this.observationConfig.blockAfter}) must be >= messageTokens (${observationThreshold})`,\n        );\n      }\n      if (!this.observationConfig.bufferTokens) {\n        throw new Error(\n          `observation.blockAfter requires observation.bufferTokens to be set (blockAfter only applies when async buffering is enabled)`,\n        );\n      }\n    }\n\n    // 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","sourceCodeStart":1000,"sourceCodeEnd":1036,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/processors/observational-memory/observational-memory.ts#L1000-L1036","documentation":"observation.blockAfter marks a token position after which observation blocking (skipping reflection on older content) begins. It only makes sense if it is at or beyond the messageTokens threshold — otherwise every batch would immediately qualify for blocking — and it only applies when async buffering (bufferTokens) is enabled. Both conditions are validated at construction time.","triggerScenarios":"new ObservationalMemory({ observation: { messageTokens: 4000, blockAfter: 2000, bufferTokens: 1000 } }) — blockAfter below the threshold; or setting blockAfter without bufferTokens (see sibling error for that case).","commonSituations":"Setting blockAfter as 'how many tokens back to block' instead of an absolute position >= threshold; enabling blockAfter on a synchronous (unbuffered) setup where it has no effect.","solutions":["Set blockAfter to a value >= the messageTokens threshold (e.g. threshold * 2).","Ensure observation.bufferTokens is also set, since blockAfter requires async buffering.","Remove blockAfter if you don't need observation blocking."],"exampleFix":"// before\nnew ObservationalMemory({ observation: { messageTokens: 4000, blockAfter: 2000 } });\n// after\nnew ObservationalMemory({ observation: { messageTokens: 4000, bufferTokens: 1000, blockAfter: 8000 } });","handlingStrategy":"validation","validationCode":"const observationThreshold = getMaxThreshold(observationConfig.messageTokens);\nif (observationConfig.blockAfter !== undefined && observationConfig.blockAfter < observationThreshold) {\n  throw new Error(`blockAfter (${observationConfig.blockAfter}) must be >= messageTokens (${observationThreshold})`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Think of blockAfter as an absolute token position, not an offset.","Set blockAfter to a multiple of messageTokens (e.g. 2x).","Only enable blockAfter together with bufferTokens."],"tags":["configuration","validation","observational-memory","token-limits"],"backgroundTag":"invalid-config-value","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}