feat(project): add project add evaluator llm-as-a-judge - #2124
Draft
notgitika wants to merge 1 commit into
Draft
Conversation
Adds a CLI command to attach a custom LLM-as-a-Judge evaluator to a
project. The judge is another LLM prompted with scoring instructions
and a rating scale, written into spec.evaluators (deployed as an
AWS::BedrockAgentCore::Evaluator by the existing CDK constructs).
- New `evaluator` subrouter under `project add` with an
`llm-as-a-judge` subcommand.
- Flags: --name, --level (SESSION|TRACE|TOOL_CALL), --model
(Bedrock id/ARN), --instructions (inline/file:///stdin),
--rating-scale (preset) | --rating-scale-file (custom JSON),
--description, --kms-key-arn, --tags.
- Rating-scale presets: 1-5-quality, 1-3-simple, pass-fail,
good-neutral-bad; expand into the schema's numerical/categorical
shapes with judge-facing definitions.
- Validate instruction placeholders per level ({context}, etc.),
mirroring the CreateEvaluator API's InstructionValidator so bad
instructions are rejected locally at 'add'/'build' instead of at
deploy time as an opaque CloudFormation rollback.
- Wire the new `evaluator` resource type through AddResourceInput and
FsProjectManager.addResource / toProjectSpecKey.
Verified end-to-end: 'project add evaluator llm-as-a-judge' +
'project deploy' provisions a real evaluator (CREATE_COMPLETE).
Contributor
|
Claude Security Review: no high-confidence findings. (run) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## refactor #2124 +/- ##
==========================================
Coverage 97.42% 97.43%
==========================================
Files 429 432 +3
Lines 26314 26550 +236
==========================================
+ Hits 25637 25869 +232
- Misses 677 681 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Looks good
Nice PR — well-structured and consistent with sibling add subcommands. Highlights:
- Handler is a thin flag-parsing layer;
EvaluatorSchema.safeParseis the single source of truth for validation. - Tests use real temp directories and drive the CLI end-to-end via
createRootHandler(no fs mocks) — mocking is limited toTestCoreClient/TestGlobalConfigAccessorat true I/O boundaries.test.eachcovers all validation branches. - Placeholder validator in
src/projectSchemas/evaluator.tsfails fast locally with a clear message instead of surfacing as a CloudFormation rollback at deploy time.structuredCloneon presets inresolvePresetguards against downstream mutation of the shared table. - Wiring through
AddResourceInput,FsProjectManager.addResource, andtoProjectSpecKeyis correct and matches the existing pattern.
A couple of very minor observations, not blockers:
LEVEL_ALLOWED_PLACEHOLDERSduplicates a list that lives server-side inInstructionValidator; if the service ever expands the allowed set (e.g. lifts the account-feature gate on skill placeholders for non-TOOL_CALLlevels), this table will silently reject valid instructions. A short comment pointing at the service source is already there; consider a follow-up to keep them in sync (or accept unknown placeholders with a warning rather than a hard error).findInstructionPlaceholderstrims whitespace inside{ ... }, so{ context }passes local validation but is sent to Bedrock verbatim. If the service does exact matching, the local check would be a false positive. Cheap fix if it matters: don't trim, or normalize the stored instructions.
Neither of these needs to be addressed before merging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
agentcore project add evaluator llm-as-a-judge. this attaches a custom LLM-as-a-Judge evaluator to a project. The judge is another LLM prompted with scoring instructions and a rating scale, written intospec.evaluatorsinagentcore.json. The existing CDK constructs render it as anAWS::BedrockAgentCore::Evaluator, soproject deployprovisions it.Command
Details
evaluatorsubrouter underproject addwith anllm-as-a-judgesubcommand (mirrors thecredentialssubrouter pattern). Wires a newevaluatorresource type throughAddResourceInputandFsProjectManager.addResource/toProjectSpecKey.1-5-quality,1-3-simple,pass-fail,good-neutral-bad) that expand into the schema's numerical/categorical shapes with judge-facing definitions, plus--rating-scale-filefor a fully custom scale.file://<path>, or-(stdin) via the sharedSourceResolver.{context}for SESSION) and use no placeholder outside that level's set. This mirrorsAgentCoreEvaluationControlPlaneService'sInstructionValidator, so invalid instructions are rejected locally atadd/buildinstead of surfacing as an opaque CloudFormation rollback at deploy time.Testing
file://instructions, description/KMS/tags, duplicate name, invalid spec, and all validation error paths) and for the schema-level placeholder validation.project add evaluator llm-as-a-judge→project deployprovisions a realAWS::BedrockAgentCore::Evaluator(CREATE_COMPLETE) in a dev account. Test resources were cleaned up afterward.Scope
Spec-write + deploy of the evaluator resource. Consistent with sibling
addcommands.