TencentCloud/TencentDB-Agent-Memory · error · ParamError
clear_chat_memory requires a non-empty memory_ids list
Error message
clear_chat_memory requires a non-empty memory_ids list
What it means
clear_chat_memory clears 1–100 chat-memory assets identified by memory_ids; after normalization (strip+dedup) the list must be non-empty. An empty or fully-invalid list raises ParamError and no request is sent. Isolation triple is intentionally omitted since scope is defined solely by memory_ids.
Source
Thrown at sdk/memory-core/python/tencentdb_agent_memory/v3/client.py:550
名称、可见性 —— 清空后 Agent 继续用原 ``memory_id`` 写入,无需重建。
与 L0/L1 删除接口不同,本接口是**资产级**操作:
* 作用域由 ``memory_ids`` 自身决定,不使用隔离三元组
* 任一 ``memory_id`` 不存在或不是 chat_memory 时**整批拒绝**,一条都不清
* 幂等:已清空过的再次调用仍返回成功,计数为 0
权限:与其它删除接口一致,内核不做用户级鉴权。若需要"仅 Owner 可清空"
的约束,请走面板后端 ``/api/v1/chat-memory/clear``(那里会校验 Owner)。
失败项会带 ``retryable`` 标志;为 True 表示服务端已自动重试仍未成功,
稍后重试即可补齐残留内容。
:param memory_ids: 待清空的资产 id,1–100 个(自动去重)
"""
normalized = _normalize_delete_ids("memory_ids", memory_ids, 100)
if not normalized:
raise ParamError("clear_chat_memory requires a non-empty memory_ids list")
# 注意:不带隔离三元组 —— 作用域由 memory_ids 决定。
return self._stub.post(f"{_V3}/chat-memory/clear", {"memory_ids": normalized})
# -- Lifecycle ---------------------------------------------------------
def close(self) -> None:
self._stub.close()
def __enter__(self) -> "MemoryClient":
return self
def __exit__(self, *exc: Any) -> None:
self.close()
# ---------------------------------------------------------------------------
# Asynchronous client
# ---------------------------------------------------------------------------View on GitHub (pinned to 3efcd317b8)
Solutions
- Pass 1–100 non-empty memory_ids: clear_chat_memory(memory_ids=["m1","m2"])
- Check the list is non-empty before calling; skip otherwise
- If you intended to clear by conversation, use delete_conversation with session_ids instead
- Deduplicate first so a duplicated id list still passes the 100 cap
Example fix
// before
client.clear_chat_memory(memory_ids=ids_from_query) # may be []
// after
if ids_from_query:
client.clear_chat_memory(memory_ids=ids_from_query) Defensive patterns
Strategy: validation
Validate before calling
def clear_memory_safe(client, memory_ids):
clean = list({m.strip() for m in memory_ids if isinstance(m, str) and m.strip()})
if not clean or len(clean) > 100:
raise ValueError("need 1-100 non-empty memory_ids")
return client.clear_chat_memory(memory_ids=clean) Type guard
def ok_memory_ids(v) -> bool:
return 1 <= len(v) <= 100 and all(isinstance(m, str) and m.strip() for m in v) Try / catch
try:
client.clear_chat_memory(memory_ids=ids)
except ParamError as e:
if "non-empty memory_ids" in str(e):
logger.warning("no memory ids to clear; skipping") Prevention
- Verify the id query returned rows before clearing
- Remember scope comes only from memory_ids — no session/team fallback
- Deduplicate to stay within the 100 cap
- For conversation-wide cleanup use delete_conversation instead
When it happens
Trigger: clear_chat_memory(memory_ids=[]) ; memory_ids containing only empty/whitespace strings; a variable holding ids that turned out empty after dedup.
Common situations: Reset/cleanup jobs whose id query returned no rows; copying the 100-item cap but passing nothing; mistaking clear_chat_memory (id-scoped) for a whole-conversation clear.
Related errors
- {field} must contain only non-empty strings
- session_id must be a non-empty string
- delete_atomic requires a non-empty ids list
- {field} accepts at most {max_items} items, got {len(deduped)
- v3 MemoryClient requires non-empty {', '.join(missing)} at c
AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01).
Data as JSON: /api/errors/45a6c307609a29da.
Report an issue: GitHub.