GET /sessions/{sid}/messages
获取指定会话的消息列表。
GET /cells/{cellID}/sessions/{sid}/messages
路径参数
| 参数 | 类型 | 说明 |
|---|
cellID | string | Cell ID |
sid | string | 会话 ID |
查询参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|
before | string | 否 | — | 消息 ID,返回此消息之前的消息(向前翻页) |
limit | integer | 否 | 50 | 每页返回条数,范围 1–200 |
curl 示例
curl -s "http://localhost:9091/cells/dept-legal/sessions/ses-a1b2c3d4/messages?limit=20" \
-H "Authorization: Bearer $TOKEN" | jq .
向前翻页(获取更早的消息):
curl -s "http://localhost:9091/cells/dept-legal/sessions/ses-a1b2c3d4/messages?before=msg-001&limit=20" \
-H "Authorization: Bearer $TOKEN" | jq .
响应
200 OK
{
"messages": [
{
"id": "msg-001",
"role": "user",
"content": [
{
"type": "text",
"text": "请审查这份合同的违约条款"
}
],
"turn_num": 1,
"created_at": "2026-09-20T10:30:00Z",
"tool_calls": null
},
{
"id": "msg-002",
"role": "assistant",
"content": [
{
"type": "text",
"text": "我来审查这份合同的违约条款。让我先读取文件内容。"
}
],
"turn_num": 1,
"created_at": "2026-09-20T10:30:05Z",
"tool_calls": [
{
"id": "call-abc123",
"name": "read",
"arguments": "{\"path\": \"/workspace/contract.pdf\"}"
}
]
},
{
"id": "msg-003",
"role": "tool",
"content": [
{
"type": "text",
"text": "{\"content\": \"甲方违约责任:...\"}"
}
],
"turn_num": 1,
"created_at": "2026-09-20T10:30:06Z",
"tool_calls": null
}
]
}
消息对象字段说明:
| 字段 | 类型 | 说明 |
|---|
id | string | 消息唯一标识 |
role | string | 角色:user / assistant / tool / system |
content | ContentBlock[] | 消息内容块数组(含 text / image / file_ref 等类型) |
turn_num | integer | 轮次编号 |
created_at | string | 创建时间(RFC 3339) |
tool_calls | object[] | null | 工具调用列表(仅 assistant 消息可能携带) |
错误码
| HTTP | 错误 | 说明 |
|---|
| 401 | — | 未认证或 Token 无效 |
| 403 | — | 无权访问该会话(Actor 不匹配) |
| 404 | — | Cell 或会话不存在 |
相关端点