Skip to content

update_agent

update_agent(
    agent_id: Id,
    agent_name: Name,
    agent_resource_role_arn: AgentRoleArn,
    *,
    config_overrides: Optional[BedrockAgentClientConfig] = None,
    instruction: Optional[Instruction] = None,
    foundation_model: Optional[ModelIdentifier] = None,
    description: Optional[Description] = None,
    orchestration_type: Optional[OrchestrationType] = None,
    custom_orchestration: Optional[CustomOrchestration] = None,
    idle_session_ttl_in_seconds: Optional[SessionTTL] = None,
    customer_encryption_key_arn: Optional[KmsKeyArn] = None,
    prompt_override_configuration: Optional[PromptOverrideConfiguration] = None,
    guardrail_configuration: Optional[GuardrailConfiguration] = None,
    memory_configuration: Optional[MemoryConfiguration] = None,
    agent_collaboration: Optional[AgentCollaboration] = None,
) -> UpdateAgentResponse

Updates the configuration of an agent.

Parameters:

  • agent_id (Id) –

    The unique identifier of the agent.

  • agent_name (Name) –

    Specifies a new name for the agent.

  • instruction (Optional[Instruction], default: None ) –

    Specifies new instructions that tell the agent what it should do and how it should interact with users.

  • foundation_model (Optional[ModelIdentifier], default: None ) –

    The identifier for the model that you want to be used for orchestration by the agent you create.

    The modelId to provide depends on the type of model or throughput that you use:

  • description (Optional[Description], default: None ) –

    Specifies a new description of the agent.

  • orchestration_type (Optional[OrchestrationType], default: None ) –

    Specifies the type of orchestration strategy for the agent. This is set to DEFAULT orchestration type, by default.

  • custom_orchestration (Optional[CustomOrchestration], default: None ) –

    Contains details of the custom orchestration configured for the agent.

  • idle_session_ttl_in_seconds (Optional[SessionTTL], default: None ) –

    The number of seconds for which Amazon Bedrock keeps information about a user's conversation with the agent.

    A user interaction remains active for the amount of time specified. If no conversation occurs during this time, the session expires and Amazon Bedrock deletes any data provided before the timeout.

  • agent_resource_role_arn (AgentRoleArn) –

    The Amazon Resource Name (ARN) of the IAM role with permissions to invoke API operations on the agent.

  • customer_encryption_key_arn (Optional[KmsKeyArn], default: None ) –

    The Amazon Resource Name (ARN) of the KMS key with which to encrypt the agent.

  • prompt_override_configuration (Optional[PromptOverrideConfiguration], default: None ) –

    Contains configurations to override prompts in different parts of an agent sequence. For more information, see Advanced prompts.

  • guardrail_configuration (Optional[GuardrailConfiguration], default: None ) –

    The unique Guardrail configuration assigned to the agent when it is updated.

  • memory_configuration (Optional[MemoryConfiguration], default: None ) –

    Specifies the new memory configuration for the agent.

  • agent_collaboration (Optional[AgentCollaboration], default: None ) –

    The agent's collaboration role.

Raises:

