{"record":{"id":"1a79adb237efa63f","repo":"Mintplex-Labs/anything-llm","slug":"maximum-scope-memory-limit-limit-reached","errorCode":null,"errorMessage":"Maximum ${scope} memory limit (${limit}) reached.","messagePattern":"Maximum (.+?) memory limit \\((.+?)\\) reached\\.","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"server/endpoints/memory.js","lineNumber":91,"sourceCode":"    [\n      validatedRequest,\n      flexUserRoleValid([ROLES.all]),\n      memoryFeatureEnabled,\n      validWorkspaceSlug,\n    ],\n    async (request, response) => {\n      try {\n        const user = await userFromSession(request, response);\n        const workspace = response.locals.workspace;\n        const { content, scope = \"workspace\" } = reqBody(request);\n        const { memory, message } = await Memory.create({\n          userId: user?.id,\n          workspaceId: scope === \"global\" ? null : workspace.id,\n          scope,\n          content: content.trim(),\n        });\n\n        if (!memory) return response.status(400).json({ error: message });\n        response.status(200).json({ memory });\n      } catch (e) {\n        console.error(e);\n        return response.sendStatus(500);\n      }\n    }\n  );\n\n  app.put(\n    \"/memories/:memoryId\",\n    [\n      validatedRequest,\n      flexUserRoleValid([ROLES.all]),\n      memoryFeatureEnabled,\n      validateMemoryOwner,\n    ],\n    async (request, response) => {\n      try {","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/memory.js#L73-L109","documentation":"400 from POST /memories. Memory.create enforces per-scope caps — 5 global per user (GLOBAL_LIMIT) and 20 per user per workspace (WORKSPACE_LIMIT). When countForScope reports count >= limit, no row is written and {memory:null, message} returns, which the endpoint sends as 400. Scope comes from the body (default 'workspace'); counts are per-user in multi-user mode.","triggerScenarios":"POST /memories {content, scope:'workspace'} when that user already holds 20 memories in that workspace, or {scope:'global'} with 5 global memories. Single-user mode counts under userId null.","commonSituations":"Memory extraction pipelines accumulating entries until the cap; users consolidating workspace memories into global and hitting the tighter 5-item cap.","solutions":["Delete or consolidate existing memories in that scope, then retry","Prefer scope:'workspace' (limit 20) when cross-workspace recall is not required","If the product needs more, raise Memory.GLOBAL_LIMIT / Memory.WORKSPACE_LIMIT in server/models/memory.js","Have the client count current memories before offering the 'add memory' action"],"exampleFix":"// before\nawait fetch('/memories', { method: 'POST', body: JSON.stringify({ content, scope }) });\n// after\nconst existing = memories.filter((m) => m.scope === scope);\nconst limit = scope === 'global' ? 5 : 20;\nif (existing.length >= limit) { promptConsolidateOrDelete(); return; }\nawait fetch('/memories', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ content, scope }) });","handlingStrategy":"validation","validationCode":"const LIMITS = { global: 5, workspace: 20 };\nconst inScope = memories.filter((m) => m.scope === scope);\nif (inScope.length >= LIMITS[scope]) throw new Error(`Memory cap (${LIMITS[scope]}) reached — delete or consolidate first`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Show a live counter (n/5 or n/20) in the memory UI","Offer consolidate/delete flows when near the cap","Remember caps are per-user (global) and per-user-per-workspace (workspace)"],"tags":["memory","quota","limit","http-400"],"backgroundTag":"resource-limit-exceeded","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}