LoadAgentSession

Updated at:

Loads the historical messages of an existing agent session and returns them by using Server-Sent Events (SSE) for page refreshes and history recovery after exceptions.

Operation description

Request description

  • This operation recovers the details of a specified session and returns the agent response in a streaming manner by using Server-Sent Events (SSE).

  • If the target session does not exist, an error frame with the error code 400 is returned.

  • The response includes processing information about how the agent handles the request, such as message chunks, thinking process, and tool invocation status updates.

  • The stopReason field indicates the reason why the agent stops the current conversation turn. Valid values include but are not limited to reaching the maximum number of turns and being canceled.

  • The returned content complies with the open source Agent Client Protocol (ACP) specification. For more information, see https://agentclientprotocol.com.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

dataworks:LoadAgentSession

none

*All Resource

*

None None

Request syntax

POST  HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

Jsonrpc

string

No

The JSON-RPC version. The value is fixed to 2.0.

2.0

Id

string

No

The ID passed by the requester. The value is returned as is.

4as3dasf654a

Params

object

No

The business parameters.

Meta

object

No

The ACP extension parameters of DataWorks.

BeginLogOffset

integer

No

Pulls the subsequent SSE output from the specified position in a resumable transfer scenario.

10000

IsReload

boolean

No

Specifies whether this is a resumable transfer scenario. In scenarios where the SSE stream is unstable, such as network instability that causes the SSE connection to drop midway, you can use this flag to pull the SSE response data again from the breakpoint.

true

SessionId

string

No

The ID of the target session. If the session does not exist, an SSE error frame is returned.

sess_0f12abc34

Response elements

Element

Type

Description

Example

object

Error

any

The error message in the SSE frame information. The returned content complies with the open source Agent Client Protocol (ACP) specification. For more information, see https://agentclientprotocol.com/protocol/prompt-turn.

{"code": 400, "errorCode": "0x50000000001", "message": "not exist session", "data": null}

Id

string

The ID passed by the requester. The value is returned as is.

676303114031776

Jsonrpc

string

The JSON-RPC version. The value is fixed to 2.0.

2.0

Method

string

The method of the SSE. The returned content complies with the open source Agent Client Protocol (ACP) specification. For more information, see https://agentclientprotocol.com/protocol/prompt-turn.

session/update

Params

any

The parameters of the SSE. The returned content complies with the open source Agent Client Protocol (ACP) specification. For more information, see https://agentclientprotocol.com/protocol/prompt-turn.

{"sessionId":"af4f5ef8-e8f5-481c-ad1f-94886c6c0aed","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"hello world"}}}

RequestId

string

Id of the request

0D41C608-0C60-5EB0-B986-1460909CF642

Result

any

The result set of the SSE frame. The returned content complies with the open source Agent Client Protocol (ACP) specification. For more information, see https://agentclientprotocol.com/protocol/prompt-turn.

{"stopReason":"end_turn"}

Timestamp

integer

The timestamp.

1769479322828

Examples

Success response

JSON format

{
  "Error": "{\"code\": 400, \"errorCode\": \"0x50000000001\", \"message\": \"not exist session\", \"data\": null}",
  "Id": "676303114031776",
  "Jsonrpc": "2.0",
  "Method": "session/update",
  "Params": "{\"sessionId\":\"af4f5ef8-e8f5-481c-ad1f-94886c6c0aed\",\"update\":{\"sessionUpdate\":\"agent_message_chunk\",\"content\":{\"type\":\"text\",\"text\":\"hello world\"}}}",
  "RequestId": "0D41C608-0C60-5EB0-B986-1460909CF642",
  "Result": "{\"stopReason\":\"end_turn\"}",
  "Timestamp": 1769479322828
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.