Skip to content

Commit a9d34be

Browse files
jariy17jariy17
andauthored
feat(eval): add ondemand evaluate (synchronous, client-side) (#1983)
Co-authored-by: jariy17 <tjariy+jariy17@users.noreply.github.com>
1 parent ea3fa84 commit a9d34be

18 files changed

Lines changed: 1842 additions & 1 deletion

src/core/eval.tsx

Lines changed: 338 additions & 0 deletions
Large diffs are not rendered by default.

src/core/types.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export type CoreFetch = (
3737
// full ClientConfig so callers can request any client customization (region,
3838
// endpoint, ...).
3939
export interface AwsClients {
40-
control(config: ClientConfig): BedrockAgentCoreControlClient;
40+
control(config: ClientConfig): BedrockAgentCoreControlClient
4141
data(config: ClientConfig): BedrockAgentCoreClient;
4242
iam(config: ClientConfig): IAMClient;
4343
// logs reads the CloudWatch Logs streams AgentCore writes batch-evaluation

src/handlers/eval/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { createEvaluatorHandler } from "./evaluator";
77
import { createOnlineEvalHandler } from "./online-eval";
88
import { createDatasetHandler } from "./dataset";
99
import { createBatchEvaluationHandler } from "./batch-evaluation";
10+
import { createOnDemandHandler } from "./ondemand";
1011
import { createConfigBundleHandler } from "./config-bundle";
1112

1213
export function createEvalHandler(core: Core, io: AppIO): Router {
@@ -17,6 +18,7 @@ export function createEvalHandler(core: Core, io: AppIO): Router {
1718
.handler(createOnlineEvalHandler(core, io))
1819
.handler(createDatasetHandler(core, io))
1920
.handler(createBatchEvaluationHandler(core, io))
21+
.handler(createOnDemandHandler(core, io))
2022
.handler(createConfigBundleHandler(core, io));
2123
}
2224

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"evaluationResults": [
3+
{
4+
"evaluatorArn": "arn:aws:bedrock-agentcore:::evaluator/Builtin.Helpfulness",
5+
"evaluatorId": "Builtin.Helpfulness",
6+
"evaluatorName": "Builtin.Helpfulness",
7+
"context": {
8+
"spanContext": {
9+
"sessionId": "67ebf93b-65e3-4127-9e13-483b239f256a",
10+
"traceId": "6a7cabfa3bfe9a7348415c7b507648a8"
11+
}
12+
},
13+
"explanation": "The user asked a simple arithmetic question ('What is 2+2?') and requested a concise answer. The assistant's response '2 + 2 = 4' directly and concisely answers the question. The tool output confirmed the answer is 4, and the assistant correctly relayed this information. The response is brief and to the point, matching the user's request for conciseness. This fully satisfies the user's goal with no unnecessary information.",
14+
"value": 0.83,
15+
"label": "Very Helpful",
16+
"tokenUsage": {
17+
"inputTokens": 941,
18+
"outputTokens": 118,
19+
"totalTokens": 1059
20+
}
21+
}
22+
]
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"evaluationResults": [
3+
{
4+
"evaluatorArn": "arn:aws:bedrock-agentcore:::evaluator/Builtin.Helpfulness",
5+
"evaluatorId": "Builtin.Helpfulness",
6+
"evaluatorName": "Builtin.Helpfulness",
7+
"context": {
8+
"spanContext": {
9+
"sessionId": "7f983b9f-9569-4a4d-bdc2-5c997ff346dd",
10+
"traceId": "6a7cac0e3fa42bfe5437eef070d1231c"
11+
}
12+
},
13+
"explanation": "The user's goal was simple: to have a primary color named. The assistant directly answered the question by naming 'red' as a primary color. Beyond just answering the question, the assistant also provided additional context about all three primary colors in both traditional color theory and the RGB model. This extra information is relevant and educational without being overwhelming. The response directly fulfills the user's request and goes a step further by providing useful context about primary colors in general, which anticipates potential follow-up questions or curiosity. This qualifies as 'Above And Beyond' since it answers the question completely and proactively addresses related information the user might find useful.",
14+
"value": 1,
15+
"label": "Above And Beyond",
16+
"tokenUsage": {
17+
"inputTokens": 859,
18+
"outputTokens": 154,
19+
"totalTokens": 1013
20+
}
21+
}
22+
]
23+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"agentRuntimeArn": "arn:aws:bedrock-agentcore:us-west-2:685197708687:runtime/asdf_MyAgent-3s5axvBC6Q",
3+
"agentRuntimeName": "asdf_MyAgent",
4+
"agentRuntimeId": "asdf_MyAgent-3s5axvBC6Q",
5+
"agentRuntimeVersion": "1",
6+
"createdAt": {
7+
"$date": "2026-04-23T21:17:21.895Z"
8+
},
9+
"lastUpdatedAt": {
10+
"$date": "2026-04-23T21:17:35.159Z"
11+
},
12+
"roleArn": "arn:aws:iam::685197708687:role/AgentCore-asdf-default-ApplicationAgentMyAgentRunti-KdyUbgImzDRK",
13+
"networkConfiguration": {
14+
"networkMode": "PUBLIC"
15+
},
16+
"status": "READY",
17+
"lifecycleConfiguration": {
18+
"idleRuntimeSessionTimeout": 900,
19+
"maxLifetime": 28800
20+
},
21+
"description": "AgentCore Runtime: asdf_MyAgent",
22+
"workloadIdentityDetails": {
23+
"workloadIdentityArn": "arn:aws:bedrock-agentcore:us-west-2:685197708687:workload-identity-directory/default/workload-identity/asdf_MyAgent-3s5axvBC6Q"
24+
},
25+
"agentRuntimeArtifact": {
26+
"codeConfiguration": {
27+
"code": {
28+
"s3": {
29+
"bucket": "cdk-hnb659fds-assets-685197708687-us-west-2",
30+
"prefix": "a07977786dda1e2e5be304cb7485237a19ed24d5e05b02e73ca91a43fd2e7280.zip"
31+
}
32+
},
33+
"runtime": "PYTHON_3_13",
34+
"entryPoint": [
35+
"opentelemetry-instrument",
36+
"main.py"
37+
]
38+
}
39+
},
40+
"environmentVariables": {
41+
"AGENTCORE_GATEWAY_BUGBASHGW1776978672_AUTH_TYPE": "NONE",
42+
"AGENTCORE_GATEWAY_BUGBASHGW1776978672_URL": "https://bugbashgw1776978672-zsy8cbqwts.gateway.bedrock-agentcore.us-west-2.amazonaws.com/mcp"
43+
},
44+
"metadataConfiguration": {
45+
"requireMMDSV2": true
46+
}
47+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"evaluatorArn": "arn:aws:bedrock-agentcore:::evaluator/Builtin.Helpfulness",
3+
"evaluatorId": "Builtin.Helpfulness",
4+
"evaluatorName": "Builtin.Helpfulness",
5+
"evaluatorConfig": {
6+
"llmAsAJudge": {
7+
"ratingScale": {
8+
"numerical": [
9+
{
10+
"value": 0,
11+
"label": "Not helpful at all"
12+
},
13+
{
14+
"value": 1,
15+
"label": "Very unhelpful"
16+
},
17+
{
18+
"value": 2,
19+
"label": "Somewhat unhelpful"
20+
},
21+
{
22+
"value": 3,
23+
"label": "Neutral/Mixed"
24+
},
25+
{
26+
"value": 4,
27+
"label": "Somewhat helpful"
28+
},
29+
{
30+
"value": 5,
31+
"label": "Very helpful"
32+
},
33+
{
34+
"value": 6,
35+
"label": "Above and beyond"
36+
}
37+
]
38+
}
39+
}
40+
},
41+
"level": "TRACE",
42+
"status": "ACTIVE",
43+
"createdAt": {
44+
"$date": "2024-10-22T00:00:00.000Z"
45+
},
46+
"updatedAt": {
47+
"$date": "2024-10-22T00:00:00.000Z"
48+
},
49+
"description": "Response Quality Metric. Evaluates from user's perspective how useful and valuable the agent's response is",
50+
"lockedForModification": true
51+
}

0 commit comments

Comments
 (0)