List subagents

Updated at:

List a session's subagents and inspect names, status, and lifecycle timestamps.

Endpoint

Returns the session's subagent list. The root agent is not returned as a subagent. Returns 200 on success. The query does not start or resume a subagent, and does not create resources.

GET/agents/sessions/{session_id}/subagents

Path parameters

session_idstringRequired

Session ID, for example sess_xxx

Query parameters

limitintegerOptional

Page size, range 1–100, default 20

orderstringOptional

Sort direction, asc or desc, default desc

afterstringOptional

The last_id from the previous page; the cursor item is excluded

before is ignored and is not used for reverse pagination. Use order and after to page.

Request example

curl --get "$BASE_URL/agents/sessions/sess_xxx/subagents" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  --data-urlencode "limit=20" \
  --data-urlencode "order=asc"
subagents = client.beta.agents.sessions.subagents.list(
    "sess_xxx", limit=20, order="asc"
)
for subagent in subagents.data:
    print(subagent.id, subagent.status)

Response fields

List envelope:

objectstring

List object type, fixed as list

dataarray<Subagent>

Subagents on this page; [] when empty

first_idstring / null

First subagent ID on this page; null for an empty page

last_idstring / null

Last subagent ID on this page; null for an empty page; use it as after

has_moreboolean

Whether the current scan direction has another page

Subagent fields:

active can be idle and waiting; it does not mean the subagent is continuously running. History queries do not start or resume subagents.

data item

idstring

Stable subagent ID

objectstring

Subagent object type, fixed as agent.session.subagent

session_idstring

Owning session

parent_agent_idstring

Parent agent

namestring / null

Display name

instructionsarray / null

Public instruction content

statusstring

Subagent status: active or closed

opened_atinteger

Open time in Unix seconds

closed_atinteger / null

Close time in Unix seconds; null before the subagent is closed

Response example

{
  "object": "list",
  "data": [
    {
      "id": "subagent_xxx",
      "object": "agent.session.subagent",
      "session_id": "sess_xxx",
      "parent_agent_id": "agent_xxx",
      "name": "researcher",
      "instructions": null,
      "status": "active",
      "opened_at": 1794118835,
      "closed_at": null
    }
  ],
  "first_id": "subagent_xxx",
  "last_id": "subagent_xxx",
  "has_more": false
}
{
  "object": "list",
  "data": [],
  "first_id": null,
  "last_id": null,
  "has_more": false
}

Error codes

HTTP statusError type / codeSolution
400invalid_request_error / invalid_request_errorFix limit and order as described in the query parameters; use the last_id returned by the previous page as after
404not_found_error / not_found_errorUse a session ID that exists and has not been deleted in the current workspace
502server_error / agents_api_upstream_unavailableRetry later. If it keeps failing, submit a ticket with the x-request-id from the response headers