ReplyAgentSession

Updated at:
Copy as MD

Submits the approval choice or question answer for the current pending interaction.

Operation description

  • Read data.sessionId, data.requestId, and data.options from the permission_request notification of PromptAgentSession or LoadAgentSession. This operation uses the interaction ID, not the tool invocation ID or the server-side RequestId.

  • When selecting an action, use the optionId actually provided in the notification. For Q&A scenarios, you must also write the question key and answer text into answers. Do not pass this field for regular tool approvals.

  • accepted=true only indicates that the reply has been accepted. Subsequent output is still read through Prompt/Load. false indicates that the reply is not adopted this time. You should reload the current interaction and not automatically change to approve other requests.

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:ReplyAgentSession

update

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

Jsonrpc

string

No

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

2.0

Id

string

No

The client call identifier used to associate the current response. This parameter does not provide idempotence guarantees.

request-001

Params

any

Yes

The business parameter structure. For core nested fields, see the supplementary description.

{"sessionId":"0123456789abcdef0123456789abcdef","permissionRequestId":"permission-example","outcome":{"outcome":"selected","optionId":"allow_once"}}

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

NameTypeRequiredDescriptionExample
Params.sessionIdstringYesThe ID of the session to which the current interaction belongs.0123456789abcdef0123456789abcdef
Params.permissionRequestIdstringYesThe data.requestId of the current notification.permission-example
Params.outcomeanyYesThe approval choice or cancellation result.{"outcome":"selected","optionId":"allow_once"}
Params.outcome.outcomestringYesselected indicates that an action is selected. cancelled indicates that the current interaction is canceled.selected
Params.outcome.optionIdstringConditionally requiredRequired when outcome=selected. The value is obtained from data.options[].optionId of the current notification.allow_once
Params.answersanyNoThe answer object used in Q&A scenarios. For the actual structure, see the following section.{"0":"Analyze and explain recommendations only. Do not execute code."}

Embedded structure of Params.answers

The actual type is a key-value object Map<string,string>, not an array or any multi-layer JSON. Preferentially use toolCall._meta.qwenAnswerKeys provided in the notification or the answerKey of the question. If the notification does not provide an answer key, fill in the zero-based index string of the question.

NameTypeRequiredDescriptionExample
Params.answers.<question key>stringConditionally requiredFill in this parameter when answering the corresponding question. The key name is subject to the current notification. The answer text of the corresponding question. Multiple-choice answers are still encoded as strings as required by the current interaction. Do not change them to arrays.Analyze and explain recommendations only. Do not execute code.

Only reply to interactions that are still valid this time. The IDs, options, and answer keys in the examples must be replaced with actual notification values. Canceling an interaction is not the same operation as calling CancelAgentSession to cancel execution.

Request examples

Common approval choice. The example assumes that the current notification actually provides allow_once:

{
  "Jsonrpc": "2.0",
  "Id": "request-001",
  "Params": {
    "sessionId": "0123456789abcdef0123456789abcdef",
    "permissionRequestId": "permission-example",
    "outcome": {
      "outcome": "selected",
      "optionId": "allow_once"
    }
  }
}

Cancel the current interaction. Omit optionId and answers:

{
  "Jsonrpc": "2.0",
  "Id": "request-001",
  "Params": {
    "sessionId": "0123456789abcdef0123456789abcdef",
    "permissionRequestId": "permission-example",
    "outcome": {
      "outcome": "cancelled"
    }
  }
}

Answer a question. The example assumes that the current notification provides the answer key 0 and the action allow_once:

{
  "Jsonrpc": "2.0",
  "Id": "request-001",
  "Params": {
    "sessionId": "0123456789abcdef0123456789abcdef",
    "permissionRequestId": "question-example",
    "outcome": {
      "outcome": "selected",
      "optionId": "allow_once"
    },
    "answers": {
      "0": "Analyze and explain recommendations only. Do not execute code."
    }
  }
}

Response elements

Element

Type

Description

Example

object

RequestId

string

The ID of the current request, used for troubleshooting.

0A1B2C3D-4E5F-6789-ABCD-EF0123456789

JsonRpcResponse

any

The JSON-RPC response. For core embedded fields, see the supplementary description.

{"jsonrpc":"2.0","id":"request-001","result":{"accepted":true}}

Success

boolean

Indicates whether the current API call is successful. This parameter cannot replace the business acceptance result.

true

NameTypeDescriptionExample
JsonRpcResponse.jsonrpcstringThe JSON-RPC version.2.0
JsonRpcResponse.idstringThe Id of the echo request.request-001
JsonRpcResponse.resultanyThe reply acceptance result.{"accepted":true}
JsonRpcResponse.result.acceptedbooleantrue indicates adopted, and false indicates not adopted. Neither indicates that the subsequent turn is completed.true

Situations such as the interaction being processed, unknown, or the session being busy may cause accepted=false. Do not automatically change to other approval decisions based on this.

Sample success responses

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

Examples

Success response

JSON format

{
  "RequestId": "0A1B2C3D-4E5F-6789-ABCD-EF0123456789",
  "JsonRpcResponse": "{\"jsonrpc\":\"2.0\",\"id\":\"request-001\",\"result\":{\"accepted\":true}}",
  "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.

See Error CodesError Codes for a complete list.

Release notes

See Release NotesRelease Notes for a complete list.