# CodeBasedOptions

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

Uses a Lambda function to implement custom evaluation logic.

- Source: [`aws-bedrockagentcore/lib/evaluation/evaluator-config.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-bedrockagentcore/lib/evaluation/evaluator-config.ts#L85)
- Type last changed: v2.255.0 · 19 May 2026

## Example

```ts
declare const evalFunction: lambda.IFunction;

const codeEvaluator = new agentcore.Evaluator(this, 'CodeEvaluator', {
  evaluatorName: 'custom_code_evaluator',
  level: agentcore.EvaluationLevel.TOOL_CALL,
  description: 'Evaluates tool call accuracy using custom logic',
  evaluatorConfig: agentcore.EvaluatorConfig.codeBased({
    lambdaFunction: evalFunction,
    timeout: cdk.Duration.seconds(30),
  }),
});
```

## Properties

- `lambdaFunction`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) (required) — 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`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — 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.
