← Back to Pull requests

fix: handle non-list relevant_statements in ContextRelevanceEvaluator #13758

Open
unknown opened this pull request with 281 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 15, 2026 01:10 UTC
Author

Related Issues

  • fixes #13757
  • Proposed Changes:

    ContextRelevanceEvaluator._postprocess_results called len() directly on relevant_statements, so a structurally valid but malformed LLM response such as {"relevant_statements": null} raised TypeError after parsing and bypassed the raise_on_failure handling.

    The value is now validated to be a list:

  • with raise_on_failure=False, the row is logged, marked "status": "error" with a NaN score, and excluded from the aggregate score, consistent with other failed rows;

  • with raise_on_failure=True, a ValueError is raised instead of a TypeError.
  • How did you test it?

  • Added unit tests test_run_invalid_statements_value_raise_on_failure_false and test_run_invalid_statements_value_raise_on_failure_true.

  • hatch run pytest test/components/evaluators/test_context_relevance_evaluator.py → 18 passed, 2 skipped (the skipped tests require an OpenAI API key).

  • Full evaluator suite: 194 passed, 4 skipped. The SAS evaluator was excluded locally because its optional sentence-transformers dependency is not installed.

  • hatch run pre-commit run --files ... passes on the changed files.
  • Notes for the reviewer

    The validation is intentionally scoped to ContextRelevanceEvaluator. FaithfulnessEvaluator has a related output-shape validation gap that is tracked separately in #13423.

    Checklist

  • I have read the contributors guidelines and the code of conduct.

  • I have updated the related issue with new insights and changes.

  • I have added unit tests and updated the docstrings.

  • I've used one of the conventional commit types for my PR title: fix: and added ! in case the PR includes breaking changes.

  • I have documented my code.

  • I have added a release note file, following the contributors guidelines.

  • I have run pre-commit hooks and fixed any issue.
  • Diff: 281 lines (+210 / -71) across 3 files Reviewer: chrikrah Review duration: 3285m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.45) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 281 lines diff across 3 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.338
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #13758"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.7% (MEDIUM) · Higher = larger blast radius
    44.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.5% · Safe to merge
    25.5%