TencentCloud/TencentDB-Agent-Memory · error · Error

store does not support clearMemoryContent

Error message

store does not support clearMemoryContent

What it means

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.

Source

Thrown at MemoryCore/src/gateway/chat-memory-handlers.ts:190

 *   - `MetadataService.archiveAgent` —— 清完再删资产(删Agent 场景)
 *
 * 失败向上抛,由调用方决定是标记单条失败还是中止整个流程。
 */
export async function clearChatMemoryContent(args: {
  store: IMemoryStore;
  storage: StorageAdapter;
  teamId: string;
  agentId: string;
}): Promise<{ l0Deleted: number; l1Deleted: number; profileDeleted: number }> {
  // 入口处自校验:这是破坏性操作,且有两个调用方,不能依赖上游都做过校验。
  const teamId = (args.teamId ?? "").trim();
  const agentId = (args.agentId ?? "").trim();
  if (!teamId || !agentId) {
    throw new Error("clearChatMemoryContent requires non-empty teamId and agentId");
  }

  if (typeof args.store.clearMemoryContent !== "function") {
    throw new Error("store does not support clearMemoryContent");
  }
  const result: MemoryContentClearResult = await args.store.clearMemoryContent({
    teamId,
    agentId,
  });
  const filesRemoved = await clearProfileStorage(args.storage, teamId, agentId);
  return {
    l0Deleted: result.l0Deleted,
    l1Deleted: result.l1Deleted,
    profileDeleted: result.profilesDeleted + filesRemoved,
  };
}

/** 清空内容的整体重试次数上限(含首次尝试)。 */
export const CLEAR_MAX_ATTEMPTS = 3;
/** 重试退避基数(毫秒),实际等待为 BASE * 2^(n-1)。 */
const CLEAR_RETRY_BASE_DELAY_MS = 300;

View on GitHub (pinned to 3efcd317b8)

Solutions

  1. Upgrade or update the store adapter to a version that implements clearMemoryContent({ teamId, agentId }): Promise<MemoryContentClearResult>.
  2. Add clearMemoryContent to your custom store class (no-op or real delete), then pass that store in args.store.
  3. Verify you are passing the correct store object (not a config or partial stub) in args.store.
  4. Pre-upgrade guard: feature-check typeof store.clearMemoryContent === 'function' before calling, and handle unsupported stores by skipping the memory-content step.

Example fix

// before
class MyStore { /* no clearMemoryContent */ }
clearChatMemoryContent({ teamId, agentId, store: new MyStore(), storage });
// after
class MyStore {
  async clearMemoryContent({ teamId, agentId }) {
    await this.db.delete('memory_content').where({ team_id: teamId, agent_id: agentId });
  }
}
clearChatMemoryContent({ teamId, agentId, store: new MyStore(), storage });
Defensive patterns

Strategy: type-guard

Validate before calling

if (typeof store?.clearMemoryContent !== 'function') {
  throw new Error('Store does not implement clearMemoryContent; upgrade or skip memory-content clearing');
}

Type guard

function supportsClearMemoryContent(store: unknown): store is { clearMemoryContent: (args: { teamId: string; agentId: string }) => Promise<MemoryContentClearResult> } {
  return typeof (store as any)?.clearMemoryContent === 'function';
}

Try / catch

try {
  await clearChatMemoryContent({ teamId, agentId, store, storage });
} catch (err) {
  if (err.message.includes('does not support clearMemoryContent')) {
    logger.warn('Store lacks clearMemoryContent; skipping memory content clear');
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.


AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01). Data as JSON: /api/errors/9320746fbc47b125. Report an issue: GitHub.