feat(evaluation): expose evaluationReferenceInputs on EvaluatorInput - #540
Merged
Conversation
Code-based evaluators now receive ground-truth reference inputs in the Lambda event's evaluationReferenceInputs field, but EvaluatorInput dropped it. Add a typed ReferenceInput model and a reference_inputs list on EvaluatorInput, populated by the @custom_code_based_evaluator decorator. Backward compatible: existing evaluators ignore the new field. Closes #539
Contributor
✅ No Breaking Changes DetectedNo public API breaking changes found in this PR. |
Contributor
|
Claude Security Review: the review did not analyze this PR (model took 0 turns). See the run for details; a later push or re-run is needed. |
…uatorInput The Lambda event carries evaluatorId and evaluatorName (top-level, per the code-based-evaluator input schema) but EvaluatorInput dropped both. Map them to optional evaluator_id/evaluator_name fields so evaluators can log or branch on which evaluator config invoked them.
Contributor
|
Claude Security Review: the review did not analyze this PR (model took 0 turns). See the run for details; a later push or re-run is needed. |
aidandaly24
approved these changes
Jun 23, 2026
Contributor
|
Claude Security Review: the review did not analyze this PR (model took 0 turns). See the run for details; a later push or re-run is needed. |
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.
Issue
Closes #539
Description of changes
The Lambda event for code-based evaluators carries fields that
EvaluatorInputdropped, so evaluator functions had no typed access to them. This adds the missing ones (see input schema).Ground truth (
evaluationReferenceInputs)ReferenceInputmodel for a single reference entry (context,expected_response,assertions,expected_trajectory), with camelCase aliases matching the wire format and anexpected_response_textconvenience property.reference_inputs: List[ReferenceInput]field onEvaluatorInput, populated by the decorator fromevent["evaluationReferenceInputs"].ReferenceInputis exported from bothcustom_code_based_evaluatorsand the top-levelevaluationpackage.Evaluator identity (
evaluatorId/evaluatorName)evaluator_id/evaluator_namefields onEvaluatorInput, mapped by the decorator. Lets an evaluator log or branch on which evaluator config invoked it.Usage
Notes
expected_responseis modeled as an object ({"text": "..."}), not a bare string, matching the contract. Theexpected_response_textproperty encodes this so callers don't misread it.ReferenceInputusesextra="allow", so unknown/future keys in a reference entry are preserved (reachable viaref.model_extra) instead of dropped.ReferenceInputs(plural, client-side ground-truth input). This addsReferenceInput(singular, the parsed evaluator-side entry) — opposite ends of the same contract.Testing
uv run pytest tests/bedrock_agentcore/evaluation/custom_code_based_evaluators/— 31 passed. New tests cover decorator pass-through (reference inputs + evaluator id/name), default-empty/None, alias coercion, extra-key preservation, and theexpected_response_textproperty.ruff checkandruff format --checkclean.