Repository navigation
fix(tier3): score goal_accuracy with RAGAS for eligible OpenAI judges - #286
Conversation
The verifier's RAGAS goal scorer passed a SingleTurnSample to the RAGAS 0.4 collections AgentGoalAccuracyWithReference metric, which takes the conversation messages and the reference as keyword arguments. The call failed before any request was sent, so every trial that should use RAGAS (the openai provider on the canonical endpoint with a non-reasoning judge such as gpt-4.1) silently fell back to the custom prompt judge, with only an info-level log line. The documented scorer never ran. Call metric.ascore(user_input=..., reference=...) and drop the unused SingleTurnSample import from the verifier and its image import smoke check. After scoring, cancel any work a judge deadline left pending and close the AsyncOpenAI client within a short bound; a close failure is logged by type only and never hides the score or the scorer's error. Record the RAGAS judge model like the prompt judges do, so goal_accuracy keeps judge_model_used, judge_reasoning_effort and judge_fallback_used for lift's mixed-judge check. When RAGAS fails and the prompt judge takes over, log a warning with the redacted error. Trials with eligible judges now report goal_accuracy with method "ragas" instead of "custom". Default GPT-5 and GPT-6 judges skip RAGAS and are unaffected. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
9c531c8 to
b1a1948
Compare
Build the metric inside the try block so a failure in llm_factory or the metric constructor still closes the AsyncOpenAI client before the custom goal judge runs. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Narendran Raghavan <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Verified the new call shape against the real ragas 0.4.3 AgentGoalAccuracyWithReference.ascore(user_input, reference) signature (it reaches the network layer with keyword arguments), and the provenance recording and docs/CHANGELOG are consistent. ruff is clean and tests/tier3 passes locally. One P3, fixed in 222ec15.
Reviewed with Claude Code.
Conflicted files: CHANGELOG.md Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts: CHANGELOG.md Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
chrisknvidia
left a comment
There was a problem hiding this comment.
The keyword call into the RAGAS collections metric, the cleanup in the finally block and the provenance recording all look right, and I checked them against _call_required_judge and the lift mixed-judge check that consume them. Two non-blocking points: lift still cannot tell a RAGAS score from a prompt-judge score that used the same model, and the deadline test does not assert the new cleanup.
Conflicted: docs/tier3-live-evaluation.mdx. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
A case scored by RAGAS in one arm and by the prompt judge in the other used the same judge model on both sides, so lift paired the two scores. The collector now tags a RAGAS-scored judge model as "<model> (ragas)" when it compares arms, so these cases are left out of the goal_accuracy lift and counted in judge_mixed_cases like a model fallback. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s the client The time-budget test only checked the error status and score, so it would still pass if the cleanup only closed the event loop. It now runs once with the scorer's own timeout and once with the judge deadline alarm stopping the loop mid-score, and asserts that the cut-off scoring work is cancelled and the OpenAI client is closed exactly once. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the CHANGELOG.md conflict: keep main's new Unreleased entry and put this PR's entry after it. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Name the eligible judges by what the code checks (an OpenAI judge outside the GPT-5 and GPT-6 families) rather than by gpt-4.1, which OpenAI is retiring from its API. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the CHANGELOG.md conflict: keep main's Ctrl+C entry (#291) and add this PR's RAGAS scorer entry after it. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
chrisknvidia
left a comment
There was a problem hiding this comment.
Follow-up on the current head. Both earlier points are fixed. _reward_judge_models now tags a RAGAS-scored judge model as <model> (ragas), so a RAGAS score never pairs with a prompt-judge score from the same model, and the multi-step path collects its step models through the same function. The deadline test now asserts that pending work is cancelled and the client is closed once. The CHANGELOG wording change reads fine. Nothing further from me.
Resolve the CHANGELOG.md conflict: keep main's SkillSpector partial-scan entry (#294) and add this PR's RAGAS scorer entry after it. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve conflicts with #303's judge contract: - judge_goal_accuracy: keep this PR's redacted warning when RAGAS falls back, plus main's judge_attempts.json records for the failed and the accepted RAGAS attempt. - _judge_goal_accuracy_ragas: keep main's binary-score check (which also rejects NaN) in place of the finite check, plus this PR's judge-model provenance and _record_judge_call. - docs/tier3-live-evaluation.mdx: describe both the non-binary fallback and the warning and method fields. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Combine binary-score validation and judge-attempt evidence with the RAGAS collections API fix and judge provenance. Bound cancellation and client cleanup, preserve scorer outcomes, and consume late task failures without logging credentials. Signed-off-by: Narendran Raghavan <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
Summary
AgentGoalAccuracyWithReferencemetric the way its API expects,metric.ascore(user_input=..., reference=...), instead of passing aSingleTurnSample. Drop the unusedSingleTurnSampleimport from the verifier and from the image's verifier import check.AsyncOpenAIclient within a short bound. If closing fails, only the exception type is logged, and the failure never hides the score or the scorer's own error.goal_accuracythen carriesjudge_model_used,judge_reasoning_effortandjudge_fallback_used, and lift's mixed-judge check can see it.docs/tier3-live-evaluation.mdx, RAGAS goal scorer) and a CHANGELOGFixedentry.Why
The RAGAS path in
goal_accuracyruns for theopenaiprovider onhttps://api.openai.com/v1with a judge that is not a GPT-5 or GPT-6 reasoning model. The docs say this setup uses the RAGAS scorer. In practice the scorer never ran. The verifier pinsragas~=0.4.0, and that version's collections metric takes keyword arguments. Building aSingleTurnSamplefrom a message list fails pydantic validation, and the positional call would fail anyway becausereferenceis missing. Both failures happened before any request was sent. The broadexceptthen switched to the prompt judge and logged one info line, so every eligible trial quietly reported"method": "custom". The existing unit-test stub (ascore(self, _sample)) accepted the wrong call shape, which hid the bug.I checked this against the real
ragas==0.4.3package with a mocked OpenAI transport:main, the scorer failed with aSingleTurnSamplevalidation error and sent no requests. It fell back to the custom judge, and the client was never closed."method": "ragas"withjudge_model_used: gpt-4.1. The client was closed.User-visible change: trials with eligible judges now report
goal_accuracyfrom RAGAS ("method": "ragas"), so their scores and lift can differ from earlier runs. Default judges (GPT-5 and GPT-6) skip RAGAS and are unaffected.Kept from public
_ragas_goal_accuracy_enabledstays as is: OpenAI only, canonical endpoint only, no reasoning models, and off whenSKILL_EVAL_JUDGE_CHARACTER_FACTSselects the prompt goal judge. RAGAS is never used as a fallback for the agent's key, and a custom base URL is never sent to RAGAS.asyncio.wait_forwith the remaining per-judge time, and theSIGALRMdeadline in_call_required_judgestill applies. No separate RAGAS budget or SDK retry policy is added.Tests
test_ragas_goal_scorer_uses_the_collections_keyword_contractdrivesjudge_goal_accuracythrough_call_required_judgeusing the real eligibility checks (SKILL_EVAL_LLM_PROVIDER=openai,LLM_JUDGE_MODEL=gpt-4.1,SKILL_EVAL_JUDGE_CHARACTER_FACTSunset). Its fake metric has the RAGAS 0.4ascore(user_input, reference)signature, and its fakeSingleTurnSampleraises an error if used. The test asserts:test_ragas_goal_scorer_failure_warns_and_closes_its_client, run with close succeeding and with close failing, checks:test_ragas_goal_judge_obeys_the_required_judge_time_budgetnow uses the same keyword-only fake and the real eligibility checks.main, all four RAGAS tests fail. On this branch they pass.pytest tests/tier3 tests/test_llm_judge.py tests/test_tier3_public_runtime.py tests/test_harbor_runtime_skill_isolation.py tests/test_character_facts.py tests/test_harbor_adapter_safety.py tests/test_verifier_error_redaction.py tests/test_oss_packaging.py tests/test_benchmark_rollout_docs.py tests/test_ci_change_classifier.py tests/test_accuracy_arithmetic.py: 7319 passed, 2 skipped. The one failure,test_fifo_dataset_is_rejected_without_blocking, was a 5-second subprocess timeout under parallel load. That test does not exercise this change, and it passes when rerun on its own.ruff checkandruff format --checkpass on all changed Python files.🤖 Generated with Claude Code