# EvaluationLevel

The level at which a custom evaluator assesses agent performance.

Determines what granularity of data the evaluator operates on.

Obtainable from: EvaluationLevel.SESSION, EvaluationLevel.TOOL_CALL, EvaluationLevel.TRACE

- Source: [`lib/evaluation/types.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/@aws-cdk/aws-bedrock-agentcore-alpha/lib/evaluation/types.ts#L398)

## Example

TypeScript:

```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:

```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:

```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();
```

C# / .NET:

```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" }
    })
});
```

Golang:

```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"),
		},
	}),
})
```

## Initializer

TypeScript:

```ts
new EvaluationLevel(value: string)
```

Python:

```python
EvaluationLevel(value: str)
```

Java:

```java
new EvaluationLevel(String value)
```

C# / .NET:

```csharp
new EvaluationLevel(string value)
```

Golang:

```go
NewEvaluationLevel(Value *string)
```

## Properties

- `SESSION`: [EvaluationLevel](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.EvaluationLevel.html) (static) — Evaluates an entire agent session (multiple traces across a conversation).

- `TOOL_CALL`: [EvaluationLevel](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.EvaluationLevel.html) (static) — Evaluates individual tool call invocations within a trace.

- `TRACE`: [EvaluationLevel](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.EvaluationLevel.html) (static) — Evaluates a complete agent trace (a single request-response cycle).

- `value`: string — The string value of the evaluation level.
