读取后台任务输出(扩展)
GET
/agent/v1/sessions/{session_id}/background_tasks/{task_id}/output● 支持请求参数
session_idstring必填path: 会话 ID(sesn_...),由 sessions.create 或 sessions.list 返回。资源和线程调用的 session_id 查询参数也接受同一 ID,且必须与路径值一致。
task_idstring必填path: Background task id (task_...), as listed by sessions.background_tasks.list.
offsetinteger可选query: 读取任务输出的字节偏移量;从 0 开始,后续使用上一响应的 next_offset。整数且至少为 0,默认 0。
max_bytesinteger可选query: Maximum number of bytes to return: an integer from 1 to 262144, default 65536.
返回
200
offset 默认 0;max_bytes 默认 65536,上限 262144。返回 text、next_offset、eof。沙箱已暂停或不存在时返回空 text、原 offset、eof=true、unavailable=true。读取不确认模型结果。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
请求示例
curl
curl "https://api.deepraxis.com/agent/v1/sessions/sesn_example/background_tasks/task_example/output?offset=0&max_bytes=65536" \
-H "Authorization: Bearer $PRAXIS_API_KEY"Python
import requests
opts = dict(
base_url="https://api.deepraxis.com/agent",
api_key="$PRAXIS_API_KEY",
)
# /agent 是我们自己的 Managed Agents 形状,直接发 HTTP 请求(Bearer 认证)
resp = requests.get(
f"{opts['base_url']}/v1/sessions/sesn_example/background_tasks/task_example/output?offset=0&max_bytes=65536",
headers={"Authorization": f"Bearer {opts['api_key']}"},
)
print(resp.status_code, resp.json())TypeScript
const opts = {
baseURL: "https://api.deepraxis.com/agent",
apiKey: "$PRAXIS_API_KEY",
};
// /agent 是我们自己的 Managed Agents 形状,直接发 HTTP 请求(Bearer 认证)
const resp = await fetch(`${opts.baseURL}/v1/sessions/sesn_example/background_tasks/task_example/output?offset=0&max_bytes=65536`, {
headers: { Authorization: `Bearer ${opts.apiKey}` },
});
console.log(resp.status, await resp.json());响应示例 200
{
"text": "Build complete.\n",
"next_offset": 16,
"eof": true
}响应
HTTP 200
Background task output byte page
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| text | string | Text of the block. |
| next_offset | integer | Byte offset to pass as offset to continue reading the output. |
| eof | boolean | True when the output has ended and no more bytes will follow. |
| unavailable | boolean | True when the output could not be read; text is then empty. |