智能体
列出后台任务(扩展)
读取会话的运行中和已结束后台任务。
GET
/agent/v1/sessions/{session_id}/background_tasks● 支持请求参数
session_idstring必填path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.
返回
200
仅在 /agent/v1 提供。kind 是开放字符串。subagent 行的 thread_id 指向对应子线程,其他 kind 为 null。completed 且 delivery=pending 显示 result_pending。notified_at 是系统通知批次被受理开轮的时间,无则 null。trigger_count 仅监视器返回已受理的事件批次数,无记录则 null。时间为 RFC3339。会话不存在或不可见返回 404。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
响应
HTTP 200
Session background tasks
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Items of this page, in the order requested by the call. |
| data[].id | string | Identifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource. |
| data[].kind | string | Kind of background task: bash for a command started with run_in_background, monitor for a Monitor watch. |
| data[].title | string | Short human-readable title of the task or object. |
| data[].thread_id | string | null | Execution thread the task belongs to; null for the primary thread. |
| data[].status | string | Current lifecycle state. |
| data[].started_at | string | RFC 3339 time at which the task started. |
| data[].ended_at | string | null | RFC 3339 time at which the task ended; null while it is running. |
| data[].cancellable | boolean | Whether the task can still be stopped. |
| data[].notified_at | string | null | RFC 3339 time of the latest run that the task's notification started; null while no notification has been delivered. |
| data[].trigger_count | integer | null | For a monitor task, how many times its matches woke the session; null for other kinds or before the first notification. |