DeleteAgentSession

Updated at:
Copy as MD

Deletes an idle session that is no longer needed.

Operation description

A session cannot be directly deleted while it is being executed or waiting for interaction. You must first call CancelAgentSession and continue reading the original response stream, or resume reading through LoadAgentSession. Delete the session only after confirming that the target turn has ended.

A successful deletion indicates that the session deletion operation is complete, but it does not mean that external operations that have already occurred are rolled back. Deleting a session does not delete the associated agent or assistant.

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

ada:DeleteAgentSession

delete

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

Jsonrpc

string

No

The JSON-RPC protocol version. Set this parameter to 2.0.

2.0

Id

string

No

The correlation identifier for this call, which is echoed in the response. This parameter does not provide idempotence guarantees.

request-001

Params

any

Yes

The business parameter object. For nested fields, refer to the supplementary description of request parameters.

{"sessionId":"0123456789abcdef0123456789abcdef"}

The call method is POST, and the business parameters are located in formData. The example shows only the business parameters. Action, Version, signature, and identity information are handled by the POP client. The region is determined by the client configuration. Structure fields are serialized once as required by the SDK.

NameTypeRequiredDescriptionExample
Params.sessionIdstringYesThe ID of the session to be deleted.0123456789abcdef0123456789abcdef

Request example

{
  "Jsonrpc": "2.0",
  "Id": "request-001",
  "Params": {
    "sessionId": "0123456789abcdef0123456789abcdef"
  }
}

Response elements

Element

Type

Description

Example

object

RequestId

string

The server-side request ID, which is used to troubleshoot this call.

0A1B2C3D-4E5F-6789-ABCD-EF0123456789

JsonRpcResponse

any

The response object. The business result is located in result.

{"jsonrpc":"2.0","id":"request-001","result":{"sessionId":"0123456789abcdef0123456789abcdef"}}

Success

boolean

Indicates whether the operation is successful. Determine the final execution state based on the description of this operation.

true

Optional fields may not be returned. Refer to the actual response.

NameTypeDescriptionExample
JsonRpcResponse.jsonrpcstringThe JSON-RPC protocol version.2.0
JsonRpcResponse.idstringThe call identifier corresponding to the request Id.request-001
JsonRpcResponse.resultanyThe deletion result.{"sessionId":"0123456789abcdef0123456789abcdef"}
JsonRpcResponse.result.sessionIdstringThe ID of the deleted session.0123456789abcdef0123456789abcdef

If AgentSession.SessionBusy is returned, process the turn that is still being executed or waiting for interaction before retrying the deletion. Retain the original sessionId when the request result is unknown to avoid retrying for other sessions.

Sample success response

{
  "RequestId": "0A1B2C3D-4E5F-6789-ABCD-EF0123456789",
  "Success": true,
  "JsonRpcResponse": {
    "jsonrpc": "2.0",
    "id": "request-001",
    "result": {
      "sessionId": "0123456789abcdef0123456789abcdef"
    }
  }
}

Examples

Success response

JSON format

{
  "RequestId": "0A1B2C3D-4E5F-6789-ABCD-EF0123456789",
  "JsonRpcResponse": "{\"jsonrpc\":\"2.0\",\"id\":\"request-001\",\"result\":{\"sessionId\":\"0123456789abcdef0123456789abcdef\"}}",
  "Success": true
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameter The specified parameter is invalid.
401 Unauthenticated Authentication required.
500 InternalError Internal server error.
403 Forbidden You are not authorized to perform this operation.
404 AgentSession.SessionNotFound The specified agent session does not exist.
503 ServiceUnavailable The service is not ready or temporarily unavailable.
409 AgentSession.SessionBusy A turn is already running in the agent session.

See Error CodesError Codes for a complete list.

Release notes

See Release NotesRelease Notes for a complete list.