TencentCloud/TencentDB-Agent-Memory · error · ParamError
delete_conversation requires message_ids or session_ids (the
Error message
delete_conversation requires message_ids or session_ids (the constructor session_id is intentionally NOT used for deletes)
What it means
delete_conversation requires explicit targeting via message_ids or session_ids; the constructor-level session_id is deliberately ignored for deletes to prevent accidental wide deletes based on ambient client state. Calling it with neither list raises ParamError.
Source
Thrown at sdk/memory-core/python/tencentdb_agent_memory/v3/client.py:319
操作,若像读接口那样自动带上默认 session,只想按 message_ids 删几条
的调用方会意外把整个会话删掉。要删会话必须显式传 ``session_ids``。
``session_id``(单数)已废弃,保留仅为兼容旧调用方,会合并进
``session_ids``。
"""
normalized_messages = _normalize_delete_ids("message_ids", message_ids, 5000)
normalized_sessions = _normalize_delete_ids("session_ids", session_ids, 100)
if session_id is not None:
if not isinstance(session_id, str) or not session_id.strip():
raise ParamError("session_id must be a non-empty string")
merged = list(normalized_sessions or [])
if session_id.strip() not in merged:
merged.append(session_id.strip())
normalized_sessions = merged
if not normalized_messages and not normalized_sessions:
raise ParamError(
"delete_conversation requires message_ids or session_ids "
"(the constructor session_id is intentionally NOT used for deletes)"
)
return self._stub.post(
f"{_V3}/conversation/delete",
_strip_none({
**self._iso.base_body(),
"message_ids": normalized_messages,
"session_ids": normalized_sessions,
}),
)
def count_conversation(
self,
*,
session_id: Optional[str] = None,
time_start: Optional[str] = None,View on GitHub (pinned to 3efcd317b8)
Solutions
- Pass message_ids=[...] or session_ids=[...] (or session_id=...) explicitly on the call
- If you want constructor-session deletes, pass it again: delete_conversation(session_id=client.session_id)
- Batch by grouping message_ids (≤5000) or session_ids (≤100) per call
- Never rely on ambient client state for destructive operations — this is by design
Example fix
// before client.delete_conversation() # relies on constructor session_id — raises // after client.delete_conversation(session_ids=[client.session_id])
Defensive patterns
Strategy: validation
Validate before calling
def can_delete(message_ids, session_ids, session_id=None):
has_msgs = bool(message_ids)
has_sessions = bool(session_ids) or (isinstance(session_id, str) and session_id.strip())
return has_msgs or has_sessions Try / catch
try:
client.delete_conversation()
except ParamError as e:
if "requires message_ids or session_ids" in str(e):
client.delete_conversation(session_ids=[explicit_session]) Prevention
- Never rely on constructor state for destructive calls — pass filters explicitly
- Wrap delete_conversation in your own function that requires a target argument
- Lint/review for zero-argument delete calls
- Document that constructor session_id is write-scoped only
When it happens
Trigger: delete_conversation() with no arguments, relying on the session_id given at construction; calling with message_ids=None and session_ids=None (or empty lists) and no session_id parameter.
Common situations: Assuming the client's constructor session_id scopes deletes like it scopes add_conversation; generic wrapper code that forwards no filter arguments; scripts intending to 'wipe the current session' without passing it explicitly.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- {field} must contain only non-empty strings
- {field} accepts at most {max_items} items, got {len(deduped)
- v3 MemoryClient requires non-empty {', '.join(missing)} at c
- v3 MemoryClient.add_conversation requires session_id: pass i
- service_id must be provided
AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01).
Data as JSON: /api/errors/7fe3fc4e31e09573.
Report an issue: GitHub.