mastra-ai/mastra · error · MastraError
AGENT_NETWORK_OBSERVATIONAL_MEMORY_UNSUPPORTED
AGENT_NETWORK_OBSERVATIONAL_MEMORY_UNSUPPORTED
Error message
Observational Memory is not supported with agent network. Agent network does not propagate the threadId/resourceId context Observational Memory requires. Disable observationalMemory before using agent.network().
What it means
This error is thrown by assertNetworkSupportsMemory when an agent with Observational Memory enabled is used inside agent.network(). Observational Memory depends on threadId/resourceId context being propagated through the loop, which the agent network does not do, so the combination is explicitly rejected with a 400-class USER error before the network loop starts.
Source
Thrown at packages/core/src/loop/network/index.ts:79
if (config === true) return true;
if (!config || config === false) return false;
if (typeof config !== 'object') return false;
return (config as { enabled?: boolean }).enabled !== false;
}
function assertNetworkSupportsMemory(memory: Awaited<ReturnType<Agent['getMemory']>>, memoryConfig: unknown) {
const configuredObservationalMemory =
typeof memory?.getConfig === 'function' ? memory.getConfig().observationalMemory : undefined;
const runtimeObservationalMemory =
memoryConfig && typeof memoryConfig === 'object' && 'observationalMemory' in memoryConfig
? (memoryConfig as { observationalMemory?: unknown }).observationalMemory
: undefined;
if (
isObservationalMemoryEnabled(runtimeObservationalMemory) ||
(runtimeObservationalMemory === undefined && isObservationalMemoryEnabled(configuredObservationalMemory))
) {
throw new MastraError({
id: 'AGENT_NETWORK_OBSERVATIONAL_MEMORY_UNSUPPORTED',
domain: ErrorDomain.AGENT_NETWORK,
category: ErrorCategory.USER,
text: OBSERVATIONAL_MEMORY_NETWORK_ERROR,
details: {
status: 400,
},
});
}
}
/**
* Safely parses JSON from LLM output, handling common issues like:
* - Unescaped control characters (newlines, tabs) in strings
* - Truncated/incomplete JSON (missing closing braces)
* - Partial JSON from token limits
*
* @param text - Raw JSON text from LLM outputView on GitHub (pinned to 75dd419e61)
Solutions
- Disable observationalMemory on the routing agent used with agent.network() (set observationalMemory.enabled=false in the agent's memory options).
- If the setting is passed at runtime, remove or set runtimeObservationalMemory to disabled for network calls.
- Use two agent instances: one with observational memory for direct conversations, one without it for the network routing agent.
- Remove the memory/observational-memory feature entirely from the network agent if observation is not needed.
Example fix
// before
const agent = new Agent({ name: 'router', memory: new Memory({ options: { observationalMemory: { enabled: true } } }) });
await agent.network('plan this', memory);
// after
const agent = new Agent({ name: 'router', memory: new Memory({ options: { observationalMemory: { enabled: false } } }) });
await agent.network('plan this', memory); Defensive patterns
Strategy: validation
Validate before calling
import { isObservationalMemoryEnabled } from '@mastra/core/loop/network';
const mem = await agent.getMemory({ requestContext });
const opts = mem?.getOptions?.();
if (isObservationalMemoryEnabled(runtimeObservationalMemory) || (!runtimeObservationalMemory && isObservationalMemoryEnabled(configuredObservationalMemory))) {
throw new Error('Disable observationalMemory before using agent.network()');
}
await agent.network(input, memory); Type guard
function isOmDisabled(om: unknown): boolean {
const enabled = (om as { enabled?: boolean } | undefined)?.enabled;
return enabled !== true;
} Try / catch
try {
await agent.network(input);
} catch (e) {
if (e instanceof MastraError && e.id === 'AGENT_NETWORK_OBSERVATIONAL_MEMORY_UNSUPPORTED') {
// fall back to non-network agent.generate() or re-create agent with OM disabled
}
throw e;
} Prevention
- Keep a dedicated routing agent without observational memory for network use
- Centralize agent/memory construction so OM flags are set in one place
- Add a unit test asserting the network agent's memory options have OM disabled
When it happens
Trigger: Calling agent.network() (directly or via createNetworkLoop/networkLoop, or getRoutingAgent/prepareMemoryStep paths) on a routing agent whose memory configuration has observationalMemory enabled — either in the configured memory options or passed at runtime (runtimeObservationalMemory), including when it is undefined at runtime and enabled in the agent's configured options.
Common situations: A developer enables observationalMemory on an agent for normal chat usage and later reuses the same agent as the network routing agent; upgrading Mastra and turning on observational memory globally without realizing network mode is incompatible; shared agent factory returns memory-enabled agents used in both network and non-network contexts.
Related errors
- AGENT_NETWORK_MEMORY_REQUIRED
- Tried to create observation embedding index but no vector db
- Observational memory is not enabled
- Observational Memory is not enabled for this agent
- sendStateSignal requires Mastra memory
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/ffe66964fe2965c6.
Report an issue: GitHub.