CodeBasedOptions

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

Bases: object

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) – 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]) – 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

ExampleMetadata:

fixture=default infused

Example:

# eval_function: lambda.IFunction


code_evaluator = agentcore.Evaluator(self, "CodeEvaluator",
    evaluator_name="custom_code_evaluator",
    level=agentcore.EvaluationLevel.TOOL_CALL,
    description="Evaluates tool call accuracy using custom logic",
    evaluator_config=agentcore.EvaluatorConfig.code_based(
        lambda_function=eval_function,
        timeout=cdk.Duration.seconds(30)
    )
)

Attributes

lambda_function

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

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