Skip to content

Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.

Clarify literal final-response format checks (partial mitigation) (#509)

Narendran Raghavan868de686afe4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 55017c30..1561dea9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -157,6 +157,11 @@ All notable changes to SkillEvaluator are documented in this file.
### Fixed
+- Accuracy and Behavior judge prompts clarify that explicit final-answer formats
+ apply to the entire final response, independently of correct values in tool
+ output or references. Scoring and thresholds are unchanged; an Accuracy format
+ failure alone can still score 0.8 and pass the default threshold.
+
- Folder validation preserves author and metadata ID advisories from passing
skills. Catalog summaries include duplicate ID severity counts and consistent
member verdicts, while explicitly labeling linked reports as single-skill
diff --git a/docs/grader-validation.mdx b/docs/grader-validation.mdx
index acbb605d..2528a053 100644
--- a/docs/grader-validation.mdx
+++ b/docs/grader-validation.mdx
@@ -121,6 +121,13 @@ Scores at or above the metric threshold pass. Defaults are accuracy 0.8,
goal accuracy 1.0, security/execution/efficiency/behavior 1.0, and overall 0.5
(the Harbor pass threshold). Suite thresholds override defaults.
+Accuracy and Behavior judge prompts instruct the judge to check explicit
+final-answer formats against the entire final response. Correct values in tool
+output or references do not establish format compliance. This clarification
+does not add a critical-failure gate or establish improved semantic accuracy.
+Accuracy still averages five criteria: if only `FORMAT_FOLLOWED` is false, its
+score is 0.8 and passes the default accuracy threshold.
+
`overall` is the score policy's dimension mean, compared with the default 0.5
threshold. The shipped policy averages security, accuracy, skill execution,
goal achievement (the mean of goal_accuracy and behavior_check), and skill
diff --git a/src/skillevaluator/tier3/eval_core/llm_judge.py b/src/skillevaluator/tier3/eval_core/llm_judge.py
index 1c840e45..a1a11c99 100644
--- a/src/skillevaluator/tier3/eval_core/llm_judge.py
+++ b/src/skillevaluator/tier3/eval_core/llm_judge.py
@@ -705,6 +705,19 @@ refused), every criterion is false, unless the expected answer is itself a refus
Be lenient on wording, but strict on factual correctness and on any output format the user \
question explicitly requires.
+For FORMAT_FOLLOWED, judge the entire final response literally against only the format explicitly \
+required by the USER QUESTION, independently of factual correctness.
+When a FINAL RESPONSE section is supplied, its contents are the final answer; other section \
+headings, tool results, history, and artifacts are context, not part of that answer.
+Inspect every line of the final response, including text after an initially valid answer. \
+Line breaks do not end the final response. Do not mentally remove labels or Markdown fence characters \
+when checking the stated format.
+Do not extract a compliant answer from surrounding noncompliant text or substitute a correct \
+value from tool output or the expected answer.
+If only a number is required, extra prose, a label, or a code fence violates that requirement.
+Required prefixes, units, or prose are valid when they match the stated format.
+Wording leniency does not relax explicit format constraints.
+
Respond with ONLY one JSON object with a "criteria" object holding exactly these five keys, each \
true or false, and a one-sentence "reason". Do not include a score: it is computed from the criteria.
Example of the shape (the values are only an illustration):
@@ -888,6 +901,25 @@ CONVERSATION:
EXPECTED BEHAVIORS:
{behaviors}
+For each numbered behavior, check only what that behavior requires.
+A format-only behavior does not require the answer's value to be factually correct: a wrong value \
+can still satisfy its format. If a behavior also requires factual correctness, evaluate that requirement too.
+For a behavior about final-response format, judge the entire final response literally against only \
+the stated format requirement, independently of factual correctness.
+When a FINAL RESPONSE section is supplied, its contents are the final answer; other section \
+headings, tool results, history, and artifacts are context, not part of that answer.
+Inspect every line of the final response, including text after an initially valid answer. \
+Line breaks do not end the final response. Do not mentally remove labels or Markdown fence characters \
+when checking the stated format.
+Do not extract a compliant answer from surrounding noncompliant text or substitute a correct \
+value from tool output or the expected answer.
+If only a number is required, extra prose, a label, or a code fence violates that requirement.
+Required prefixes, units, or prose are valid when they match the stated format.
+When the complete final response establishes a format violation, mark that behavior false; \
+keep null when missing or incomplete evidence prevents checking it.
+Before returning, ensure each passed value agrees with its reason: a reason establishing a violation \
+requires false, not true; an evidence gap that prevents checking requires null.
+
Respond with ONLY one JSON object. "results" must hold exactly {expected_count} entries, one per \
expected behavior: "step" is the behavior's number (each number from 1 to {expected_count} exactly \
once), "passed" is true (observed), false (evidence supports a violation or absence), or null \
diff --git a/src/skillevaluator/tier3/harbor/templates/eval.py b/src/skillevaluator/tier3/harbor/templates/eval.py
index 28f1200e..3c70623c 100644
--- a/src/skillevaluator/tier3/harbor/templates/eval.py
+++ b/src/skillevaluator/tier3/harbor/templates/eval.py
@@ -3124,6 +3124,19 @@ refused), every criterion is false, unless the expected answer is itself a refus
Be lenient on wording, but strict on factual correctness and on any output format the user \
question explicitly requires.
+For FORMAT_FOLLOWED, judge the entire final response literally against only the format explicitly \
+required by the USER QUESTION, independently of factual correctness.
+When a FINAL RESPONSE section is supplied, its contents are the final answer; other section \
+headings, tool results, history, and artifacts are context, not part of that answer.
+Inspect every line of the final response, including text after an initially valid answer. \
+Line breaks do not end the final response. Do not mentally remove labels or Markdown fence characters \
+when checking the stated format.
+Do not extract a compliant answer from surrounding noncompliant text or substitute a correct \
+value from tool output or the expected answer.
+If only a number is required, extra prose, a label, or a code fence violates that requirement.
+Required prefixes, units, or prose are valid when they match the stated format.
+Wording leniency does not relax explicit format constraints.
+
Respond with ONLY one JSON object with a "criteria" object holding exactly these five keys, each \
true or false, and a one-sentence "reason". Do not include a score: it is computed from the criteria.
Example of the shape (the values are only an illustration):
@@ -3525,6 +3538,25 @@ CONVERSATION:
EXPECTED BEHAVIORS:
{behaviors_text}
+For each numbered behavior, check only what that behavior requires.
+A format-only behavior does not require the answer's value to be factually correct: a wrong value \
+can still satisfy its format. If a behavior also requires factual correctness, evaluate that requirement too.
+For a behavior about final-response format, judge the entire final response literally against only \
+the stated format requirement, independently of factual correctness.
+When a FINAL RESPONSE section is supplied, its contents are the final answer; other section \
+headings, tool results, history, and artifacts are context, not part of that answer.
+Inspect every line of the final response, including text after an initially valid answer. \
+Line breaks do not end the final response. Do not mentally remove labels or Markdown fence characters \
+when checking the stated format.
+Do not extract a compliant answer from surrounding noncompliant text or substitute a correct \
+value from tool output or the expected answer.
+If only a number is required, extra prose, a label, or a code fence violates that requirement.
+Required prefixes, units, or prose are valid when they match the stated format.
+When the complete final response establishes a format violation, mark that behavior false; \
+keep null when missing or incomplete evidence prevents checking it.
+Before returning, ensure each passed value agrees with its reason: a reason establishing a violation \
+requires false, not true; an evidence gap that prevents checking requires null.
+
Respond with ONLY one JSON object. "results" must hold exactly {expected_count} entries, one per \
expected behavior: "step" is the behavior's number (each number from 1 to {expected_count} exactly \
once), "passed" is true (observed), false (evidence supports a violation or absence), or null \
diff --git a/tests/tier3/test_judge_contracts.py b/tests/tier3/test_judge_contracts.py
index 64f0c819..5ae31f4d 100644
--- a/tests/tier3/test_judge_contracts.py
+++ b/tests/tier3/test_judge_contracts.py
@@ -150,6 +150,131 @@ def test_accuracy_prompt_gives_no_free_criterion_to_a_response_without_an_answer
assert "unless the expected answer is itself a refusal" in prompt
+ ("requirement", "final_response"),
+ [
+ ("Return only a number.", "83"),
+ ("Return only a number.", "82"),
+ ("Return only a number.", "83\nFinished processing."),
+ ("Return only a number.", "The computed quantity is 83.\nCalculation finished."),
+ ("Return only a number.", "Quantity: 83"),
+ ("Return only a number.", "```text\n83\n```"),
+ ("Explain the quantity.", "The computed quantity is 83."),
+ ("Use the prefix COUNT= before the quantity.", "COUNT=83"),
+ ("Return the quantity with units and a short explanation.", "83 items remain after counting."),
+ ],
+ ids=[
+ "bare-number",
+ "wrong-value-valid-format",
+ "valid-first-line-extra-line",
+ "prose",
+ "label",
+ "fence",
+ "no-format",
+ "required-prefix",
+ "required-units-prose",
+ ],
+)
+def test_format_judges_receive_complete_final_response_separate_from_tool_and_reference(
+ monkeypatch, requirement: str, final_response: str
+) -> None:
+ # Catch response extraction, evidence misframing, or drift between deployed
+ # prompts. The provider is stopped at its boundary; no semantic verdict is faked.
+ question = f"Count the available items. {requirement}"
+ trajectory = {
+ "steps": [
+ {"source": "user", "message": question},
+ {
+ "source": "agent",
+ "tool_calls": [{"tool_call_id": "count-1", "function_name": "count_items", "arguments": {}}],
+ "observation": {"results": [{"source_call_id": "count-1", "content": "83"}]},
+ },
+ {"source": "agent", "message": final_response},
+ ]
+ }
+ captured = []
+ for module, builder in (
+ (llm_judge, atif_helpers.build_metric_evidence_bundles),
+ (eval_template, eval_template.build_metric_evidence_bundles),
+ ):
+ bundles = builder(trajectory, question, ground_truth="83", expected_behavior=[requirement])
+ prompts = _capture_prompts(module, monkeypatch)
+ module.judge_accuracy(question, "83", bundles["accuracy"]["prompt_evidence"])
+ module.judge_behavior_check(bundles["behavior_check"]["prompt_evidence"], [requirement])
+ assert len(prompts) == 2
+ accuracy, behavior = prompts
+ assert "EXPECTED ANSWER:\n83\n" in accuracy
+ assert f"FINAL RESPONSE\n{final_response}\n\nKEY OBSERVATIONS\n83" in accuracy
+ assert f"FINAL RESPONSE\n{final_response}\n\nUSER REQUEST\n{question}" in behavior
+ assert "COMPACT TOOL HISTORY\n" in behavior
+ assert "count_items" in behavior
+ assert "83" in behavior.split("COMPACT TOOL HISTORY\n", 1)[1]
+ assert f"EXPECTED BEHAVIORS:\n1. {requirement}" in behavior
+ for prompt in prompts:
+ assert "judge the entire final response literally" in prompt
+ assert "independently of factual correctness" in prompt
+ assert "Do not extract a compliant answer" in prompt
+ assert "extra prose, a label, or a code fence violates that requirement" in prompt
+ assert "Required prefixes, units, or prose are valid when they match the stated format" in prompt
+ assert "Inspect every line of the final response, including text after an initially valid answer" in prompt
+ assert "Line breaks do not end the final response" in prompt
+ assert "Do not mentally remove labels or Markdown fence characters" in prompt
+ assert "Wording leniency does not relax explicit format constraints" in accuracy
+ assert "When the complete final response establishes a format violation, mark that behavior false" in behavior
+ assert "keep null when missing or incomplete evidence prevents checking it" in behavior
+ captured.append(prompts)
+ assert captured[0] == captured[1]
+
+
+def test_format_only_behavior_is_separate_from_a_stated_correctness_behavior(monkeypatch) -> None:
+ # The same wrong value can satisfy structure but violate a separate factual
+ # requirement. Capture the actual evidence/prompt, without faking a verdict.
+ question = "Count the stored entries. Return only a number."
+ behaviors = ["Return only a number.", "Return the correct count."]
+ trajectory = {
+ "steps": [
+ {"source": "user", "message": question},
+ {"source": "agent", "message": "82"},
+ ]
+ }
+ captured = []
+ for module, builder in (
+ (llm_judge, atif_helpers.build_metric_evidence_bundles),
+ (eval_template, eval_template.build_metric_evidence_bundles),
+ ):
+ bundles = builder(trajectory, question, ground_truth="83", expected_behavior=behaviors)
+ prompts = _capture_prompts(module, monkeypatch)
+ module.judge_behavior_check(bundles["behavior_check"]["prompt_evidence"], behaviors)
+ prompt = prompts[0]
+ assert f"FINAL RESPONSE\n82\n\nUSER REQUEST\n{question}" in prompt
+ assert "EXPECTED BEHAVIORS:\n1. Return only a number.\n2. Return the correct count." in prompt
+ assert "For each numbered behavior, check only what that behavior requires" in prompt
+ assert "A format-only behavior does not require the answer's value to be factually correct" in prompt
+ assert "If a behavior also requires factual correctness, evaluate that requirement too" in prompt
+ assert "ensure each passed value agrees with its reason" in prompt
+ assert "a reason establishing a violation requires false, not true" in prompt
+ assert "an evidence gap that prevents checking requires null" in prompt
+ captured.append(prompts)
+ assert captured[0] == captured[1]
+
+
+def test_format_judges_keep_direct_unsectioned_inputs_compatible(judge_module, monkeypatch) -> None:
+ prompts = _capture_prompts(judge_module, monkeypatch)
+ direct_response = "COUNT=83"
+
+ judge_module.judge_accuracy("Use the prefix COUNT=.", "83", direct_response)
+ judge_module.judge_behavior_check(direct_response, ["Use the prefix COUNT=."])
+
+ assert prompts[0].endswith(
+ "SELECTED EVIDENCE (final response + produced artifacts; low-relevance steps may be omitted):\nCOUNT=83"
+ )
+ assert "CONVERSATION:\nCOUNT=83\n\nEXPECTED BEHAVIORS:" in prompts[1]
+ for prompt in prompts:
+ assert "When a FINAL RESPONSE section is supplied" in prompt
+ assert "its contents are the final answer" in prompt
+ assert "context, not part of that answer" in prompt
+
+
def test_goal_prompt_omits_empty_tool_section_and_keeps_real_one(judge_module, monkeypatch) -> None:
calls: list[dict[str, Any]] = []
_use_goal_script(judge_module, monkeypatch, [(_GOAL_RESPONSE, None)], calls)