clean_json_response corrupts JSON values containing code fences
Bug Description
clean_json_response in src/memos/mem_os/utils/format_utils.py strips markdown code fences with a global response.replace("```json", "").replace("```", ""). Any JSON **string value that itself contains a fenced code block** is silently corrupted before json.loads:
clean_json_response('```json\n{"text": "```py\\ncode```"}\n```')
# actual: '{"text": "py\\ncode"}' <- fences stripped from the value
# expected: '{"text": "```py\\ncode```"}'Both api/handlers/chat_handler.py and api/handlers/suggestion_handler.py pipe LLM responses through this function before json.loads, so suggestions and chat metadata carrying markdown snippets come back with mangled content.
Expected Behavior
Only an opening fence (with its optional json info string) at the very start and a closing fence at the very end are markup; interior occurrences must be preserved.
Environment
MemOS main (a7367d0), python 3.14.
Additional Context
Fix + red/green-verified tests ready; PR to follow referencing this issue.
Source: MemTensor/MemOS