会话
获取会话
通过 OMA API 获取会话。
GET
/
v1
/
sessions
/
{session_id}
获取会话
curl --request GET \
--url http://localhost:38080/v1/sessions/{session_id} \
--header 'X-Api-Key: <api-key>'import requests
url = "http://localhost:38080/v1/sessions/{session_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}', 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}"
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",
"id": "sesn_011CZkZAtmR3yMPDzynEDxu7",
"status": "idle",
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z",
"archived_at": null,
"budget": null,
"environment_id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
"title": "订单 #1234 咨询",
"metadata": {},
"agent": {
"type": "agent",
"id": "agent_011CZkYpogX7uDKUyvBTophP",
"version": 1,
"name": "我的第一个智能体",
"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": [
{
"type": "url",
"name": "example-mcp",
"url": "https://example-server.modelcontextprotocol.io/sse"
}
],
"skills": [
{
"type": "anthropic",
"skill_id": "xlsx",
"version": "1"
},
{
"type": "custom",
"skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
"version": "2"
}
],
"multiagent": null
},
"resources": [
{
"type": "file",
"id": "sesrsc_011CZkZBJq5dWxk9fVLNcPht",
"file_id": "file_011CNha8iCJcU1wXNR6q4V8w",
"mount_path": "/uploads/receipt.pdf",
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z"
},
{
"type": "github_repository",
"id": "sesrsc_011CZkZCKr6eXyl0gWMOdQiu",
"url": "https://github.com/example-org/example-repo",
"mount_path": "/workspace/example-repo",
"checkout": {
"type": "branch",
"name": "main"
},
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z"
}
],
"vault_ids": [
"vlt_011CZkZDLs7fYzm1hXNPeRjv"
],
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"cache_read_input_tokens": 0
},
"stats": {
"duration_seconds": 0,
"active_seconds": 0
},
"outcome_evaluations": [
{
"type": "outcome_evaluation",
"outcome_id": "outc_011CZkZRSw2kEfs6ncTVljxP",
"description": "生成一份 2 页的摘要并保存为 summary.md",
"result": "satisfied",
"iteration": 0,
"completed_at": "2026-03-15T10:02:31Z",
"explanation": "五个部分均已完成,并包含行内引用。"
}
]
}{
"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 示例:
"session"
示例:
"sesn_011CZkZAtmR3yMPDzynEDxu7"
会话状态枚举
可用选项:
rescheduling, running, idle, terminated 示例:
"idle"
RFC 3339 格式的时间戳
示例:
"2026-03-15T10:00:00Z"
RFC 3339 格式的时间戳
示例:
"2026-03-15T10:00:00Z"
示例:
"env_011CZkZ9X2dpNyB7HsEFoRfW"
示例:
"订单 #1234 咨询"
Show child attributes
Show child attributes
示例:
{ "key": "value" }
已解析的 session 所用 agent 定义。session 创建时该 agent 的快照。
Show child attributes
Show child attributes
示例:
{
"type": "agent",
"id": "agent_011CZkYpogX7uDKUyvBTophP",
"version": 1,
"name": "我的第一个智能体",
"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": [
{
"type": "url",
"name": "example-mcp",
"url": "https://example-server.modelcontextprotocol.io/sse"
}
],
"skills": [
{
"type": "anthropic",
"skill_id": "xlsx",
"version": "1"
},
{
"type": "custom",
"skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
"version": "2"
}
],
"multiagent": null
}
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
示例:
{
"type": "github_repository",
"id": "sesrsc_011CZkZCKr6eXyl0gWMOdQiu",
"url": "https://github.com/example-org/example-repo",
"mount_path": "/workspace/example-repo",
"checkout": { "type": "branch", "name": "main" },
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z"
}
示例:
[
{
"type": "file",
"id": "sesrsc_011CZkZBJq5dWxk9fVLNcPht",
"file_id": "file_011CNha8iCJcU1wXNR6q4V8w",
"mount_path": "/uploads/receipt.pdf",
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z"
},
{
"type": "github_repository",
"id": "sesrsc_011CZkZCKr6eXyl0gWMOdQiu",
"url": "https://github.com/example-org/example-repo",
"mount_path": "/workspace/example-repo",
"checkout": { "type": "branch", "name": "main" },
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z"
}
]
创建时附加到会话的密钥库 ID 列表。未提供密钥库时为空。
示例:
["vlt_011CZkZDLs7fYzm1hXNPeRjv"]
按结果划分的评估状态。发送给会话的每个 define_outcome 事件对应一个条目。
Show child attributes
Show child attributes
示例:
[
{
"type": "outcome_evaluation",
"outcome_id": "outc_011CZkZRSw2kEfs6ncTVljxP",
"description": "生成一份 2 页的摘要并保存为 summary.md",
"result": "satisfied",
"iteration": 0,
"completed_at": "2026-03-15T10:02:31Z",
"explanation": "五个部分均已完成,并包含行内引用。"
}
]
会话的累计令牌用量。
Show child attributes
Show child attributes
示例:
{
"input_tokens": 0,
"output_tokens": 0,
"cache_read_input_tokens": 0
}
该会话的计时统计信息。
Show child attributes
Show child attributes
示例:
{
"duration_seconds": 0,
"active_seconds": 0
}
会话的归档时间。未归档时为 null。
示例:
null
会话强制执行的花费上限;未设置预算时为 null。
Show child attributes
Show child attributes
示例:
null
当会话由部署引用创建时对应的部署 ID。否则为 Null。
此页面对您有帮助吗?
⌘I
获取会话
curl --request GET \
--url http://localhost:38080/v1/sessions/{session_id} \
--header 'X-Api-Key: <api-key>'import requests
url = "http://localhost:38080/v1/sessions/{session_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}', 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}"
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",
"id": "sesn_011CZkZAtmR3yMPDzynEDxu7",
"status": "idle",
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z",
"archived_at": null,
"budget": null,
"environment_id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
"title": "订单 #1234 咨询",
"metadata": {},
"agent": {
"type": "agent",
"id": "agent_011CZkYpogX7uDKUyvBTophP",
"version": 1,
"name": "我的第一个智能体",
"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": [
{
"type": "url",
"name": "example-mcp",
"url": "https://example-server.modelcontextprotocol.io/sse"
}
],
"skills": [
{
"type": "anthropic",
"skill_id": "xlsx",
"version": "1"
},
{
"type": "custom",
"skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
"version": "2"
}
],
"multiagent": null
},
"resources": [
{
"type": "file",
"id": "sesrsc_011CZkZBJq5dWxk9fVLNcPht",
"file_id": "file_011CNha8iCJcU1wXNR6q4V8w",
"mount_path": "/uploads/receipt.pdf",
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z"
},
{
"type": "github_repository",
"id": "sesrsc_011CZkZCKr6eXyl0gWMOdQiu",
"url": "https://github.com/example-org/example-repo",
"mount_path": "/workspace/example-repo",
"checkout": {
"type": "branch",
"name": "main"
},
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z"
}
],
"vault_ids": [
"vlt_011CZkZDLs7fYzm1hXNPeRjv"
],
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"cache_read_input_tokens": 0
},
"stats": {
"duration_seconds": 0,
"active_seconds": 0
},
"outcome_evaluations": [
{
"type": "outcome_evaluation",
"outcome_id": "outc_011CZkZRSw2kEfs6ncTVljxP",
"description": "生成一份 2 页的摘要并保存为 summary.md",
"result": "satisfied",
"iteration": 0,
"completed_at": "2026-03-15T10:02:31Z",
"explanation": "五个部分均已完成,并包含行内引用。"
}
]
}{
"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"
}