删除记忆

更新时间:
复制 MD 格式

使用 DeleteMemory 接口删除单条长期记忆。

前提条件

  • 已创建 AgentStorage 实例且状态为 normal,并获取实例访问地址(endpoint)和实例名。

  • 已创建 API Key。

  • Scope 规则:scope 为可选字段,提供时 4 个字段(appId、tenantId、agentId、runId)全部必填,不允许使用通配符 *。

请求参数

字段

类型

必填

说明

memoryStoreName

string

是

记忆库名称。

memoryId

string

是

记忆 ID。

scope

object

否

可选的完整 Scope,用于校验记忆归属;提供时 4 个字段全部必填,不允许使用通配符 *。

请求示例

使用 API Key 认证时,通过 x-ots-instancename 和 x-ots-apikey 请求头传入实例名和 API Key。

curl -X POST https://<endpoint>/DeleteMemory \
  -H "x-ots-instancename: <instance-name>" \
  -H "x-ots-apikey: <your-api-key>" \
  -H "Content-Type: application/json" \
  -d '{"memoryStoreName":"agent_memory","memoryId":"<memory-id>","scope":{"appId":"app-001","tenantId":"user-001","agentId":"assistant","runId":"session-001"}}'

响应

字段

说明

deleted

是否删除成功。

memoryId

被删除的记忆 ID。

memoryStoreName

记忆库名称。

{
  "deleted": true,
  "memoryId": "1b88d0d65a5b6c0d9142e9b7c7347048",
  "memoryStoreName": "agent_memory"
}