diff --git a/src/services/ai_session_summary.py b/src/services/ai_session_summary.py index 68dfedd..67d7745 100644 --- a/src/services/ai_session_summary.py +++ b/src/services/ai_session_summary.py @@ -41,6 +41,10 @@ Return only valid JSON, no other text.""" try: text = response.content[0].text.strip() + # Strip markdown code block if model wraps response (e.g. ```json ... ```) + if text.startswith("```"): + text = text.split("\n", 1)[1] if "\n" in text else text + text = text.rsplit("```", 1)[0].strip() data = json.loads(text) ai_title = str(data.get("title", ""))[:200] ai_result = str(data.get("result", ""))