Skip to content

update_harness

update_harness(
    harness_id: HarnessId,
    *,
    config_overrides: Optional[BedrockAgentCoreControlClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    execution_role_arn: Optional[RoleArn] = None,
    environment: Optional[HarnessEnvironmentProviderRequest] = None,
    environment_artifact: Optional[UpdatedHarnessEnvironmentArtifact] = None,
    environment_variables: Optional[EnvironmentVariablesMap] = None,
    authorizer_configuration: Optional[UpdatedAuthorizerConfiguration] = None,
    model: Optional[HarnessModelConfiguration] = None,
    system_prompt: Optional[HarnessSystemPrompt] = None,
    tools: Optional[HarnessTools] = None,
    skills: Optional[HarnessSkills] = None,
    allowed_tools: Optional[HarnessAllowedTools] = None,
    memory: Optional[UpdatedHarnessMemoryConfiguration] = None,
    truncation: Optional[HarnessTruncationConfiguration] = None,
    hooks: Optional[HarnessHooks] = None,
    max_iterations: Optional[int] = None,
    max_tokens: Optional[int] = None,
    timeout_seconds: Optional[int] = None,
) -> UpdateHarnessResponse

Operation to update a harness.

Parameters:

  • harness_id (HarnessId) –

    The ID of the harness to update.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier to ensure idempotency of the request.

  • execution_role_arn (Optional[RoleArn], default: None ) –

    The ARN of the IAM role that the harness assumes when running. If not specified, the existing value is retained.

  • environment (Optional[HarnessEnvironmentProviderRequest], default: None ) –

    The compute environment configuration for the harness. If not specified, the existing value is retained.

  • environment_artifact (Optional[UpdatedHarnessEnvironmentArtifact], default: None ) –

    The environment artifact for the harness. Use the optionalValue wrapper to set a new value, or set it to null to clear the existing configuration.

  • environment_variables (Optional[EnvironmentVariablesMap], default: None ) –

    Environment variables to set in the harness runtime environment. If specified, this replaces all existing environment variables. If not specified, the existing value is retained.

  • model (Optional[HarnessModelConfiguration], default: None ) –

    The model configuration for the harness. If not specified, the existing value is retained.

  • system_prompt (Optional[HarnessSystemPrompt], default: None ) –

    The system prompt that defines the agent's behavior. If not specified, the existing value is retained.

  • tools (Optional[HarnessTools], default: None ) –

    The tools available to the agent. If specified, this replaces all existing tools. If not specified, the existing value is retained.

  • skills (Optional[HarnessSkills], default: None ) –

    The skills available to the agent. If specified, this replaces all existing skills. If not specified, the existing value is retained.

  • allowed_tools (Optional[HarnessAllowedTools], default: None ) –

    The tools that the agent is allowed to use. If specified, this replaces all existing allowed tools. If not specified, the existing value is retained.

  • memory (Optional[UpdatedHarnessMemoryConfiguration], default: None ) –

    The AgentCore Memory configuration. Use the optionalValue wrapper to set a new value, or set it to null to clear the existing configuration.

  • truncation (Optional[HarnessTruncationConfiguration], default: None ) –

    The truncation configuration for managing conversation context. If not specified, the existing value is retained.

  • hooks (Optional[HarnessHooks], default: None ) –

    The lifecycle hooks to run at defined points in the agent loop. If specified, this replaces all existing hooks. If not specified, the existing hooks are retained.

  • max_iterations (Optional[int], default: None ) –

    The maximum number of iterations the agent loop can execute per invocation. If not specified, the existing value is retained.

  • max_tokens (Optional[int], default: None ) –

    The maximum total number of output tokens the agent can generate across all model calls within a single invocation. If not specified, the existing value is retained.

  • timeout_seconds (Optional[int], default: None ) –

    The maximum duration in seconds for the agent loop execution per invocation. If not specified, the existing value is retained.

Raises:

Source code in docs_src/capo_bedrock_agentcore_control/_services/bedrock_agent_core_control.py
def update_harness(
    self,
    harness_id: "capo_bedrock_agentcore_control.types.harness_id.HarnessId",
    *,
    config_overrides: Optional[BedrockAgentCoreControlClientConfig] = None,
    client_token: Optional[
        "capo_bedrock_agentcore_control.types.client_token.ClientToken"
    ] = None,
    execution_role_arn: Optional[
        "capo_bedrock_agentcore_control.types.role_arn.RoleArn"
    ] = None,
    environment: Optional[
        "capo_bedrock_agentcore_control.types.harness_environment_provider_request.HarnessEnvironmentProviderRequest"
    ] = None,
    environment_artifact: Optional[
        "capo_bedrock_agentcore_control.types.updated_harness_environment_artifact.UpdatedHarnessEnvironmentArtifact"
    ] = None,
    environment_variables: Optional[
        "capo_bedrock_agentcore_control.types.environment_variables_map.EnvironmentVariablesMap"
    ] = None,
    authorizer_configuration: Optional[
        "capo_bedrock_agentcore_control.types.updated_authorizer_configuration.UpdatedAuthorizerConfiguration"
    ] = None,
    model: Optional[
        "capo_bedrock_agentcore_control.types.harness_model_configuration.HarnessModelConfiguration"
    ] = None,
    system_prompt: Optional[
        "capo_bedrock_agentcore_control.types.harness_system_prompt.HarnessSystemPrompt"
    ] = None,
    tools: Optional[
        "capo_bedrock_agentcore_control.types.harness_tools.HarnessTools"
    ] = None,
    skills: Optional[
        "capo_bedrock_agentcore_control.types.harness_skills.HarnessSkills"
    ] = None,
    allowed_tools: Optional[
        "capo_bedrock_agentcore_control.types.harness_allowed_tools.HarnessAllowedTools"
    ] = None,
    memory: Optional[
        "capo_bedrock_agentcore_control.types.updated_harness_memory_configuration.UpdatedHarnessMemoryConfiguration"
    ] = None,
    truncation: Optional[
        "capo_bedrock_agentcore_control.types.harness_truncation_configuration.HarnessTruncationConfiguration"
    ] = None,
    hooks: Optional[
        "capo_bedrock_agentcore_control.types.harness_hooks.HarnessHooks"
    ] = None,
    max_iterations: Optional[int] = None,
    max_tokens: Optional[int] = None,
    timeout_seconds: Optional[int] = None,
) -> "capo_bedrock_agentcore_control.types.update_harness_response.UpdateHarnessResponse":
    """<p>Operation to update a harness.</p>

    Args:
        harness_id: <p>The ID of the harness to update.</p>
        client_token: <p>A unique, case-sensitive identifier to ensure idempotency of the request.</p>
        execution_role_arn: <p>The ARN of the IAM role that the harness assumes when running. If not specified, the existing value is retained.</p>
        environment: <p>The compute environment configuration for the harness. If not specified, the existing value is retained.</p>
        environment_artifact: <p>The environment artifact for the harness. Use the optionalValue wrapper to set a new value, or set it to null to clear the existing configuration.</p>
        environment_variables: <p>Environment variables to set in the harness runtime environment. If specified, this replaces all existing environment variables. If not specified, the existing value is retained.</p>
        model: <p>The model configuration for the harness. If not specified, the existing value is retained.</p>
        system_prompt: <p>The system prompt that defines the agent's behavior. If not specified, the existing value is retained.</p>
        tools: <p>The tools available to the agent. If specified, this replaces all existing tools. If not specified, the existing value is retained.</p>
        skills: <p>The skills available to the agent. If specified, this replaces all existing skills. If not specified, the existing value is retained.</p>
        allowed_tools: <p>The tools that the agent is allowed to use. If specified, this replaces all existing allowed tools. If not specified, the existing value is retained.</p>
        memory: <p>The AgentCore Memory configuration. Use the optionalValue wrapper to set a new value, or set it to null to clear the existing configuration.</p>
        truncation: <p>The truncation configuration for managing conversation context. If not specified, the existing value is retained.</p>
        hooks: <p>The lifecycle hooks to run at defined points in the agent loop. If specified, this replaces all existing hooks. If not specified, the existing hooks are retained.</p>
        max_iterations: <p>The maximum number of iterations the agent loop can execute per invocation. If not specified, the existing value is retained.</p>
        max_tokens: <p>The maximum total number of output tokens the agent can generate across all model calls within a single invocation. If not specified, the existing value is retained.</p>
        timeout_seconds: <p>The maximum duration in seconds for the agent loop execution per invocation. If not specified, the existing value is retained.</p>

    Raises:
        capo_bedrock_agentcore_control.errors.access_denied_exception.AccessDeniedException: <p>This exception is thrown when a request is denied per access permissions</p>
        capo_bedrock_agentcore_control.errors.conflict_exception.ConflictException: <p>This exception is thrown when there is a conflict performing an operation</p>
        capo_bedrock_agentcore_control.errors.internal_server_exception.InternalServerException: <p>This exception is thrown if there was an unexpected error during processing of request</p>
        capo_bedrock_agentcore_control.errors.resource_not_found_exception.ResourceNotFoundException: <p>This exception is thrown when a resource referenced by the operation does not exist</p>
        capo_bedrock_agentcore_control.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>This exception is thrown when a request is made beyond the service quota</p>
        capo_bedrock_agentcore_control.errors.throttling_exception.ThrottlingException: <p>This exception is thrown when the number of requests exceeds the limit</p>
        capo_bedrock_agentcore_control.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by the service.</p>
        capo_bedrock_agentcore_control.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_bedrock_agentcore_control.types.update_harness_request.UpdateHarnessRequest]",
    ) -> OperationResponse[
        "capo_bedrock_agentcore_control.types.update_harness_response.UpdateHarnessResponse"
    ]:
        import capo_bedrock_agentcore_control._operations.amazon_bedrock_agent_core_control.update_harness

        output, http_response = (
            capo_bedrock_agentcore_control._operations.amazon_bedrock_agent_core_control.update_harness.update_harness(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_bedrock_agentcore_control.types.update_harness_request.UpdateHarnessRequest",
    ) -> dict[str, Any]:
        import capo_bedrock_agentcore_control.types.update_harness_request

        return capo_bedrock_agentcore_control.types.update_harness_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_bedrock_agentcore_control.types.update_harness_response.UpdateHarnessResponse",
    ) -> dict[str, Any]:
        import capo_bedrock_agentcore_control.types.update_harness_response

        return capo_bedrock_agentcore_control.types.update_harness_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "UpdateHarness",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_bedrock_agentcore_control.types.update_harness_request.UpdateHarnessRequest = {
        "harness_id": harness_id
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if execution_role_arn is not None:
        input_["execution_role_arn"] = execution_role_arn
    if environment is not None:
        input_["environment"] = environment
    if environment_artifact is not None:
        input_["environment_artifact"] = environment_artifact
    if environment_variables is not None:
        input_["environment_variables"] = environment_variables
    if authorizer_configuration is not None:
        input_["authorizer_configuration"] = authorizer_configuration
    if model is not None:
        input_["model"] = model
    if system_prompt is not None:
        input_["system_prompt"] = system_prompt
    if tools is not None:
        input_["tools"] = tools
    if skills is not None:
        input_["skills"] = skills
    if allowed_tools is not None:
        input_["allowed_tools"] = allowed_tools
    if memory is not None:
        input_["memory"] = memory
    if truncation is not None:
        input_["truncation"] = truncation
    if hooks is not None:
        input_["hooks"] = hooks
    if max_iterations is not None:
        input_["max_iterations"] = max_iterations
    if max_tokens is not None:
        input_["max_tokens"] = max_tokens
    if timeout_seconds is not None:
        input_["timeout_seconds"] = timeout_seconds

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