createAgentActionGroup method

Future<CreateAgentActionGroupResponse> createAgentActionGroup({
  1. required String actionGroupName,
  2. required String agentId,
  3. required String agentVersion,
  4. ActionGroupExecutor? actionGroupExecutor,
  5. ActionGroupState? actionGroupState,
  6. APISchema? apiSchema,
  7. String? clientToken,
  8. String? description,
  9. FunctionSchema? functionSchema,
  10. ActionGroupSignature? parentActionGroupSignature,
  11. Map<String, String>? parentActionGroupSignatureParams,
})

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.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter actionGroupName : The name to give the action group.

Parameter agentId : The unique identifier of the agent for which to create the action group.

Parameter agentVersion : The version of the agent for which to create the action group.

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

Parameter actionGroupState : Specifies whether the action group is available for the agent to invoke or not when sending an InvokeAgent request.

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

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

Parameter description : A description of the action group.

Parameter functionSchema : Contains details about the function schema for the action group or the JSON or YAML-formatted payload defining the schema.

Parameter parentActionGroupSignature : Specify a built-in or computer use action for this action group. If you specify a value, you must leave the description, apiSchema, and actionGroupExecutor fields empty for this action group.

  • To allow your agent to request the user for additional information when trying to complete a task, set this field to AMAZON.UserInput.
  • To allow your agent to generate, run, and troubleshoot code when trying to complete a task, set this field to AMAZON.CodeInterpreter.
  • To allow your agent to use an Anthropic computer use tool, specify one of the following values.
    • ANTHROPIC.Computer - Gives the agent permission to use the mouse and keyboard and take screenshots.
    • ANTHROPIC.TextEditor - Gives the agent permission to view, create and edit files.
    • ANTHROPIC.Bash - Gives the agent permission to run commands in a bash shell.

Parameter parentActionGroupSignatureParams : The configuration settings for a computer use action.

Implementation

Future<CreateAgentActionGroupResponse> createAgentActionGroup({
  required String actionGroupName,
  required String agentId,
  required String agentVersion,
  ActionGroupExecutor? actionGroupExecutor,
  ActionGroupState? actionGroupState,
  APISchema? apiSchema,
  String? clientToken,
  String? description,
  FunctionSchema? functionSchema,
  ActionGroupSignature? parentActionGroupSignature,
  Map<String, String>? parentActionGroupSignatureParams,
}) async {
  final $payload = <String, dynamic>{
    'actionGroupName': actionGroupName,
    if (actionGroupExecutor != null)
      'actionGroupExecutor': actionGroupExecutor,
    if (actionGroupState != null) 'actionGroupState': actionGroupState.value,
    if (apiSchema != null) 'apiSchema': apiSchema,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (description != null) 'description': description,
    if (functionSchema != null) 'functionSchema': functionSchema,
    if (parentActionGroupSignature != null)
      'parentActionGroupSignature': parentActionGroupSignature.value,
    if (parentActionGroupSignatureParams != null)
      'parentActionGroupSignatureParams': parentActionGroupSignatureParams,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri:
        '/agents/${Uri.encodeComponent(agentId)}/agentversions/${Uri.encodeComponent(agentVersion)}/actiongroups/',
    exceptionFnMap: _exceptionFns,
  );
  return CreateAgentActionGroupResponse.fromJson(response);
}