Skip to content
v2.275.0

Experimental

@aws-cdk/aws-bedrock-agentcore-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

CodeBasedOptions Struct ​

Options for configuring a code-based custom evaluator using a Lambda function.

Uses a Lambda function to implement custom evaluation logic.

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,
});

Properties ​

lambdaFunctionIFunctionlambda_functionIFunctionlambdaFunctionIFunctionLambdaFunctionIFunctionLambdaFunctionIFunctionrequired#
The Lambda function used for evaluation.

The function will be granted invoke permissions for the bedrock-agentcore.amazonaws.com service principal, scoped to this specific evaluator resource.

timeoutoptionalDurationtimeoutoptionalDurationtimeoutoptionalDurationTimeoutoptionalDurationTimeoutoptionalDuration#
The timeout for the Lambda function invocation during evaluation.

Default: The AgentCore evaluation service's default Lambda timeout is used

When not specified, the AgentCore evaluation service uses its default timeout for Lambda-based evaluators.