Agent

List Session Background Tasks (Extension)

List running and ended background tasks for a session.

GET /agent/v1/sessions/{session_id}/background_tasks● Supported

Request parameters

  • 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.

Returns

200

Own-face extension. Returns { data: BackgroundTask[] }. Each task has id, kind, title, thread_id, status, started_at, ended_at, cancellable, notified_at and trigger_count. Subagent rows link to their child thread via thread_id; other kinds have null. kind is an open string; tolerate unknown kinds. Status is running, result_pending, completed, failed, cancelled or lost. Only completed tasks with pending delivery are result_pending. Timestamps are RFC3339; ended_at is null while running. notified_at is the admission time of the latest system notification batch, or null. trigger_count counts admitted monitor event batches, or is null without records and for other kinds. Only supported running tasks without stop intent are cancellable. Missing or inaccessible sessions return 404.

Errors follow the Anthropic error format (type / message / request_id) — see error codes

Response

HTTP 200

Session background tasks

application/json

NameTypeDescription
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
data[].kindstringKind of background task: bash for a command started with run_in_background, monitor for a Monitor watch.
data[].titlestringShort human-readable title of the task or object.
data[].thread_idstring | nullExecution thread the task belongs to; null for the primary thread.
data[].statusstringCurrent lifecycle state.
data[].started_atstringRFC 3339 time at which the task started.
data[].ended_atstring | nullRFC 3339 time at which the task ended; null while it is running.
data[].cancellablebooleanWhether the task can still be stopped.
data[].notified_atstring | nullRFC 3339 time of the latest run that the task's notification started; null while no notification has been delivered.
data[].trigger_countinteger | nullFor a monitor task, how many times its matches woke the session; null for other kinds or before the first notification.