diff --git a/services/extractor/event_classifier.py b/services/extractor/event_classifier.py index d240c69..801e0e1 100644 --- a/services/extractor/event_classifier.py +++ b/services/extractor/event_classifier.py @@ -284,9 +284,14 @@ def _parse_classification_response( ) -> GlobalEvent: """Parse raw Ollama JSON output into a GlobalEvent. + Strips markdown fences and repairs malformed JSON before parsing. Normalizes enum values and clamps numeric fields. """ - data = json.loads(raw_json) + from services.extractor.client import _strip_markdown_fences, _repair_json + + cleaned = _strip_markdown_fences(raw_json) + cleaned = _repair_json(cleaned) + data = json.loads(cleaned) confidence = data.get("confidence", 0.5) if isinstance(confidence, (int, float)):