mastra-ai/mastra · error
Async buffering is not yet supported with scope: 'resource'.
Error message
Async buffering is not yet supported with scope: 'resource'. Use scope: 'thread', or set observation: { bufferTokens: false } to disable async buffering. What it means
ObservationalMemory constructor rejects combining async token buffering (bufferTokens or bufferActivation set) with scope: 'resource', because buffering accumulates per-thread state that has no meaningful meaning when observations are shared at the resource level. The feature is simply not implemented for resource scope yet, so the constructor fails fast with guidance on alternatives.
Source
Thrown at packages/memory/src/processors/observational-memory/observational-memory.ts:976
*/
emitDebugEvent(event: ObservationDebugEvent): void {
if (this.onDebugEvent) {
this.onDebugEvent(event);
}
}
/**
* Validate buffer configuration on first use.
* Ensures bufferTokens is less than the threshold and bufferActivation is valid.
*/
private validateBufferConfig(): void {
// Async buffering is not yet supported with resource scope
const hasAsyncBuffering =
this.observationConfig.bufferTokens !== undefined ||
this.observationConfig.bufferActivation !== undefined ||
this.reflectionConfig.bufferActivation !== undefined;
if (hasAsyncBuffering && this.scope === 'resource') {
throw new Error(
`Async buffering is not yet supported with scope: 'resource'. ` +
`Use scope: 'thread', or set observation: { bufferTokens: false } to disable async buffering.`,
);
}
// 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})`,
);
}
}
View on GitHub (pinned to 75dd419e61)
Solutions
- Change scope to 'thread' if per-thread buffering fits your use case.
- Set observation: { bufferTokens: false } to explicitly disable async buffering while keeping resource scope.
- Remove bufferTokens/bufferActivation options from both observation and reflection configs.
- Track upstream releases for resource-scope buffering support before re-enabling.
Example fix
// before
const memory = new ObservationalMemory({ scope: 'resource', observation: { bufferTokens: 2000 } });
// after
const memory = new ObservationalMemory({ scope: 'resource', observation: { bufferTokens: false } }); Defensive patterns
Strategy: validation
Validate before calling
const cfg = { scope: 'resource', observation: { bufferTokens: 2000 } } as const;
const hasAsyncBuffering = cfg.observation.bufferTokens !== undefined || cfg.observation.bufferActivation !== undefined;
if (cfg.scope === 'resource' && hasAsyncBuffering) {
throw new Error('Async buffering is incompatible with resource scope');
} Try / catch
try {
memory = new ObservationalMemory(userConfig);
} catch (e) {
if (e.message.includes("scope: 'resource'")) {
memory = new ObservationalMemory({ ...userConfig, observation: { ...userConfig.observation, bufferTokens: false } });
} else throw e;
} Prevention
- When switching scope between 'thread' and 'resource', audit all buffer* options.
- Keep a single shared config factory per scope type.
- Add unit tests asserting construction succeeds for each shipped config.
When it happens
Trigger: new ObservationalMemory({ scope: 'resource', observation: { bufferTokens: N } }) or observation: { bufferActivation: x } or reflection: { bufferActivation: x }, i.e. any async-buffering option set while scope is 'resource'.
Common situations: Copying a thread-scoped ObservationalMemory config and switching scope to 'resource' for cross-thread memory without removing buffer options; enabling async buffering to reduce latency on a resource-scoped processor.
Related errors
- Target type '${targetType}' not yet supported.
- AGENT_NETWORK_OBSERVATIONAL_MEMORY_UNSUPPORTED
- observationalMemory.experimental_subconscious must be a Subc
- `retrieval: { vector: true }` requires a vector store. Pass
- `retrieval: { vector: true }` requires an embedder. Pass an
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/e21b6222c623b353.
Report an issue: GitHub.