LlmAsAJudgeOptions Struct
Options for configuring an LLM-as-a-Judge custom evaluator.
Uses a foundation model to assess agent performance based on custom instructions and a rating scale.
| Source | lib/evaluation/evaluator-config.ts |
|---|
Example
// 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'],
}),
});
# 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"]
)
)
// 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();
// 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" }
})
});
// 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
additionalModelRequestFieldsoptional{ [key: string]: any }additional_model_request_fieldsoptionaltyping.Mapping[str, Any]additionalModelRequestFieldsoptionalMap<String, Object>AdditionalModelRequestFieldsoptionalIDictionary<string, object>AdditionalModelRequestFieldsoptional*map[string]interface{} #Default: No additional fields
inferenceConfigoptionalEvaluatorInferenceConfiginference_configoptionalEvaluatorInferenceConfiginferenceConfigoptionalEvaluatorInferenceConfigInferenceConfigoptionalEvaluatorInferenceConfigInferenceConfigoptionalEvaluatorInferenceConfig #Default: The foundation model's default inference parameters are used
When not specified, the foundation model uses its own default values for maxTokens, temperature, and topP.
notes
These instructions define the evaluation criteria, context, and expected behavior. Instructions must contain placeholders appropriate for the evaluation level (e.g., {context}, {available_tools} for SESSION level).
Note: Evaluators using reference-input placeholders (e.g., {expected_tool_trajectory}, {assertions}, {expected_response}) are only compatible with on-demand evaluation, not online evaluation.
Accepts standard model IDs (e.g., 'anthropic.claude-sonnet-4-6') and cross-region inference profile IDs with region prefixes (e.g., 'us.anthropic.claude-sonnet-4-6', 'eu.anthropic.claude-sonnet-4-6').
ratingScaleEvaluatorRatingScalerating_scaleEvaluatorRatingScaleratingScaleEvaluatorRatingScaleRatingScaleEvaluatorRatingScaleRatingScaleEvaluatorRatingScale required #