Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6fba5c8
Add deepeval CLI integration: flags, templates, warnings, memory, uni…
haomiao037 Jun 16, 2026
d44430a
Refactor CLI to registry-driven third-party evaluator framework (Deep…
haomiao037 Jun 25, 2026
485000e
fix: Update 3P evaluator templates and add --param/--parameters-file …
haomiao037 Jul 16, 2026
0bff7a8
feat: Add 3P evaluator E2E test + fix autoevals template
haomiao037 Jul 16, 2026
9153b3c
fix: Rename AutoevalsAdapter → AutoEvalsAdapter in template (match SD…
haomiao037 Jul 20, 2026
7b5348c
fix: Reject --3p-library with --type llm-as-a-judge
haomiao037 Jul 22, 2026
56158e3
feat: Add --model-provider flag for keyless Bedrock evaluators
haomiao037 Jul 24, 2026
1a860d9
fix: Require --model with --model-provider bedrock, remove env var de…
haomiao037 Jul 24, 2026
591760a
fix: Address Copilot review comments
haomiao037 Jul 24, 2026
a100276
fix: Update E2E test to use --model-provider bedrock (keyless)
haomiao037 Jul 24, 2026
f92635c
fix: Default --model-provider to bedrock, add OpenAI warning
haomiao037 Jul 24, 2026
27ba5a2
fix: Use hasOwnProperty for library validation (Copilot review)
haomiao037 Jul 24, 2026
f1cf617
fix: Allow --model without explicit --model-provider (bedrock is defa…
haomiao037 Jul 26, 2026
1aa9152
fix: Parse Python-style True/False/None in --param values
haomiao037 Jul 29, 2026
11537a1
fix: Autoevals dangling comma + clarify inference profile in --model …
haomiao037 Jul 29, 2026
e9cb8f6
fix: Remove --memory flag (to be handled via GitHub issue)
haomiao037 Jul 29, 2026
565eeda
feat: Add --3p-template-json and --3p-template-json-file flags
haomiao037 Jul 29, 2026
978a29c
fix: Remove individual 3P flags, use --3p-template-json only
haomiao037 Jul 30, 2026
73376a3
fix: Remove dead parseParamFlags code + update E2E tests to use --3p-…
haomiao037 Jul 30, 2026
de7768b
fix: Add OpenAI warning + pass model to metric in OpenAI path
haomiao037 Jul 30, 2026
315fa1d
fix: Make model optional for deterministic metrics in --3p-template-json
haomiao037 Jul 30, 2026
802a95f
fix: Pin deepeval and autoevals with upper version bounds
haomiao037 Jul 30, 2026
e740815
fix: Remove memorySizeMb, fix lint errors per TJ review
haomiao037 Jul 30, 2026
59aa8b8
fix: Resolve typecheck errors (TS2454, TS2353)
haomiao037 Jul 31, 2026
ec5c264
fix: Apply prettier formatting to test file
haomiao037 Jul 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ ProtocolTesting/
browser-tests/.browser-test-env
browser-tests/test-results/
browser-tests/playwright-report/

# E2E test output
test-e2e-output/
214 changes: 214 additions & 0 deletions e2e-tests/third-party-eval-lifecycle.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
import { parseJsonOutput, retry } from '../src/test-utils/index.js';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run typecheck, linter, and prettier on this PR.

import {
baseCanRun,
hasAws,
installCdkTarball,
runAgentCoreCLI,
teardownE2EProject,
writeAwsTargets,
} from './e2e-helper.js';
import { randomUUID } from 'node:crypto';
import { mkdir, rm } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

const canRun = baseCanRun && hasAws;

describe.sequential('e2e: third-party evaluator lifecycle (DeepEval + Autoevals)', () => {
let testDir: string;
let projectPath: string;
const agentName = `E2e3pEval${String(Date.now()).slice(-8)}`;
const deepevalEvalName = 'answer_relevancy';
const autoevalsEvalName = 'exact_match';

beforeAll(async () => {
if (!canRun) return;

testDir = join(tmpdir(), `agentcore-e2e-3p-eval-${randomUUID()}`);
await mkdir(testDir, { recursive: true });

const result = await runAgentCoreCLI(
[
'create',
'--name',
agentName,
'--language',
'Python',
'--framework',
'Strands',
'--model-provider',
'Bedrock',
'--memory',
'none',
'--json',
],
testDir
);
expect(result.exitCode, `Create failed: ${result.stderr}`).toBe(0);
projectPath = (parseJsonOutput(result.stdout) as { projectPath: string }).projectPath;

await writeAwsTargets(projectPath);
installCdkTarball(projectPath);
}, 300000);

afterAll(async () => {
if (projectPath && hasAws) {
await teardownE2EProject(projectPath, agentName, 'Bedrock');
}
if (testDir) await rm(testDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 1000 });
}, 600000);

const run = (args: string[]) => runAgentCoreCLI(args, projectPath);

it.skipIf(!canRun)(
'adds a DeepEval 3P evaluator with --3p-template-json',
async () => {
const templateJson = JSON.stringify({
library: 'deepeval',
metric: 'AnswerRelevancyMetric',
modelProvider: 'bedrock',
model: 'us.anthropic.claude-sonnet-4-20250514-v1:0',
params: { threshold: 0.5 },
});
const result = await run([
'add',
'evaluator',
'--name',
deepevalEvalName,
'--level',
'TRACE',
'--type',
'code-based',
'--3p-template-json',
templateJson,
'--json',
]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update all the tests

expect(result.exitCode, `Add DeepEval evaluator failed: ${result.stdout}`).toBe(0);
const json = parseJsonOutput(result.stdout) as { success: boolean; evaluatorName: string; codePath: string };
expect(json.success).toBe(true);
expect(json.evaluatorName).toBe(deepevalEvalName);
expect(json.codePath).toContain(deepevalEvalName);
},
60000
);

it.skipIf(!canRun)(
'adds an Autoevals 3P evaluator with --3p-template-json',
async () => {
const templateJson = JSON.stringify({
library: 'autoevals',
metric: 'ExactMatch',
modelProvider: 'bedrock',
model: 'us.anthropic.claude-sonnet-4-20250514-v1:0',
});
const result = await run([
'add',
'evaluator',
'--name',
autoevalsEvalName,
'--level',
'TRACE',
'--type',
'code-based',
'--3p-template-json',
templateJson,
'--json',
]);
expect(result.exitCode, `Add Autoevals evaluator failed: ${result.stdout}`).toBe(0);
const json = parseJsonOutput(result.stdout) as { success: boolean; evaluatorName: string; codePath: string };
expect(json.success).toBe(true);
expect(json.evaluatorName).toBe(autoevalsEvalName);
expect(json.codePath).toContain(autoevalsEvalName);
},
60000
);

it.skipIf(!canRun)(
'deploys agent with 3P evaluators',
async () => {
const result = await run(['deploy', '--yes', '--json']);
if (result.exitCode !== 0) {
console.log('Deploy stdout:', result.stdout);
console.log('Deploy stderr:', result.stderr);
}
expect(result.exitCode, 'Deploy failed').toBe(0);
const json = parseJsonOutput(result.stdout) as { success: boolean };
expect(json.success).toBe(true);
},
600000
);

it.skipIf(!canRun)(
'invokes the deployed agent to generate traces',
async () => {
await retry(
async () => {
const result = await run(['invoke', '--prompt', 'What is 2+2?', '--runtime', agentName, '--json']);
expect(result.exitCode, `Invoke failed: ${result.stderr}`).toBe(0);
const json = parseJsonOutput(result.stdout) as { success: boolean };
expect(json.success).toBe(true);
},
3,
15000
);
},
180000
);

it.skipIf(!canRun)(
'runs on-demand evaluation with DeepEval 3P evaluator',
async () => {
await retry(
async () => {
const result = await run([
'run',
'eval',
'--runtime',
agentName,
'--evaluator',
deepevalEvalName,
'--days',
'1',
'--json',
]);
expect(result.exitCode, `Run eval failed (stdout: ${result.stdout}, stderr: ${result.stderr})`).toBe(0);
const json = parseJsonOutput(result.stdout) as Record<string, unknown>;
expect(json).toHaveProperty('success', true);
expect(json).toHaveProperty('run');
},
18,
10000
);
},
300000
);

it.skipIf(!canRun)(
'runs on-demand evaluation with Autoevals 3P evaluator',
async () => {
await retry(
async () => {
const result = await run([
'run',
'eval',
'--runtime',
agentName,
'--evaluator',
autoevalsEvalName,
'--days',
'1',
'--json',
]);
expect(result.exitCode, `Run eval failed (stdout: ${result.stdout}, stderr: ${result.stderr})`).toBe(0);
const json = parseJsonOutput(result.stdout) as Record<string, unknown>;
expect(json).toHaveProperty('success', true);
expect(json).toHaveProperty('run');
},
18,
10000
);
},
300000
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,12 @@ exports[`Assets Directory Snapshots > File listing > should match the expected f
"container/typescript/dockerignore.template",
"datasets/predefined-v1.jsonl",
"datasets/simulated-v1.jsonl",
"evaluators/autoevals-lambda/execution-role-policy.json",
"evaluators/autoevals-lambda/lambda_function.py",
"evaluators/autoevals-lambda/pyproject.toml",
"evaluators/deepeval-lambda/execution-role-policy.json",
"evaluators/deepeval-lambda/lambda_function.py",
"evaluators/deepeval-lambda/pyproject.toml",
"evaluators/python-lambda/execution-role-policy.json",
"evaluators/python-lambda/lambda_function.py",
"evaluators/python-lambda/pyproject.toml",
Expand Down
15 changes: 15 additions & 0 deletions src/assets/evaluators/autoevals-lambda/execution-role-policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents"],
"Resource": "arn:*:logs:*:*:log-group:/aws/lambda/*"
},
{
"Effect": "Allow",
"Action": ["bedrock:InvokeModel"],
"Resource": "*"
}
]
}
37 changes: 37 additions & 0 deletions src/assets/evaluators/autoevals-lambda/lambda_function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{#if ModelProviderBedrock}}
import os

# litellm's Bedrock provider reads AWS_REGION_NAME; Lambda only sets AWS_REGION/AWS_DEFAULT_REGION.
os.environ.setdefault("AWS_REGION_NAME", os.environ.get("AWS_REGION", "us-west-2"))

from autoevals import {{ EvaluatorClass }}, init
from autoevals.litellm import LiteLLMClient

from bedrock_agentcore.evaluation.custom_code_based_evaluators import (
EvaluatorInput,
EvaluatorOutput,
custom_code_based_evaluator,
)
from bedrock_agentcore.evaluation.custom_code_based_evaluators.third_party.autoevals import AutoEvalsAdapter

client = LiteLLMClient()
init(client=client, default_model="{{ Model }}")

adapter = AutoEvalsAdapter(metric={{ EvaluatorClass }}(client=client, model="{{ Model }}"){{#if EvaluatorParams}}, {{{ EvaluatorParams }}}{{/if}})
{{else}}
from autoevals import {{ EvaluatorClass }}

from bedrock_agentcore.evaluation.custom_code_based_evaluators import (
EvaluatorInput,
EvaluatorOutput,
custom_code_based_evaluator,
)
from bedrock_agentcore.evaluation.custom_code_based_evaluators.third_party.autoevals import AutoEvalsAdapter

adapter = AutoEvalsAdapter(metric={{ EvaluatorClass }}({{#if Model}}model="{{ Model }}"{{/if}}){{#if EvaluatorParams}}, {{{ EvaluatorParams }}}{{/if}})
{{/if}}


@custom_code_based_evaluator()
def handler(evaluator_input: EvaluatorInput, context) -> EvaluatorOutput:
return adapter(evaluator_input, context)
22 changes: 22 additions & 0 deletions src/assets/evaluators/autoevals-lambda/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "{{ Name }}"
version = "0.1.0"
description = "AgentCore Code-Based Evaluator (Autoevals)"
requires-python = ">=3.10"
dependencies = [
"bedrock-agentcore[autoevals]",
"autoevals>=0.0.80,<1.0.0",
{{#if ModelProviderBedrock}}
# autoevals grades via LiteLLMClient -> Bedrock (Converse); litellm replaces the openai judge
"litellm>=1.60,<1.85",
{{else}}
"openai>=1.0.0",
{{/if}}
]

[tool.hatch.build.targets.wheel]
packages = ["."]
15 changes: 15 additions & 0 deletions src/assets/evaluators/deepeval-lambda/execution-role-policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents"],
"Resource": "arn:*:logs:*:*:log-group:/aws/lambda/*"
},
{
"Effect": "Allow",
"Action": ["bedrock:InvokeModel"],
"Resource": "*"
}
]
}
29 changes: 29 additions & 0 deletions src/assets/evaluators/deepeval-lambda/lambda_function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os

os.environ.setdefault("DEEPEVAL_RESULTS_FOLDER", "/tmp/.deepeval")
os.environ.setdefault("DEEPEVAL_TELEMETRY_OPT_OUT", "YES")
os.chdir("/tmp")

{{#if ModelProviderBedrock}}
from deepeval.models import AmazonBedrockModel
{{/if}}
from deepeval.metrics import {{ EvaluatorClass }}

from bedrock_agentcore.evaluation.custom_code_based_evaluators import (
EvaluatorInput,
EvaluatorOutput,
custom_code_based_evaluator,
)
from bedrock_agentcore.evaluation.custom_code_based_evaluators.third_party.deepeval import DeepEvalAdapter

{{#if ModelProviderBedrock}}
model = AmazonBedrockModel(model="{{ Model }}", region=os.environ.get("AWS_REGION", "us-west-2"))
adapter = DeepEvalAdapter(metric={{ EvaluatorClass }}(model=model{{#if EvaluatorParams}}, {{{ EvaluatorParams }}}{{/if}}))
{{else}}
adapter = DeepEvalAdapter(metric={{ EvaluatorClass }}({{{ EvaluatorParams }}}))
{{/if}}


@custom_code_based_evaluator()
def handler(evaluator_input: EvaluatorInput, context) -> EvaluatorOutput:
return adapter(evaluator_input, context)
19 changes: 19 additions & 0 deletions src/assets/evaluators/deepeval-lambda/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "{{ Name }}"
version = "0.1.0"
description = "AgentCore Code-Based Evaluator (DeepEval)"
requires-python = ">=3.10"
dependencies = [
"bedrock-agentcore[deepeval]",
"deepeval>=2.0.0,<3.0.0",
{{#if ModelProviderBedrock}}
"aiobotocore>=2.13.0",
{{/if}}
]

[tool.hatch.build.targets.wheel]
packages = ["."]
Loading
Loading