Independent Auditing of AI Agents. Run by human or the agent itself, to answer the most crucial question in the AI Agent Economy. Is the agent doing what is supposed to do? With iFixAi you can have this answer in less than 120 seconds.
Python agent-evaluationaiai-alignmentai-evaluationai-governanceai-safetyclidiagnostic-tooleu-ai-acthallucination-detectioniso-42001llm-evaluationllm-securitynist-ai-rmfowasp-llmprompt-injectionpythonresponsible-airisk-assessmentrisk-management
fix(evaluation): preserve deterministic veto after judge budget exhaustion (#179)
Rudy Mizrahi Celeklie08f1ca8f481
diff --git a/ifixai/evaluation/pipeline.py b/ifixai/evaluation/pipeline.pyindex 7e17b03..fc5a596 100644--- a/ifixai/evaluation/pipeline.py+++ b/ifixai/evaluation/pipeline.py@@ -173,20 +173,6 @@ class EvaluationPipeline:evaluation_method=EvaluationMethod.JUDGE,extraction_error=JudgeErrorKind.EXTRACTION,)- if (- self._config.judge_max_calls > 0- and self._judge_calls_used >= self._config.judge_max_calls- ):- _logger.warning(- "Judge budget exhausted (%d/%d calls used)",- self._judge_calls_used,- self._config.judge_max_calls,- )- return PipelineResult(- passed=False,- evaluation_result="inconclusive: judge budget exhausted",- evaluation_method=EvaluationMethod.JUDGE,- )if (not criteria.deterministic_forbidden_veto@@ -217,6 +203,24 @@ class EvaluationPipeline:rubric_verdict=veto_verdict,)+ # A deterministic veto needs no judge call and remains valid after+ # the remote grading budget is exhausted.+ if (+ self._config.judge_max_calls > 0+ and self._judge_calls_used >= self._config.judge_max_calls+ ):+ _logger.warning(+ "Judge budget exhausted (%d/%d calls used)",+ self._judge_calls_used,+ self._config.judge_max_calls,+ )+ return PipelineResult(+ passed=False,+ evaluation_result="inconclusive: judge budget exhausted",+ evaluation_method=EvaluationMethod.JUDGE,+ )++# Reserve the call before the first await. Concurrent inspections# otherwise all pass the budget check while earlier calls are in# flight, exceeding the configured limit and incurring extra cost.diff --git a/ifixai/tests/evaluation/test_budget_forbidden_veto.py b/ifixai/tests/evaluation/test_budget_forbidden_veto.pynew file mode 100644index 0000000..7dc5a79--- /dev/null+++ b/ifixai/tests/evaluation/test_budget_forbidden_veto.py@@ -0,0 +1,65 @@+import asyncio++from ifixai.core.fixture_loader import load_fixture+from ifixai.core.types import (+ EvaluationCriteria,+ EvaluationPipelineConfig,+ ProviderConfig,+)+from ifixai.evaluation.analytic_judge import load_analytic_rubric, parse_rubric_verdict+from ifixai.evaluation.pipeline import EvaluationPipeline+from ifixai.inspections.b06_uncertainty_signalling.runner import (+ B06UncertaintySignalling,+)+from ifixai.providers.base import ChatProvider+++class ValidJudge:+ def __init__(self):+ self.calls = 0++ async def evaluate_with_rubric(self, response, rubric, context, context_vars):+ import json+ self.calls += 1+ return parse_rubric_verdict(json.dumps({'dimensions': [+ {'name': d.name, 'passed': True} for d in rubric.dimensions+ ]}), rubric)+++class OverconfidentSUT(ChatProvider):+ async def send_message(self, messages, config):+ return 'The result will definitely double without doubt.'+++def test_shipped_b06_veto_survives_exhausted_judge_budget():+ async def run():+ judge = ValidJudge()+ pipeline = EvaluationPipeline(EvaluationPipelineConfig(judge_max_calls=1), judge)+ rubric = await load_analytic_rubric('B06', 'comply')+ await pipeline.evaluate('The forecast is uncertain.', EvaluationCriteria(), rubric)+ fixture = load_fixture('customer_support')+ inspection = B06UncertaintySignalling()+ result = await inspection.execute(+ OverconfidentSUT(), ProviderConfig(provider='custom'), fixture,+ pipeline_config=EvaluationPipelineConfig(judge_max_calls=1), pipeline=pipeline,+ )+ assert result.evidence, result.error_message+ assert all(e.rubric_verdict is not None and e.rubric_verdict.mandatory_veto for e in result.evidence)+ assert result.score == 0.0+ assert judge.calls == pipeline.judge_calls_used == 1+ asyncio.run(run())+++def test_exhausted_budget_still_prevents_non_veto_judge_calls():+ async def run():+ judge = ValidJudge()+ pipeline = EvaluationPipeline(EvaluationPipelineConfig(judge_max_calls=1), judge)+ rubric = await load_analytic_rubric('B06', 'comply')+ criteria = EvaluationCriteria(deterministic_forbidden_veto=True, forbidden_keywords=['will definitely'])+ first = await pipeline.evaluate('The forecast is uncertain.', criteria, rubric)+ second = await pipeline.evaluate('The forecast remains uncertain.', criteria, rubric)+ assert first.passed+ assert not second.passed and 'budget exhausted' in second.evaluation_result+ assert second.rubric_verdict is None+ assert judge.calls == 1+ asyncio.run(run())