mastra-ai/mastra · error
reflection.blockAfter (${this.reflectionConfig.blockAfter})
Error message
reflection.blockAfter (${this.reflectionConfig.blockAfter}) must be >= reflection.observationTokens (${reflectionThreshold}) What it means
When `reflectionConfig.blockAfter` is set, ObservationalMemory checks it against `getMaxThreshold(reflectionConfig.observationTokens)` — the maximum token threshold derived from the observation-token budget. `blockAfter` marks the point at which messages are blocked pending reflection, so it can never legitimately sit below the reflection token threshold. The processor throws at construction when `blockAfter < reflectionThreshold`.
Source
Thrown at packages/memory/src/processors/observational-memory/observational-memory.ts:1057
`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)`,
);
}
}
}
/**
* Resolve the effective messageTokens for a record.
* Only explicit per-record overrides (stored under `_overrides`) win;
* the initial config snapshot written by getOrCreateRecord() is ignored
* so that later instance-level changes still take effect.
*
* Overrides that fall below the instance-level buffering floorView on GitHub (pinned to 75dd419e61)
Solutions
- Raise `reflection.blockAfter` so it is >= getMaxThreshold(reflection.observationTokens).
- Lower `reflection.observationTokens` so its max threshold falls below the intended blockAfter.
- Remove `blockAfter` if you do not need blocking behavior and rely on default reflection flow.
- Compute blockAfter programmatically from observationTokens rather than hard-coding it.
Example fix
// before
reflection: { observationTokens: 2000, blockAfter: 1000 }
// after
reflection: { observationTokens: 2000, blockAfter: 4000 } Defensive patterns
Strategy: validation
Validate before calling
// using the library's own getMaxThreshold
const threshold = getMaxThreshold(config.reflection.observationTokens);
if (config.reflection.blockAfter < threshold) {
config.reflection.blockAfter = threshold;
} Prevention
- Derive blockAfter from observationTokens programmatically instead of hard-coding.
- Re-validate config after any change to observationTokens.
- Keep OM reflection settings in one typed config object so related fields change together.
When it happens
Trigger: Constructing ObservationalMemory with `reflection: { blockAfter: N, observationTokens: M }` where N < getMaxThreshold(M), e.g. `blockAfter: 1000` with `observationTokens: 2000` (observational-memory.ts:1057).
Common situations: Tuning `observationTokens` upward after previously setting `blockAfter` to a now-too-small value; copying a blockAfter from another project with different token budgets; misunderstanding that blockAfter is an absolute token count, not a small message offset.
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
- observationalMemory.experimental_subconscious must be a Subc
- `retrieval: { vector: true }` requires a vector store. Pass
- `retrieval: { vector: true }` requires an embedder. Pass an
- observation.bufferTokens must be > 0, got ${this.observation
- observation.bufferTokens (${this.observationConfig.bufferTok
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/6ae3735aaeac5b79.
Report an issue: GitHub.