EvaluatorConfig Class
Configuration for a custom evaluator.
Defines how an evaluator assesses agent performance. Supports two 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.
| Source | lib/evaluation/evaluator-config.ts |
|---|
Example
ts
// LLM-as-a-Judge evaluator
const llmConfig = agentcore.EvaluatorConfig.llmAsAJudge({
instructions: 'Evaluate whether the agent response is helpful.',
modelId: 'us.anthropic.claude-sonnet-4-6',
ratingScale: agentcore.EvaluatorRatingScale.categorical([
{ label: 'Good', definition: 'The response is helpful.' },
{ label: 'Bad', definition: 'The response is not helpful.' },
]),
});
// Code-based evaluator
declare const myEvalFunction: lambda.IFunction;
const codeConfig = agentcore.EvaluatorConfig.codeBased({
lambdaFunction: myEvalFunction,
});
python
# Code-based evaluator
# my_eval_function: lambda.IFunction
# LLM-as-a-Judge evaluator
llm_config = agentcore.EvaluatorConfig.llm_as_a_judge(
instructions="Evaluate whether the agent response is helpful.",
model_id="us.anthropic.claude-sonnet-4-6",
rating_scale=agentcore.EvaluatorRatingScale.categorical([agentcore.CategoricalRatingOption(label="Good", definition="The response is helpful."), agentcore.CategoricalRatingOption(label="Bad", definition="The response is not helpful.")
])
)
code_config = agentcore.EvaluatorConfig.code_based(
lambda_function=my_eval_function
)
java
// Code-based evaluator
IFunction myEvalFunction;
// LLM-as-a-Judge evaluator
EvaluatorConfig llmConfig = EvaluatorConfig.llmAsAJudge(LlmAsAJudgeOptions.builder()
.instructions("Evaluate whether the agent response is helpful.")
.modelId("us.anthropic.claude-sonnet-4-6")
.ratingScale(EvaluatorRatingScale.categorical(List.of(CategoricalRatingOption.builder().label("Good").definition("The response is helpful.").build(), CategoricalRatingOption.builder().label("Bad").definition("The response is not helpful.").build())))
.build());
EvaluatorConfig codeConfig = EvaluatorConfig.codeBased(CodeBasedOptions.builder()
.lambdaFunction(myEvalFunction)
.build());
csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Agentcore.Alpha
// Code-based evaluator
IFunction myEvalFunction;
// LLM-as-a-Judge evaluator
var llmConfig = EvaluatorConfig.LlmAsAJudge(new LlmAsAJudgeOptions {
Instructions = "Evaluate whether the agent response is helpful.",
ModelId = "us.anthropic.claude-sonnet-4-6",
RatingScale = EvaluatorRatingScale.Categorical(new [] { new CategoricalRatingOption { Label = "Good", Definition = "The response is helpful." }, new CategoricalRatingOption { Label = "Bad", Definition = "The response is not helpful." } })
});
var codeConfig = EvaluatorConfig.CodeBased(new CodeBasedOptions {
LambdaFunction = myEvalFunction
});
go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockagentcorealpha/v2
// Code-based evaluator
var myEvalFunction IFunction
// LLM-as-a-Judge evaluator
llmConfig := agentcore.EvaluatorConfig_LlmAsAJudge(&LlmAsAJudgeOptions{
Instructions: jsii.String("Evaluate whether the agent response is helpful."),
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."),
},
&CategoricalRatingOption{
Label: jsii.String("Bad"),
Definition: jsii.String("The response is not helpful."),
},
}),
})
codeConfig := agentcore.EvaluatorConfig_CodeBased(&CodeBasedOptions{
LambdaFunction: myEvalFunction,
})
Properties
Methods
codeBased(options: CodeBasedOptions): EvaluatorConfig // chainable@staticmethod def code_based(options: CodeBasedOptions) -> EvaluatorConfigpublic static EvaluatorConfig codeBased(CodeBasedOptions options)public static EvaluatorConfig CodeBased(CodeBasedOptions options)func CodeBased(Options CodeBasedOptions) EvaluatorConfig static #Creates a code-based evaluator configuration using a Lambda function.
The Lambda function implements custom evaluation logic. The function will automatically be granted invoke permissions for the bedrock-agentcore service.
1 parameter
Parameters
optionsoptionsoptionsoptionsOptions— - The code-based configuration options.
llmAsAJudge(options: LlmAsAJudgeOptions): EvaluatorConfig // chainable@staticmethod def llm_as_a_judge(options: LlmAsAJudgeOptions) -> EvaluatorConfigpublic static EvaluatorConfig llmAsAJudge(LlmAsAJudgeOptions options)public static EvaluatorConfig LlmAsAJudge(LlmAsAJudgeOptions options)func LlmAsAJudge(Options LlmAsAJudgeOptions) EvaluatorConfig static #Creates an LLM-as-a-Judge evaluator configuration.
Uses a foundation model to assess agent performance based on custom instructions and a rating scale.
1 parameter
Parameters
optionsoptionsoptionsoptionsOptions— - The LLM-as-a-Judge configuration options.