CodeBasedOptions

class aws_cdk.aws_bedrock_agentcore_alpha.CodeBasedOptions(*, lambda_function, timeout=None)

Bases: object

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

Uses a Lambda function to implement custom evaluation logic.

Parameters:
  • lambda_function (IFunction) – (experimental) 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.

  • timeout (Optional[Duration]) – (experimental) The timeout for the Lambda function invocation during evaluation. When not specified, the AgentCore evaluation service uses its default timeout for Lambda-based evaluators. Default: - The AgentCore evaluation service’s default Lambda timeout is used

Stability:

experimental

ExampleMetadata:

infused

Example:

# Code-based evaluator
# my_eval_function: lambda.IFunction
# LLM-as-a-Judge evaluator
llm_config = agentcore.EvaluatorConfig.llm_as_aJudge(
    instructions="Evaluate whether the agent response is helpful.",
    model_id="us.anthropic.claude-sonnet-4-6",
    rating_scale=agentcore.EvaluatorRatingScale.categorical([label="Good", definition="The response is helpful.", label="Bad", definition="The response is not helpful."
    ])
)
code_config = agentcore.EvaluatorConfig.code_based(
    lambda_function=my_eval_function
)

Attributes

lambda_function

(experimental) 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.

Stability:

experimental

timeout

(experimental) The timeout for the Lambda function invocation during evaluation.

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

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

See:

https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/custom-evaluators.html

Stability:

experimental