EvaluatorProps Struct
Properties for creating an Evaluator.
| Source | lib/evaluation/custom-evaluator.ts |
|---|
Example
ts
// Create a custom LLM-as-a-Judge evaluator
const evaluator = new agentcore.Evaluator(this, 'MyEvaluator', {
evaluatorName: 'my_custom_evaluator',
level: agentcore.EvaluationLevel.SESSION,
evaluatorConfig: agentcore.EvaluatorConfig.llmAsAJudge({
instructions: 'Evaluate whether the agent response is helpful and accurate.',
modelId: 'us.anthropic.claude-sonnet-4-6',
ratingScale: agentcore.EvaluatorRatingScale.categorical([
{ label: 'Good', definition: 'The response is helpful and accurate.' },
{ label: 'Bad', definition: 'The response is not helpful or contains errors.' },
]),
}),
});
// Use the custom evaluator in an online evaluation configuration
new agentcore.OnlineEvaluationConfig(this, 'MyEvaluation', {
onlineEvaluationConfigName: 'my_evaluation',
evaluators: [
agentcore.EvaluatorReference.builtin(agentcore.BuiltinEvaluator.HELPFULNESS),
agentcore.EvaluatorReference.custom(evaluator),
],
dataSource: agentcore.DataSourceConfig.fromCloudWatchLogs({
logGroupNames: ['/aws/bedrock-agentcore/my-agent'],
serviceNames: ['my-agent.default'],
}),
});
python
# Create a custom LLM-as-a-Judge evaluator
evaluator = agentcore.Evaluator(self, "MyEvaluator",
evaluator_name="my_custom_evaluator",
level=agentcore.EvaluationLevel.SESSION,
evaluator_config=agentcore.EvaluatorConfig.llm_as_a_judge(
instructions="Evaluate whether the agent response is helpful and accurate.",
model_id="us.anthropic.claude-sonnet-4-6",
rating_scale=agentcore.EvaluatorRatingScale.categorical([agentcore.CategoricalRatingOption(label="Good", definition="The response is helpful and accurate."), agentcore.CategoricalRatingOption(label="Bad", definition="The response is not helpful or contains errors.")
])
)
)
# Use the custom evaluator in an online evaluation configuration
agentcore.OnlineEvaluationConfig(self, "MyEvaluation",
online_evaluation_config_name="my_evaluation",
evaluators=[
agentcore.EvaluatorReference.builtin(agentcore.BuiltinEvaluator.HELPFULNESS),
agentcore.EvaluatorReference.custom(evaluator)
],
data_source=agentcore.DataSourceConfig.from_cloud_watch_logs(
log_group_names=["/aws/bedrock-agentcore/my-agent"],
service_names=["my-agent.default"]
)
)
java
// 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(EvaluatorReference.builtin(BuiltinEvaluator.HELPFULNESS), EvaluatorReference.custom(evaluator)))
.dataSource(DataSourceConfig.fromCloudWatchLogs(CloudWatchLogsDataSourceConfig.builder()
.logGroupNames(List.of("/aws/bedrock-agentcore/my-agent"))
.serviceNames(List.of("my-agent.default"))
.build()))
.build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Agentcore.Alpha
// Create a custom LLM-as-a-Judge evaluator
var evaluator = new Evaluator(this, "MyEvaluator", new EvaluatorProps {
EvaluatorName = "my_custom_evaluator",
Level = EvaluationLevel.SESSION,
EvaluatorConfig = EvaluatorConfig.LlmAsAJudge(new LlmAsAJudgeOptions {
Instructions = "Evaluate whether the agent response is helpful and accurate.",
ModelId = "us.anthropic.claude-sonnet-4-6",
RatingScale = EvaluatorRatingScale.Categorical(new [] { new CategoricalRatingOption { Label = "Good", Definition = "The response is helpful and accurate." }, new CategoricalRatingOption { Label = "Bad", Definition = "The response is not helpful or contains errors." } })
})
});
// Use the custom evaluator in an online evaluation configuration
// Use the custom evaluator in an online evaluation configuration
new OnlineEvaluationConfig(this, "MyEvaluation", new OnlineEvaluationConfigProps {
OnlineEvaluationConfigName = "my_evaluation",
Evaluators = new [] { EvaluatorReference.Builtin(BuiltinEvaluator.HELPFULNESS), EvaluatorReference.Custom(evaluator) },
DataSource = DataSourceConfig.FromCloudWatchLogs(new CloudWatchLogsDataSourceConfig {
LogGroupNames = new [] { "/aws/bedrock-agentcore/my-agent" },
ServiceNames = new [] { "my-agent.default" }
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockagentcorealpha/v2
// Create a custom LLM-as-a-Judge evaluator
evaluator := agentcore.NewEvaluator(this, jsii.String("MyEvaluator"), &EvaluatorProps{
EvaluatorName: jsii.String("my_custom_evaluator"),
Level: agentcore.EvaluationLevel_SESSION(),
EvaluatorConfig: agentcore.EvaluatorConfig_LlmAsAJudge(&LlmAsAJudgeOptions{
Instructions: jsii.String("Evaluate whether the agent response is helpful and accurate."),
ModelId: jsii.String("us.anthropic.claude-sonnet-4-6"),
RatingScale: agentcore.EvaluatorRatingScale_Categorical([]CategoricalRatingOption{
&CategoricalRatingOption{
Label: jsii.String("Good"),
Definition: jsii.String("The response is helpful and accurate."),
},
&CategoricalRatingOption{
Label: jsii.String("Bad"),
Definition: jsii.String("The response is not helpful or contains errors."),
},
}),
}),
})
// Use the custom evaluator in an online evaluation configuration
// Use the custom evaluator in an online evaluation configuration
agentcore.NewOnlineEvaluationConfig(this, jsii.String("MyEvaluation"), &OnlineEvaluationConfigProps{
OnlineEvaluationConfigName: jsii.String("my_evaluation"),
Evaluators: []EvaluatorReference{
agentcore.EvaluatorReference_Builtin(agentcore.BuiltinEvaluator_HELPFULNESS()),
agentcore.EvaluatorReference_Custom(evaluator),
},
DataSource: agentcore.DataSourceConfig_FromCloudWatchLogs(&CloudWatchLogsDataSourceConfig{
LogGroupNames: []*string{
jsii.String("/aws/bedrock-agentcore/my-agent"),
},
ServiceNames: []*string{
jsii.String("my-agent.default"),
},
}),
})
Properties
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string #The description of the evaluator.
Default: No description
evaluatorConfigEvaluatorConfigevaluator_configEvaluatorConfigevaluatorConfigEvaluatorConfigEvaluatorConfigEvaluatorConfigEvaluatorConfigEvaluatorConfig required #The configuration that defines how the evaluator assesses agent performance.
Use EvaluatorConfig.llmAsAJudge() for model-based evaluation or EvaluatorConfig.codeBased() for Lambda-based evaluation.
evaluatorNamestringevaluator_namestrevaluatorNameStringEvaluatorNamestringEvaluatorName*string required #The name of the evaluator.
Must be unique within your account. Valid characters are a-z, A-Z, 0-9, _ (underscore). Must start with a letter and can be up to 48 characters long.
levelEvaluationLevellevelEvaluationLevellevelEvaluationLevelLevelEvaluationLevelLevelEvaluationLevel required #The level at which the evaluator assesses agent performance.
Determines what granularity of data the evaluator operates on: tool call, trace (single request-response), or session (full conversation).
tagsoptional{ [key: string]: string }tagsoptionaltyping.Mapping[str, str]tagsoptionalMap<String, String>TagsoptionalIDictionary<string, string>Tagsoptional*map[string]*string #Tags for the evaluator.
Default: No tags
A list of key:value pairs of tags to apply to this Evaluator resource.