# 获取智能体短期记忆 (/zh-CN/api-reference/api-ref/conversational-ai/history)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

获取用户和智能体对话的短期记忆。

- OpenAPI: /openapi/conversational-ai/rest-api.zh-CN.yaml
- Operation ID: get-history
- Method: GET
- Path: /v2/projects/{appid}/agents/{agentId}/history
- Endpoint: https://api.agora.io/cn/api/conversational-ai-agent/v2/projects/{appid}/agents/{agentId}/history

## Servers

- https://api.agora.io/cn/api/conversational-ai-agent

你可以在智能体运行期间 (`RUNNING`) 调用该 API 获取智能体创建到现在储存的短期记忆信息，包括：
- 智能体创建和停止的时间戳
- 用户和智能体对话消息


## Authorization

This endpoint requires authentication.

- `Basic Auth`
- `Agora Token`

## Parameters

No parameters.

## Request body

No request body.

## Responses

### 200

- 若返回的状态码为 `200` 则表示请求成功。响应包体中包含本次请求的结果。
- 若返回的状态码不为 `200` 则表示请求失败。响应包体中包含错误的类别和描述，你可以参考[响应状态码](/zh-CN/api-reference/conversational-ai/rest-api/api/response-code)了解可能的原因。

- `agent_id` (string) - 智能体唯一标识。
- `start_ts` (integer) - 智能体创建时间戳。
- `status` (string) - 智能体运行状态。仅支持查询状态为 `RUNNING` (2)，即正在运行的智能体。
- `contents` (array) - 智能体短期记忆。
  - `contents.items` (object)
    - `contents.items.role` (string) - 消息发送者。可能为以下值：
- `user`：用户。
- `assistant`：智能体。
    - `contents.items.content` (string) - 消息内容。
    - `contents.items.speech_start_ms` (integer) - 说话或 TTS 播报开始时间戳，单位为毫秒（Unix 时间戳）。仅在 `llm.vendor = custom` 时返回。
    - `contents.items.speech_end_ms` (integer) - 说话结束、TTS 播报完成或被打断的时间戳，单位为毫秒（Unix 时间戳）。仅在 `llm.vendor = custom` 时返回。
    - `contents.items.speech_algorithmic_delay` (integer) - 算法处理时延，单位为毫秒。
- 仅当 `llm.vendor = custom`，`contents[].role = user` 且存在实际语音输入时返回。
- 表示音频从用户设备麦克风采集后，经过降噪、背景人声消除、声纹锁定等算法处理引入的总延迟，可用于进一步对齐云录制原始音频的时间戳。

## Response examples

### 200

```json
{
  "agent_id": "xxxx",
  "start_ts": 123,
  "status": "RUNNING",
  "contents": [
    {
      "role": "user",
      "content": "hello."
    },
    {
      "role": "assistant",
      "content": "hi, how can I help you?"
    }
  ]
}
```
