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(resume): recover from unreadable checkpoint encoding (#224)
Rudy Mizrahi Celekli344cc12cac27
diff --git a/ifixai/evaluation/checkpoint.py b/ifixai/evaluation/checkpoint.pyindex a3a6d55..cdaf420 100644--- a/ifixai/evaluation/checkpoint.py+++ b/ifixai/evaluation/checkpoint.py@@ -38,7 +38,7 @@ def load_checkpoint(runs_root: Path, run_id: str) -> dict[str, TestResult]:return {}try:raw = json.loads(path.read_text(encoding="utf-8"))- except (OSError, json.JSONDecodeError) as exc:+ except (OSError, UnicodeError, json.JSONDecodeError) as exc:_logger.warning("checkpoint unreadable (%s) — starting fresh", exc)return {}if not isinstance(raw, dict):diff --git a/ifixai/tests/evaluation/test_checkpoint_validation.py b/ifixai/tests/evaluation/test_checkpoint_validation.pyindex ec95ceb..4ce2d72 100644--- a/ifixai/tests/evaluation/test_checkpoint_validation.py+++ b/ifixai/tests/evaluation/test_checkpoint_validation.py@@ -2,6 +2,8 @@import json+import pytest+from ifixai.core.types import TestResult, TestStatusfrom ifixai.evaluation.checkpoint import load_checkpoint@@ -40,3 +42,15 @@ def test_valid_completed_entry_is_reused(tmp_path):})assert load_checkpoint(tmp_path, "run-1")["B01"].status == TestStatus.PASS++[email protected]("damaged", [b"\xff", b'{"B01":"\xe2\x82'])+def test_unreadable_utf8_checkpoint_starts_fresh(tmp_path, caplog, damaged):+ run_dir = tmp_path / "run-1"+ run_dir.mkdir()+ checkpoint = run_dir / "checkpoint.json"+ checkpoint.write_bytes(damaged)++ assert load_checkpoint(tmp_path, "run-1") == {}+ assert "checkpoint unreadable" in caplog.text+ assert checkpoint.read_bytes() == damaged