Skip to content

fix(tests): stop a live-provider eval test from grading the mock - #502

Merged
guangyu-reflexio merged 1 commit into
mainfrom
fix/eval-live-tests-assert-unpatched
Sep 12, 2026
Merged

guangyu-reflexio merged 1 commit into
mainfrom
fix/eval-live-tests-assert-unpatched

Conversation

@guangyu-reflexio

@guangyu-reflexio guangyu-reflexio commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

The claim that was false

Five tests under tests/eval/ build a real LiteLLMClient and say so in their docstrings — "Real end-to-end smoke: live extractors + real LLM", "Smoke test against a real judge model".

None of them can reach a provider. Per .claude/rules/testing-conventions.md, a live test does that only if it lives under tests/e2e_tests/ and carries requires_credentials. These satisfy neither, so _is_e2e_test_run installs the session-wide litellm.completion patch and they grade canned text.

Measured, not argued

RUN_LOW_PRIORITY=1 is the only way these ever run. With it:

before: 4 failed, 44 passed
after:  5 failed, 43 passed

One test flipped: test_live_extraction_provider_real. It was PASSING — reporting a green live-LLM smoke while grading mock output. That is the bug.

The other four were already failing, but for a reason that named the wrong thing — StructuredOutputParseError / StructuredOutputRepairError, i.e. "the canned response does not fit the schema", when the actual problem is that a canned response is in play at all.

The fix

Each of the five now calls assert_litellm_unpatched() — the backstop this repo already ships for exactly this case, and which the e2e live tests already use. One false pass becomes an honest failure; four confusing failures name their real cause:

AssertionError: litellm.completion is patched, so this live-provider test would
assert against canned mock text. Live tests belong under tests/e2e_tests/ and
must carry the requires_credentials marker; the e2e conftest lifts the session
patch for those.

What this deliberately does not do

It does not move them under tests/e2e_tests/. That is the other half of the documented recipe and would make them actually run — but they depend on tests/eval/'s own fixtures and provider factories, so relocating them is a larger change than making them honest. Worth doing separately if you want these live smokes to earn their keep.

They remain @skip_low_priority, so the default suite is unchanged.

Test Plan

Local, as Actions has no budget:

Check Result
ruff check + ruff format --check on tests/eval/ clean
pytest tests/eval (normal run) 93 passed, 5 skipped, exit 0
Full OSS suite 6220 passed, 101 skipped, exit 0

The before/after comparison above was produced by reverting the three files, re-running, and restoring them from byte-exact copies verified by checksum — not by trusting git checkout -- to bring the work back.

Summary by CodeRabbit

  • Tests
    • Added safeguards to real-model evaluation tests to verify that test mocks are inactive before making live model calls.
    • Improved reliability of consolidation, extraction, and scenario evaluation smoke tests.

Five tests under `tests/eval/` build a real `LiteLLMClient` and say so --
"Real end-to-end smoke: live extractors + real LLM", "Smoke test against a real
judge model". None of them can reach a provider. Per
`.claude/rules/testing-conventions.md` a live test does that only if it lives
under `tests/e2e_tests/` AND carries `requires_credentials`; these satisfy
neither, so `_is_e2e_test_run` installs the session-wide `litellm.completion`
patch and they talk to canned text.

Measured with `RUN_LOW_PRIORITY=1`, which is the only way these ever run:

  before: 4 failed, 44 passed
  after:  5 failed, 43 passed

The single test that flipped is `test_live_extraction_provider_real`. It was
PASSING -- reporting a green live-LLM smoke while grading mock output. That is
the bug.

The other four were already failing, but for a reason that named the wrong
thing: `StructuredOutputParseError` / `StructuredOutputRepairError`, i.e. "the
canned response does not fit the schema", when the actual problem is that a
canned response is being used at all.

Each now calls `assert_litellm_unpatched()` -- the backstop this repo already
ships for exactly this, and which the e2e live tests already use. One false pass
becomes an honest failure; four confusing failures name their real cause:

  AssertionError: litellm.completion is patched, so this live-provider test
  would assert against canned mock text. Live tests belong under
  tests/e2e_tests/ and must carry the requires_credentials marker; the e2e
  conftest lifts the session patch for those.

Not moved under `tests/e2e_tests/`, which is the other half of the documented
recipe and would make them actually run: they depend on `tests/eval/`'s own
fixtures and providers, so relocating them is a larger change than making them
honest. They remain `@skip_low_priority`, so the default suite is unaffected --
`tests/eval` is 93 passed, 5 skipped, and the full OSS suite 6220 passed.
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: c8891705-ceaa-465f-9cc8-396f22970719

📥 Commits

Reviewing files that changed from the base of the PR and between c86bc7d and 8ab4572.

📒 Files selected for processing (3)
  • tests/eval/consolidation/test_consolidation_eval.py
  • tests/eval/extraction/test_extraction_eval.py
  • tests/eval/scenarios/test_scenario_eval.py

Included review availability: Your plan provides up to 5 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The evaluation smoke tests now verify that litellm.completion is unpatched before real consolidation, extraction, judge, and scenario model calls.

Changes

Evaluation guards

Layer / File(s) Summary
Real-model LiteLLM guards
tests/eval/consolidation/test_consolidation_eval.py, tests/eval/extraction/test_extraction_eval.py, tests/eval/scenarios/test_scenario_eval.py
The tests import assert_litellm_unpatched and call it before real-provider, judge, and scenario model execution.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Suggested reviewers: yilu331

Merge Risk: ⚪ Minimal · up to 8ab45

The tests now fail explicitly instead of silently grading mocked responses.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: preventing live-provider evaluation tests from grading mocked responses.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 3 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/eval-live-tests-assert-unpatched

Comment @coderabbitai help to get the list of available commands.

@guangyu-reflexio
guangyu-reflexio merged commit bdd1313 into main Sep 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant