CancelAgentChat

Updated at:

Stops the ongoing agent generation in a specified conversation and clears pending confirmation operations.

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

odps:CancelAgentChat

create

*All Resource

*

None None

Request syntax

POST /api/v1/ai/chat/cancel HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The cancellation request body.

conversationId

string

No

The ID of the conversation to stop.

123456789012****#cn-shanghai#1ee04bea-0488-46b6-b85b-827e3cd37e55

agentType

string

No

The agent type. Valid values: MaxAgent (default, MaxCompute intelligent assistant) and DataAgent (data analytics agent).

DataAgent

expectedTurnId

string

No

The ID of the turn to cancel, which can be up to 128 characters in length. If you specify this parameter, only the run corresponding to this turn is canceled. This prevents accidental cancellation of newly initiated turns in the same conversation. If you do not specify this parameter, the current active run is canceled.

9f8e7d6c5b4a39281706f5e4d3c2b1a0

Response elements

Element

Type

Description

Example

object

PopResult

requestId

string

The request ID, which uniquely identifies the request and can be used for troubleshooting and log correlation.

A3F5B7C9-1D2E-4F6A-8B9C-0D1E2F3A4B5C

httpCode

integer

The business status code. This field is not returned if the call is successful. If the call fails, the corresponding HTTP error code is returned, such as 400, 403, 404, or 500.

400

errorCode

string

The error code. This field is not returned if the call is successful. If the call fails, a specific error code is returned to help identify the cause of the error.

InvalidParameter

errorMsg

string

The error message. This field is not returned if the call is successful. If the call fails, a human-readable error description is returned.

The specified parameter is invalid.

data

object

The cancellation result.

success

boolean

Indicates whether the generation is successfully stopped.

conversationId

string

The conversation ID.

123456789012****#cn-shanghai#1ee04bea-0488-46b6-b85b-827e3cd37e55

openclawCancelled

string

Indicates whether the cancellation request is successfully propagated to the agent runtime.

true

runId

string

The ID of the canceled agent run. An empty string is returned if no active run is canceled.

9f8e7d6c5b4a39281706f5e4d3c2b1a0

reason

string

The reason for the cancellation failure or why no cancellation occurred. An empty string is returned if the cancellation is successful. If expectedTurnId is specified and the turn has already ended, TURN_ENDED is returned.

TURN_ENDED

Examples

Success response

JSON format

{
  "requestId": "A3F5B7C9-1D2E-4F6A-8B9C-0D1E2F3A4B5C",
  "httpCode": 400,
  "errorCode": "InvalidParameter",
  "errorMsg": "The specified parameter is invalid.",
  "data": {
    "success": false,
    "conversationId": "123456789012****#cn-shanghai#1ee04bea-0488-46b6-b85b-827e3cd37e55",
    "openclawCancelled": "true",
    "runId": "9f8e7d6c5b4a39281706f5e4d3c2b1a0",
    "reason": "TURN_ENDED"
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.