CreateAgentActionGroup
Creates an action group for an agent. An action group represents the actions that an agent can carry out for the customer by defining the APIs that an agent can call and the logic for calling them.
To allow your agent to request the user for additional information when trying to complete a task,
add an action group with the parentActionGroupSignature
field set to AMAZON.UserInput
.
To allow your agent to generate, run, and troubleshoot code when trying to complete a task,
add an action group with the parentActionGroupSignature
field set to AMAZON.CodeInterpreter
.
You must leave the description
, apiSchema
, and actionGroupExecutor
fields blank for this action group. During orchestration, if your agent determines that it needs to invoke an API in an action group, but doesn't have enough information to complete the API request, it will invoke this action group instead and return an Observation reprompting the user for more information.
Request Syntax
PUT /agents/agentId
/agentversions/agentVersion
/actiongroups/ HTTP/1.1
Content-type: application/json
{
"actionGroupExecutor": { ... },
"actionGroupName": "string
",
"actionGroupState": "string
",
"apiSchema": { ... },
"clientToken": "string
",
"description": "string
",
"functionSchema": { ... },
"parentActionGroupSignature": "string
"
}
URI Request Parameters
The request uses the following URI parameters.
- agentId
-
The unique identifier of the agent for which to create the action group.
Pattern:
^[0-9a-zA-Z]{10}$
Required: Yes
- agentVersion
-
The version of the agent for which to create the action group.
Length Constraints: Fixed length of 5.
Pattern:
^DRAFT$
Required: Yes
Request Body
The request accepts the following data in JSON format.
- actionGroupExecutor
-
The Amazon Resource Name (ARN) of the Lambda function containing the business logic that is carried out upon invoking the action or the custom control method for handling the information elicited from the user.
Type: ActionGroupExecutor object
Note: This object is a Union. Only one member of this object can be specified or returned.
Required: No
- actionGroupName
-
The name to give the action group.
Type: String
Pattern:
^([0-9a-zA-Z][_-]?){1,100}$
Required: Yes
- actionGroupState
-
Specifies whether the action group is available for the agent to invoke or not when sending an InvokeAgent request.
Type: String
Valid Values:
ENABLED | DISABLED
Required: No
- apiSchema
-
Contains either details about the S3 object containing the OpenAPI schema for the action group or the JSON or YAML-formatted payload defining the schema. For more information, see Action group OpenAPI schemas.
Type: APISchema object
Note: This object is a Union. Only one member of this object can be specified or returned.
Required: No
- clientToken
-
A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see Ensuring idempotency.
Type: String
Length Constraints: Minimum length of 33. Maximum length of 256.
Pattern:
^[a-zA-Z0-9](-*[a-zA-Z0-9]){0,256}$
Required: No
- description
-
A description of the action group.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 200.
Required: No
- functionSchema
-
Contains details about the function schema for the action group or the JSON or YAML-formatted payload defining the schema.
Type: FunctionSchema object
Note: This object is a Union. Only one member of this object can be specified or returned.
Required: No
- parentActionGroupSignature
-
To allow your agent to request the user for additional information when trying to complete a task, set this field to
AMAZON.UserInput
. You must leave thedescription
,apiSchema
, andactionGroupExecutor
fields blank for this action group.To allow your agent to generate, run, and troubleshoot code when trying to complete a task, set this field to
AMAZON.CodeInterpreter
. You must leave thedescription
,apiSchema
, andactionGroupExecutor
fields blank for this action group.During orchestration, if your agent determines that it needs to invoke an API in an action group, but doesn't have enough information to complete the API request, it will invoke this action group instead and return an Observation reprompting the user for more information.
Type: String
Valid Values:
AMAZON.UserInput | AMAZON.CodeInterpreter
Required: No
Response Syntax
HTTP/1.1 200
Content-type: application/json
{
"agentActionGroup": {
"actionGroupExecutor": { ... },
"actionGroupId": "string",
"actionGroupName": "string",
"actionGroupState": "string",
"agentId": "string",
"agentVersion": "string",
"apiSchema": { ... },
"clientToken": "string",
"createdAt": "string",
"description": "string",
"functionSchema": { ... },
"parentActionSignature": "string",
"updatedAt": "string"
}
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- agentActionGroup
-
Contains details about the action group that was created.
Type: AgentActionGroup object
Errors
For information about the errors that are common to all actions, see Common Errors.
- AccessDeniedException
-
The request is denied because of missing access permissions.
HTTP Status Code: 403
- ConflictException
-
There was a conflict performing an operation.
HTTP Status Code: 409
- InternalServerException
-
An internal server error occurred. Retry your request.
HTTP Status Code: 500
- ResourceNotFoundException
-
The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.
HTTP Status Code: 404
- ServiceQuotaExceededException
-
The number of requests exceeds the service quota. Resubmit your request later.
HTTP Status Code: 402
- ThrottlingException
-
The number of requests exceeds the limit. Resubmit your request later.
HTTP Status Code: 429
- ValidationException
-
Input validation failed. Check your request parameters and retry the request.
HTTP Status Code: 400
Examples
Create an action group using an OpenAPI schema and a Lambda function
The following example creates an action group using an OpenAPI schema uploaded to an Amazon S3 bucket and sends the information elicited from the user to a Lambda function.
PUT /agents/AGENT12345/agentversions/DRAFT/actiongroups/ HTTP/1.1 Content-type: application/json { "actionGroupName": "Test Action", "actionGroupState": "ENABLED", "apiSchema": { "s3": { "s3BucketName": "apischema-s3", "s3ObjectKey": "it_agent_openapi.json" } }, "description": "Testing latest IT Management action", "actionGroupExecutor": { "lambda": "arn:aws:lambda:us-west-2:123456789012:function:ItAgentLambda" } }
Create an action group using an OpenAPI schema and return control
The following example creates an action group using an OpenAPI schema uploaded to an Amazon S3 bucket and returns control by sending the information in the InvokeAgent
response.
{ "actionGroupName": "WeatherAPIs", "description": "Actions to get current weather and historical trends for a location", "actionGroupState": "ENABLED", "apiSchema": { "s3": { "s3BucketName": "openapi-spec-iad", "s3ObjectKey": "get_weather_openapi.yaml" } }, "actionGroupExecutor": { "customControl": "RETURN_CONTROL" } }
Create an action group using function details and return control
The following example creates an action group using function details and returns control by sending the information in the InvokeAgent
response
PUT /agents/AGENT12345/agentversions/DRAFT/actiongroups/ HTTP/1.1 Content-type: application/json { "actionGroupName": "OrderManagementAction", "description": "Action to get the order history, product details, product availability and to update the order", "actionGroupState": "ENABLED", "actionGroupExecutor": { "customControl": "RETURN_CONTROL" }, "functionSchema": { "functions": [{ "name": "GetOrderDetails", "description": "Retrieves the order history for a given OrderId and returns productId, color, productName, size, productType, quantity, and status." "parameters": { "orderId": { "type": "string", "required": true } } }] } }
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: