java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IEvaluatorRef, IEnvironmentAware, IResource, IEvaluator, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.130.0 (build 048a5ee)", date="2026-05-19T19:44:37.072Z") @Stability(Stable) public class Evaluator extends EvaluatorBase
A custom evaluator for Amazon Bedrock AgentCore.

Custom evaluators enable you to define evaluation logic tailored to your specific use cases. Supports two evaluation strategies:

  • LLM-as-a-Judge: Uses a foundation model with custom instructions and a rating scale.
  • Code-based: Uses a Lambda function for custom evaluation logic.

Custom evaluators are used with OnlineEvaluationConfig via EvaluatorSelector.custom().

Example:

 // Create a custom LLM-as-a-Judge evaluator
 Evaluator evaluator = Evaluator.Builder.create(this, "MyEvaluator")
         .evaluatorName("my_custom_evaluator")
         .level(EvaluationLevel.SESSION)
         .evaluatorConfig(EvaluatorConfig.llmAsAJudge(LlmAsAJudgeOptions.builder()
                 .instructions("Evaluate whether the agent response is helpful and accurate.")
                 .modelId("us.anthropic.claude-sonnet-4-6")
                 .ratingScale(EvaluatorRatingScale.categorical(List.of(CategoricalRatingOption.builder().label("Good").definition("The response is helpful and accurate.").build(), CategoricalRatingOption.builder().label("Bad").definition("The response is not helpful or contains errors.").build())))
                 .build()))
         .build();
 // Use the custom evaluator in an online evaluation configuration
 // Use the custom evaluator in an online evaluation configuration
 OnlineEvaluationConfig.Builder.create(this, "MyEvaluation")
         .onlineEvaluationConfigName("my_evaluation")
         .evaluators(List.of(EvaluatorSelector.builtin(BuiltinEvaluator.HELPFULNESS), EvaluatorSelector.custom(evaluator)))
         .dataSource(DataSourceConfig.fromCloudWatchLogs(CloudWatchLogsDataSourceConfig.builder()
                 .logGroupNames(List.of("/aws/bedrock-agentcore/my-agent"))
                 .serviceNames(List.of("my-agent.default"))
                 .build()))
         .build();
 
  • Field Details

    • PROPERTY_INJECTION_ID

      @Stability(Stable) public static final String PROPERTY_INJECTION_ID
      Uniquely identifies this class.
  • Constructor Details

    • Evaluator

      protected Evaluator(software.amazon.jsii.JsiiObjectRef objRef)
    • Evaluator

      protected Evaluator(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Evaluator

      @Stability(Stable) public Evaluator(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull EvaluatorProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • fromEvaluatorArn

      @Stability(Stable) @NotNull public static IEvaluator fromEvaluatorArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String evaluatorArn)
      Import an existing Evaluator by its ARN.

      Parameters:
      scope -
      • The construct scope.
      This parameter is required.
      id -
      • Construct identifier.
      This parameter is required.
      evaluatorArn -
      • The evaluator ARN to import.
      This parameter is required.
      Returns:
      An IEvaluator reference
    • fromEvaluatorAttributes

      @Stability(Stable) @NotNull public static IEvaluator fromEvaluatorAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull EvaluatorAttributes attrs)
      Import an existing Evaluator from its attributes.

      Parameters:
      scope -
      • The construct scope.
      This parameter is required.
      id -
      • Construct identifier.
      This parameter is required.
      attrs -
      • The evaluator attributes.
      This parameter is required.
      Returns:
      An IEvaluator reference
    • fromEvaluatorId

      @Stability(Stable) @NotNull public static IEvaluator fromEvaluatorId(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String evaluatorId)
      Import an existing Evaluator by its ID.

      Parameters:
      scope -
      • The construct scope.
      This parameter is required.
      id -
      • Construct identifier.
      This parameter is required.
      evaluatorId -
      • The evaluator ID to import.
      This parameter is required.
      Returns:
      An IEvaluator reference
    • getEvaluatorArn

      @Stability(Stable) @NotNull public String getEvaluatorArn()
      The ARN of the evaluator.
      Specified by:
      getEvaluatorArn in interface IEvaluator
      Specified by:
      getEvaluatorArn in class EvaluatorBase
    • getEvaluatorId

      @Stability(Stable) @NotNull public String getEvaluatorId()
      The unique identifier of the evaluator.
      Specified by:
      getEvaluatorId in interface IEvaluator
      Specified by:
      getEvaluatorId in class EvaluatorBase
    • getEvaluatorName

      @Stability(Stable) @NotNull public String getEvaluatorName()
      The name of the evaluator.
      Specified by:
      getEvaluatorName in interface IEvaluator
      Specified by:
      getEvaluatorName in class EvaluatorBase
    • getCreatedAt

      @Stability(Stable) @Nullable public String getCreatedAt()
      The timestamp when the evaluator was created.
      Specified by:
      getCreatedAt in interface IEvaluator
      Specified by:
      getCreatedAt in class EvaluatorBase
    • getStatus

      @Stability(Stable) @Nullable public String getStatus()
      The lifecycle status of the evaluator.
      Specified by:
      getStatus in interface IEvaluator
      Specified by:
      getStatus in class EvaluatorBase
    • getUpdatedAt

      @Stability(Stable) @Nullable public String getUpdatedAt()
      The timestamp when the evaluator was last updated.
      Specified by:
      getUpdatedAt in interface IEvaluator
      Specified by:
      getUpdatedAt in class EvaluatorBase