列出记忆任务

更新时间:
复制 MD 格式

使用 ListMemoryTasks 接口列出异步抽取任务。

前提条件

请求参数

字段

类型

必填

说明

memoryStoreName

string

是

记忆库名称。

scope

object

否

Scope,可按层级使用 *;空字段按 __default__ 处理。

status

string

否

任务状态过滤:queued、running、completed、failed 或 needs_reconcile。

limit

int

否

返回数量,默认 50,最大 100。

nextToken

string

否

下一页标记。只能用于与上一页相同的 Scope、状态和时间范围。

minTimestamp

string

否

最小时间,Unix 毫秒时间戳(不支持 RFC3339)。

maxTimestamp

string

否

最大时间,Unix 毫秒时间戳(不支持 RFC3339)。

请求示例

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

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

响应

响应在 tasks 数组中返回任务对象,字段同 GetMemoryTask 的 task,并按 createdAt 从新到旧排列。

{
  "memoryStoreName": "agent_memory",
  "tasks": [
    {
      "requestId": "4b41a912f8c8a66202896e880a505d4a",
      "eventType": "ingest",
      "status": "completed",
      "acceptedMessages": 2,
      "createdAt": "2026-06-17T07:19:59.962Z",
      "updatedAt": "2026-06-17T07:20:08.749Z",
      "finishedAt": "2026-06-17T07:20:08.749Z"
    }
  ],
  "nextToken": "<next-token>"
}
  • 任务列表采用最终一致读取。任务刚创建或状态刚更新时,列表可能短暂缺少该任务或显示旧状态;需要确认单个任务的最新状态时,请调用 GetMemoryTask。列表能力初始化期间可能返回 HTTP 409 和 CONFLICT,请稍后重试。

  • 一次查询的扫描预算用尽时,返回数量可能少于 limit,甚至为空,但仍可能携带 nextToken。调用方应持续翻页,直到 nextToken 为空。

  • 对于同时输出 structured 和 file 的记忆库,同一个 requestId 在列表中只出现一次,status 按 GetMemoryTask 的整体状态规则返回。status 请求参数会分别匹配各输出任务,因此某个输出命中过滤条件时,返回项的整体 status 可能不同于请求中的过滤值;需要确认全部输出是否完成时,应以返回项的整体状态为准。