{"record":{"id":"9320746fbc47b125","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"store-does-not-support-clearmemorycontent","errorCode":null,"errorMessage":"store does not support clearMemoryContent","messagePattern":"store does not support clearMemoryContent","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"MemoryCore/src/gateway/chat-memory-handlers.ts","lineNumber":190,"sourceCode":" *   - `MetadataService.archiveAgent` —— 清完再删资产（删Agent 场景）\n *\n * 失败向上抛，由调用方决定是标记单条失败还是中止整个流程。\n */\nexport async function clearChatMemoryContent(args: {\n  store: IMemoryStore;\n  storage: StorageAdapter;\n  teamId: string;\n  agentId: string;\n}): Promise<{ l0Deleted: number; l1Deleted: number; profileDeleted: number }> {\n  // 入口处自校验：这是破坏性操作，且有两个调用方，不能依赖上游都做过校验。\n  const teamId = (args.teamId ?? \"\").trim();\n  const agentId = (args.agentId ?? \"\").trim();\n  if (!teamId || !agentId) {\n    throw new Error(\"clearChatMemoryContent requires non-empty teamId and agentId\");\n  }\n\n  if (typeof args.store.clearMemoryContent !== \"function\") {\n    throw new Error(\"store does not support clearMemoryContent\");\n  }\n  const result: MemoryContentClearResult = await args.store.clearMemoryContent({\n    teamId,\n    agentId,\n  });\n  const filesRemoved = await clearProfileStorage(args.storage, teamId, agentId);\n  return {\n    l0Deleted: result.l0Deleted,\n    l1Deleted: result.l1Deleted,\n    profileDeleted: result.profilesDeleted + filesRemoved,\n  };\n}\n\n/** 清空内容的整体重试次数上限（含首次尝试）。 */\nexport const CLEAR_MAX_ATTEMPTS = 3;\n/** 重试退避基数（毫秒），实际等待为 BASE * 2^(n-1)。 */\nconst CLEAR_RETRY_BASE_DELAY_MS = 300;\n","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryCore/src/gateway/chat-memory-handlers.ts#L172-L208","documentation":"clearChatMemoryContent requires the injected store object to implement clearMemoryContent. The gateway feature-detects it with typeof args.store.clearMemoryContent !== \"function\" and throws when the store adapter is an older or minimal implementation lacking the capability. It is a capability-check, not a runtime failure of the clear itself.","triggerScenarios":"Calling clearChatMemoryContent({ teamId, agentId, store, storage }) where store lacks a clearMemoryContent method — e.g. passing a custom store adapter, a legacy store version, or the wrong object (plain object / partial store) as store.","commonSituations":"Custom IChatMemoryStore implementations written before clearMemoryContent was added to the interface; teams swapping a full store (e.g. PostgreSQL) for a slim in-memory/test store; a refactor that passes the wrong dependency into args.store; stale builds where store code predates the gateway handler.","solutions":["Upgrade or update the store adapter to a version that implements clearMemoryContent({ teamId, agentId }): Promise<MemoryContentClearResult>.","Add clearMemoryContent to your custom store class (no-op or real delete), then pass that store in args.store.","Verify you are passing the correct store object (not a config or partial stub) in args.store.","Pre-upgrade guard: feature-check typeof store.clearMemoryContent === 'function' before calling, and handle unsupported stores by skipping the memory-content step."],"exampleFix":"// before\nclass MyStore { /* no clearMemoryContent */ }\nclearChatMemoryContent({ teamId, agentId, store: new MyStore(), storage });\n// after\nclass MyStore {\n  async clearMemoryContent({ teamId, agentId }) {\n    await this.db.delete('memory_content').where({ team_id: teamId, agent_id: agentId });\n  }\n}\nclearChatMemoryContent({ teamId, agentId, store: new MyStore(), storage });","handlingStrategy":"type-guard","validationCode":"if (typeof store?.clearMemoryContent !== 'function') {\n  throw new Error('Store does not implement clearMemoryContent; upgrade or skip memory-content clearing');\n}","typeGuard":"function supportsClearMemoryContent(store: unknown): store is { clearMemoryContent: (args: { teamId: string; agentId: string }) => Promise<MemoryContentClearResult> } {\n  return typeof (store as any)?.clearMemoryContent === 'function';\n}","tryCatchPattern":"try {\n  await clearChatMemoryContent({ teamId, agentId, store, storage });\n} catch (err) {\n  if (err.message.includes('does not support clearMemoryContent')) {\n    logger.warn('Store lacks clearMemoryContent; skipping memory content clear');\n    return;\n  }\n  throw err;\n}","preventionTips":["Implement every method of the current IChatMemoryStore interface in custom adapters","Feature-check store capabilities before invoking capability-gated handlers","Keep store adapters and the gateway package on matching versions","Add a unit test that exercises clearChatMemoryContent against your store"],"tags":["capability-check","store-adapter","memory"],"backgroundTag":"missing-store-capability","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}