{"record":{"id":"ffe66964fe2965c6","repo":"mastra-ai/mastra","slug":"agent-network-observational-memory-unsupported","errorCode":"AGENT_NETWORK_OBSERVATIONAL_MEMORY_UNSUPPORTED","errorMessage":"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().","messagePattern":"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\\(\\)\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":400,"severity":"error","filePath":"packages/core/src/loop/network/index.ts","lineNumber":79,"sourceCode":"  if (config === true) return true;\n  if (!config || config === false) return false;\n  if (typeof config !== 'object') return false;\n  return (config as { enabled?: boolean }).enabled !== false;\n}\n\nfunction assertNetworkSupportsMemory(memory: Awaited<ReturnType<Agent['getMemory']>>, memoryConfig: unknown) {\n  const configuredObservationalMemory =\n    typeof memory?.getConfig === 'function' ? memory.getConfig().observationalMemory : undefined;\n  const runtimeObservationalMemory =\n    memoryConfig && typeof memoryConfig === 'object' && 'observationalMemory' in memoryConfig\n      ? (memoryConfig as { observationalMemory?: unknown }).observationalMemory\n      : undefined;\n\n  if (\n    isObservationalMemoryEnabled(runtimeObservationalMemory) ||\n    (runtimeObservationalMemory === undefined && isObservationalMemoryEnabled(configuredObservationalMemory))\n  ) {\n    throw new MastraError({\n      id: 'AGENT_NETWORK_OBSERVATIONAL_MEMORY_UNSUPPORTED',\n      domain: ErrorDomain.AGENT_NETWORK,\n      category: ErrorCategory.USER,\n      text: OBSERVATIONAL_MEMORY_NETWORK_ERROR,\n      details: {\n        status: 400,\n      },\n    });\n  }\n}\n\n/**\n * Safely parses JSON from LLM output, handling common issues like:\n * - Unescaped control characters (newlines, tabs) in strings\n * - Truncated/incomplete JSON (missing closing braces)\n * - Partial JSON from token limits\n *\n * @param text - Raw JSON text from LLM output","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/loop/network/index.ts#L61-L97","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst agent = new Agent({ name: 'router', memory: new Memory({ options: { observationalMemory: { enabled: true } } }) });\nawait agent.network('plan this', memory);\n// after\nconst agent = new Agent({ name: 'router', memory: new Memory({ options: { observationalMemory: { enabled: false } } }) });\nawait agent.network('plan this', memory);","handlingStrategy":"validation","validationCode":"import { isObservationalMemoryEnabled } from '@mastra/core/loop/network';\nconst mem = await agent.getMemory({ requestContext });\nconst opts = mem?.getOptions?.();\nif (isObservationalMemoryEnabled(runtimeObservationalMemory) || (!runtimeObservationalMemory && isObservationalMemoryEnabled(configuredObservationalMemory))) {\n  throw new Error('Disable observationalMemory before using agent.network()');\n}\nawait agent.network(input, memory);","typeGuard":"function isOmDisabled(om: unknown): boolean {\n  const enabled = (om as { enabled?: boolean } | undefined)?.enabled;\n  return enabled !== true;\n}","tryCatchPattern":"try {\n  await agent.network(input);\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'AGENT_NETWORK_OBSERVATIONAL_MEMORY_UNSUPPORTED') {\n    // fall back to non-network agent.generate() or re-create agent with OM disabled\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["agent-network","observational-memory","memory","configuration"],"backgroundTag":"incompatible-feature-combination","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}