Retrieve a turn

Updated at:

Retrieve a single root agent turn to inspect status, time boundaries, errors, and token usage.

Endpoint

Returns 200 with a single Turn. The query does not start a model, resume execution, or create resources.

GET/agents/sessions/{session_id}/turns/{turn_id}

Path parameters

session_idstringRequired

Session ID, for example sess_xxx

turn_idstringRequired

Public turn ID, for example turn_xxx

The path hierarchy must match. Turns from another workspace or another caller, and requests whose parent resource does not exist, return no data.

Request example

curl "$BASE_URL/agents/sessions/sess_xxx/turns/turn_xxx" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY"
turn = client.beta.agents.sessions.turns.retrieve(
    "turn_xxx", session_id="sess_xxx"
)
print(turn.status)

Response fields

idstring

Public turn ID

objectstring

Object type, fixed as agent.session.turn

session_idstring

Owning session

agent_idstring

Executing agent

subagent_idstring / null

Subagent ID. null for a root turn

statusstring

Turn status: in_progress, waiting, completed, failed, or cancelled

created_atinteger

Creation time, Unix seconds

started_atinteger / null

Start time

completed_atinteger / null

Completion time

errorobject / null

Turn-level error; null means no error

Properties

codestring

Error code

messagestring

Error description

usageobject / null

Token usage; null when the related counts are incomplete

Properties

input_tokensinteger

Number of input tokens

input_tokens_details

cached_tokensinteger

Number of input tokens that hit the cache

output_tokensinteger

Number of output tokens

output_tokens_details

reasoning_tokensinteger

Number of reasoning tokens

total_tokensinteger

Total number of tokens

usage contains input_tokens, input_tokens_details.cached_tokens, output_tokens, output_tokens_details.reasoning_tokens, and total_tokens. If the related counts are incomplete, the entire usage is null.

waiting is not a successful terminal state. completed, failed, and cancelled are terminal. The SSE turn.created event can show queued; persisted turns start at in_progress.

Response example

{
  "id": "turn_xxx",
  "object": "agent.session.turn",
  "session_id": "sess_xxx",
  "agent_id": "agent_xxx",
  "subagent_id": null,
  "status": "completed",
  "created_at": 1794118835,
  "started_at": 1794118836,
  "completed_at": 1794118840,
  "error": null,
  "usage": {
    "input_tokens": 1024,
    "input_tokens_details": {"cached_tokens": 0},
    "output_tokens": 256,
    "output_tokens_details": {"reasoning_tokens": 64},
    "total_tokens": 1280
  }
}

Error codes

HTTP statusError type / codeSolution
404not_found_error / not_found_errorConfirm that the session and turn exist in the same workspace, and use matching path levels
502server_error / agents_api_upstream_unavailableRetry later. If it keeps failing, submit a ticket with the x-request-id from the response headers