Source code in docs_src/capo_bedrock_agent/_services/bedrock_agent.py
def update_agent(
    self,
    agent_id: "capo_bedrock_agent.types.id.Id",
    agent_name: "capo_bedrock_agent.types.name.Name",
    agent_resource_role_arn: "capo_bedrock_agent.types.agent_role_arn.AgentRoleArn",
    *,
    config_overrides: Optional[BedrockAgentClientConfig] = None,
    instruction: Optional[
        "capo_bedrock_agent.types.instruction.Instruction"
    ] = None,
    foundation_model: Optional[
        "capo_bedrock_agent.types.model_identifier.ModelIdentifier"
    ] = None,
    description: Optional[
        "capo_bedrock_agent.types.description.Description"
    ] = None,
    orchestration_type: Optional[
        "capo_bedrock_agent.types.orchestration_type.OrchestrationType"
    ] = None,
    custom_orchestration: Optional[
        "capo_bedrock_agent.types.custom_orchestration.CustomOrchestration"
    ] = None,
    idle_session_ttl_in_seconds: Optional[
        "capo_bedrock_agent.types.session_ttl.SessionTTL"
    ] = None,
    customer_encryption_key_arn: Optional[
        "capo_bedrock_agent.types.kms_key_arn.KmsKeyArn"
    ] = None,
    prompt_override_configuration: Optional[
        "capo_bedrock_agent.types.prompt_override_configuration.PromptOverrideConfiguration"
    ] = None,
    guardrail_configuration: Optional[
        "capo_bedrock_agent.types.guardrail_configuration.GuardrailConfiguration"
    ] = None,
    memory_configuration: Optional[
        "capo_bedrock_agent.types.memory_configuration.MemoryConfiguration"
    ] = None,
    agent_collaboration: Optional[
        "capo_bedrock_agent.types.agent_collaboration.AgentCollaboration"
    ] = None,
) -> "capo_bedrock_agent.types.update_agent_response.UpdateAgentResponse":
    """<p>Updates the configuration of an agent.</p>

    Args:
        agent_id: <p>The unique identifier of the agent.</p>
        agent_name: <p>Specifies a new name for the agent.</p>
        instruction: <p>Specifies new instructions that tell the agent what it should do and how it should interact with users.</p>
        foundation_model: <p>The identifier for the model that you want to be used for orchestration by the agent you create.</p> <p>The <code>modelId</code> to provide depends on the type of model or throughput that you use:</p> <ul> <li> <p>If you use a base model, specify the model ID or its ARN. For a list of model IDs for base models, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html#model-ids-arns">Amazon Bedrock base model IDs (on-demand throughput)</a> in the Amazon Bedrock User Guide.</p> </li> <li> <p>If you use an inference profile, specify the inference profile ID or its ARN. For a list of inference profile IDs, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference-support.html">Supported Regions and models for cross-region inference</a> in the Amazon Bedrock User Guide.</p> </li> <li> <p>If you use a provisioned model, specify the ARN of the Provisioned Throughput. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/prov-thru-use.html">Run inference using a Provisioned Throughput</a> in the Amazon Bedrock User Guide.</p> </li> <li> <p>If you use a custom model, first purchase Provisioned Throughput for it. Then specify the ARN of the resulting provisioned model. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-use.html">Use a custom model in Amazon Bedrock</a> in the Amazon Bedrock User Guide.</p> </li> <li> <p>If you use an <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-import-model.html">imported model</a>, specify the ARN of the imported model. You can get the model ARN from a successful call to <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_CreateModelImportJob.html">CreateModelImportJob</a> or from the Imported models page in the Amazon Bedrock console.</p> </li> </ul>
        description: <p>Specifies a new description of the agent.</p>
        orchestration_type: <p> Specifies the type of orchestration strategy for the agent. This is set to <code>DEFAULT</code> orchestration type, by default. </p>
        custom_orchestration: <p> Contains details of the custom orchestration configured for the agent. </p>
        idle_session_ttl_in_seconds: <p>The number of seconds for which Amazon Bedrock keeps information about a user's conversation with the agent.</p> <p>A user interaction remains active for the amount of time specified. If no conversation occurs during this time, the session expires and Amazon Bedrock deletes any data provided before the timeout.</p>
        agent_resource_role_arn: <p>The Amazon Resource Name (ARN) of the IAM role with permissions to invoke API operations on the agent.</p>
        customer_encryption_key_arn: <p>The Amazon Resource Name (ARN) of the KMS key with which to encrypt the agent.</p>
        prompt_override_configuration: <p>Contains configurations to override prompts in different parts of an agent sequence. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/advanced-prompts.html">Advanced prompts</a>.</p>
        guardrail_configuration: <p>The unique Guardrail configuration assigned to the agent when it is updated.</p>
        memory_configuration: <p>Specifies the new memory configuration for the agent. </p>
        agent_collaboration: <p>The agent's collaboration role.</p>

    Raises:
        capo_bedrock_agent.errors.access_denied_exception.AccessDeniedException: <p>The request is denied because of missing access permissions.</p>
        capo_bedrock_agent.errors.conflict_exception.ConflictException: <p>There was a conflict performing an operation.</p>
        capo_bedrock_agent.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. Retry your request.</p>
        capo_bedrock_agent.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.</p>
        capo_bedrock_agent.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The number of requests exceeds the service quota. Resubmit your request later.</p>
        capo_bedrock_agent.errors.throttling_exception.ThrottlingException: <p>The number of requests exceeds the limit. Resubmit your request later.</p>
        capo_bedrock_agent.errors.validation_exception.ValidationException: <p>Input validation failed. Check your request parameters and retry the request.</p>
        capo_bedrock_agent.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_bedrock_agent.types.update_agent_request.UpdateAgentRequest]",
    ) -> OperationResponse[
        "capo_bedrock_agent.types.update_agent_response.UpdateAgentResponse"
    ]:
        import capo_bedrock_agent._operations.amazon_bedrock_agent_build_time_lambda.update_agent

        output, http_response = (
            capo_bedrock_agent._operations.amazon_bedrock_agent_build_time_lambda.update_agent.update_agent(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_bedrock_agent.types.update_agent_request.UpdateAgentRequest",
    ) -> dict[str, Any]:
        import capo_bedrock_agent.types.update_agent_request

        return capo_bedrock_agent.types.update_agent_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_bedrock_agent.types.update_agent_response.UpdateAgentResponse",
    ) -> dict[str, Any]:
        import capo_bedrock_agent.types.update_agent_response

        return capo_bedrock_agent.types.update_agent_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "UpdateAgent", redact_input=_redact_input, redact_output=_redact_output
        ),
    )
    input_: capo_bedrock_agent.types.update_agent_request.UpdateAgentRequest = {
        "agent_id": agent_id,
        "agent_name": agent_name,
        "agent_resource_role_arn": agent_resource_role_arn,
    }
    if instruction is not None:
        input_["instruction"] = instruction
    if foundation_model is not None:
        input_["foundation_model"] = foundation_model
    if description is not None:
        input_["description"] = description
    if orchestration_type is not None:
        input_["orchestration_type"] = orchestration_type
    if custom_orchestration is not None:
        input_["custom_orchestration"] = custom_orchestration
    if idle_session_ttl_in_seconds is not None:
        input_["idle_session_ttl_in_seconds"] = idle_session_ttl_in_seconds
    if customer_encryption_key_arn is not None:
        input_["customer_encryption_key_arn"] = customer_encryption_key_arn
    if prompt_override_configuration is not None:
        input_["prompt_override_configuration"] = prompt_override_configuration
    if guardrail_configuration is not None:
        input_["guardrail_configuration"] = guardrail_configuration
    if memory_configuration is not None:
        input_["memory_configuration"] = memory_configuration
    if agent_collaboration is not None:
        input_["agent_collaboration"] = agent_collaboration

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output