线程
获取会话线程
通过 OMA API 获取会话线程。
GET
/
v1
/
sessions
/
{session_id}
/
threads
/
{thread_id}
获取会话线程
curl --request GET \
--url http://localhost:38080/v1/sessions/{session_id}/threads/{thread_id} \
--header 'X-Api-Key: <api-key>'import requests
url = "http://localhost:38080/v1/sessions/{session_id}/threads/{thread_id}"
headers = {"X-Api-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-Api-Key': '<api-key>'}};
fetch('http://localhost:38080/v1/sessions/{session_id}/threads/{thread_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:38080/v1/sessions/{session_id}/threads/{thread_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-Api-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"type": "session_thread",
"id": "sthr_011CZkZVWa6oIjw0rgXZpnBt",
"session_id": "sesn_011CZkZAtmR3yMPDzynEDxu7",
"status": "idle",
"agent": {
"type": "agent",
"id": "agent_011CZkYqphY8vELVzwCUpqiQ",
"version": 1,
"name": "Researcher",
"description": "一个专注的调研子智能体。",
"model": {
"id": "claude-sonnet-4-6",
"speed": "standard"
},
"system": "你是一个研究型子智能体,负责为协调智能体收集并总结资料来源。",
"tools": [
{
"type": "agent_toolset_20260401",
"default_config": {
"enabled": true,
"permission_policy": {
"type": "always_ask"
}
},
"configs": []
}
],
"mcp_servers": [],
"skills": []
},
"parent_thread_id": null,
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z",
"archived_at": null,
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
"ephemeral_1h_input_tokens": 0
}
},
"stats": {
"duration_seconds": 0,
"startup_seconds": 0,
"active_seconds": 0
}
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}每个请求都必须发送
?beta=true。授权
omaApiKeyomaBearer
OMA 工作区 API 密钥。
查询参数
为此接口启用 Beta API 合同,必须为 true。
可用选项:
true 响应
请求成功。
session 内的一条执行线程。每个会话有一个主线程,以及由协调器派生的零个或多个子线程。
可用选项:
session_thread 示例:
"session_thread"
此线程的唯一标识符。
示例:
"sthr_011CZkZVWa6oIjw0rgXZpnBt"
此线程所属的会话。
示例:
"sesn_011CZkZAtmR3yMPDzynEDxu7"
线程的当前执行状态。
可用选项:
running, idle, rescheduling, terminated 示例:
"idle"
此线程已解析的智能体定义。线程创建时该智能体的快照。
- Option 1
- Option 2
Show child attributes
Show child attributes
示例:
{
"type": "agent",
"id": "agent_011CZkYqphY8vELVzwCUpqiQ",
"version": 1,
"name": "Researcher",
"description": "一个专注的调研子智能体。",
"model": {
"id": "claude-sonnet-4-6",
"speed": "standard"
},
"system": "你是一个研究型子智能体,负责为协调智能体收集并总结资料来源。",
"tools": [
{
"type": "agent_toolset_20260401",
"default_config": {
"enabled": true,
"permission_policy": { "type": "always_ask" }
},
"configs": []
}
],
"mcp_servers": [],
"skills": []
}
创建此线程的父线程。主线程为 null。
示例:
null
线程创建的时间。
示例:
"2026-03-15T10:00:00Z"
线程的最后更新时间。
示例:
"2026-03-15T10:00:00Z"
线程的归档时间。未归档时为 null。
示例:
null
该线程的累计令牌用量。在线程首次转入空闲之前为 null。
Show child attributes
Show child attributes
示例:
{
"input_tokens": 0,
"output_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
"ephemeral_1h_input_tokens": 0
}
}
该线程的计时统计信息。在线程首次状态转换之前为 null。
Show child attributes
Show child attributes
示例:
{
"duration_seconds": 0,
"startup_seconds": 0,
"active_seconds": 0
}
此页面对您有帮助吗?
⌘I
获取会话线程
curl --request GET \
--url http://localhost:38080/v1/sessions/{session_id}/threads/{thread_id} \
--header 'X-Api-Key: <api-key>'import requests
url = "http://localhost:38080/v1/sessions/{session_id}/threads/{thread_id}"
headers = {"X-Api-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-Api-Key': '<api-key>'}};
fetch('http://localhost:38080/v1/sessions/{session_id}/threads/{thread_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:38080/v1/sessions/{session_id}/threads/{thread_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-Api-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"type": "session_thread",
"id": "sthr_011CZkZVWa6oIjw0rgXZpnBt",
"session_id": "sesn_011CZkZAtmR3yMPDzynEDxu7",
"status": "idle",
"agent": {
"type": "agent",
"id": "agent_011CZkYqphY8vELVzwCUpqiQ",
"version": 1,
"name": "Researcher",
"description": "一个专注的调研子智能体。",
"model": {
"id": "claude-sonnet-4-6",
"speed": "standard"
},
"system": "你是一个研究型子智能体,负责为协调智能体收集并总结资料来源。",
"tools": [
{
"type": "agent_toolset_20260401",
"default_config": {
"enabled": true,
"permission_policy": {
"type": "always_ask"
}
},
"configs": []
}
],
"mcp_servers": [],
"skills": []
},
"parent_thread_id": null,
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z",
"archived_at": null,
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
"ephemeral_1h_input_tokens": 0
}
},
"stats": {
"duration_seconds": 0,
"startup_seconds": 0,
"active_seconds": 0
}
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}