class Evaluator (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.Bedrock.Agentcore.Alpha.Evaluator |
Go | github.com/aws/aws-cdk-go/awsbedrockagentcorealpha/v2#Evaluator |
Java | software.amazon.awscdk.services.bedrock.agentcore.alpha.Evaluator |
Python | aws_cdk.aws_bedrock_agentcore_alpha.Evaluator |
TypeScript (source) | @aws-cdk/aws-bedrock-agentcore-alpha ยป Evaluator |
Implements
IConstruct, IDependable, IResource, IEnvironment, IEvaluator, IEvaluator
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 EvaluatorReference.custom().
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'],
}),
});
Initializer
new Evaluator(scope: Construct, id: string, props: EvaluatorProps)
Parameters
- scope
Construct - id
string - props
EvaluatorProps
Construct Props
| Name | Type | Description |
|---|---|---|
| evaluator | Evaluator | The configuration that defines how the evaluator assesses agent performance. |
| evaluator | string | The name of the evaluator. |
| level | Evaluation | The level at which the evaluator assesses agent performance. |
| description? | string | The description of the evaluator. |
evaluatorConfig
Type:
Evaluator
The configuration that defines how the evaluator assesses agent performance.
Use EvaluatorConfig.llmAsAJudge() for model-based evaluation or
EvaluatorConfig.codeBased() for Lambda-based evaluation.
evaluatorName
Type:
string
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.
level
Type:
Evaluation
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).
description?
Type:
string
(optional, default: No description)
The description of the evaluator.
Properties
| Name | Type | Description |
|---|---|---|
| env | Resource | The environment this resource belongs to. |
| evaluator | string | The ARN of the evaluator. |
| evaluator | string | The unique identifier of the evaluator. |
| evaluator | string | The name of the evaluator. |
| evaluator | Evaluator | A reference to this Evaluator resource. |
| node | Node | The tree node. |
| stack | Stack | The stack in which this resource is defined. |
| created | string | The timestamp when the evaluator was created. |
| status? | string | The lifecycle status of the evaluator. |
| updated | string | The timestamp when the evaluator was last updated. |
| static PROPERTY_INJECTION_ID | string | Uniquely identifies this class. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
evaluatorArn
Type:
string
The ARN of the evaluator.
evaluatorId
Type:
string
The unique identifier of the evaluator.
evaluatorName
Type:
string
The name of the evaluator.
evaluatorRef
Type:
Evaluator
A reference to this Evaluator resource.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
createdAt?
Type:
string
(optional)
The timestamp when the evaluator was created.
status?
Type:
string
(optional)
The lifecycle status of the evaluator.
updatedAt?
Type:
string
(optional)
The timestamp when the evaluator was last updated.
static PROPERTY_INJECTION_ID
Type:
string
Uniquely identifies this class.
Methods
| Name | Description |
|---|---|
| apply | Apply the given removal policy to this resource. |
| grant(grantee, ...actions) | Grants IAM actions to the IAM Principal. |
| to | Returns a string representation of this construct. |
| with(...mixins) | Applies one or more mixins to this construct. |
| static from | Import an existing Evaluator by its ARN. |
| static from | Import an existing Evaluator from its attributes. |
| static from | Import an existing Evaluator by its ID. |
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
RemovalPolicy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN).
grant(grantee, ...actions)
public grant(grantee: IGrantable, ...actions: string[]): Grant
Parameters
- grantee
IGrantableโ - The IAM principal to grant permissions to. - actions
stringโ - The actions to grant.
Returns
Grants IAM actions to the IAM Principal.
[disable-awslint:no-grants]
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
with(...mixins)
public with(...mixins: IMixin[]): IConstruct
Parameters
- mixins
IMixin
Returns
Applies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
static fromEvaluatorArn(scope, id, evaluatorArn)
public static fromEvaluatorArn(scope: Construct, id: string, evaluatorArn: string): IEvaluator
Parameters
- scope
Constructโ - The construct scope. - id
stringโ - Construct identifier. - evaluatorArn
stringโ - The evaluator ARN to import.
Returns
Import an existing Evaluator by its ARN.
static fromEvaluatorAttributes(scope, id, attrs)
public static fromEvaluatorAttributes(scope: Construct, id: string, attrs: EvaluatorAttributes): IEvaluator
Parameters
- scope
Constructโ - The construct scope. - id
stringโ - Construct identifier. - attrs
Evaluatorโ - The evaluator attributes.Attributes
Returns
Import an existing Evaluator from its attributes.
static fromEvaluatorId(scope, id, evaluatorId)
public static fromEvaluatorId(scope: Construct, id: string, evaluatorId: string): IEvaluator
Parameters
- scope
Constructโ - The construct scope. - id
stringโ - Construct identifier. - evaluatorId
stringโ - The evaluator ID to import.
Returns
Import an existing Evaluator by its ID.

.NET
Go
Java
Python
TypeScript (