From bf53f2e17c34da5a1cb8fc1837ced6c299eae06d Mon Sep 17 00:00:00 2001 From: devops Date: Mon, 19 Oct 2026 14:13:00 +0000 Subject: [PATCH] fix(orchestration): tolerate raw control characters in model JSON --- scripts/orchestration/orchestration_worker.py | 2 +- scripts/orchestration/test_orchestration_worker.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/orchestration/orchestration_worker.py b/scripts/orchestration/orchestration_worker.py index b5dc78fa..f10c1b86 100644 --- a/scripts/orchestration/orchestration_worker.py +++ b/scripts/orchestration/orchestration_worker.py @@ -37,7 +37,7 @@ def parse_structured_response(text: str) -> dict[str, Any]: start, end = cleaned.find("{"), cleaned.rfind("}") if start >= 0 and end > start: cleaned = cleaned[start : end + 1] - parsed = json.loads(cleaned) + parsed = json.loads(cleaned, strict=False) if not isinstance(parsed, dict): raise ValueError("Model response must be a JSON object") parsed.setdefault("summary", "") diff --git a/scripts/orchestration/test_orchestration_worker.py b/scripts/orchestration/test_orchestration_worker.py index 5d8e9ef4..1c02bc6d 100644 --- a/scripts/orchestration/test_orchestration_worker.py +++ b/scripts/orchestration/test_orchestration_worker.py @@ -35,6 +35,10 @@ class OrchestrationWorkerTests(unittest.TestCase): payload = parse_structured_response('```json\n{"summary":"ok","child_tasks":[]}\n```') self.assertEqual(payload["summary"], "ok") + def test_parse_json_with_raw_control_character(self): + payload = parse_structured_response('{"summary":"line one\nline two","child_tasks":[]}') + self.assertEqual(payload["summary"], "line one\nline two") + def test_child_task_codes_are_deterministic_and_include_parent(self): proposal = { "child_tasks": [