diff --git a/plugins/memory/hindsight/__init__.py b/plugins/memory/hindsight/__init__.py index b3126a0b2f..c40a65b3f3 100644 --- a/plugins/memory/hindsight/__init__.py +++ b/plugins/memory/hindsight/__init__.py @@ -890,7 +890,7 @@ class HindsightMemoryProvider(MemoryProvider): if session_id: self._session_id = str(session_id).strip() - turn = json.dumps(self._build_turn_messages(user_content, assistant_content)) + turn = json.dumps(self._build_turn_messages(user_content, assistant_content), ensure_ascii=False) self._session_turns.append(turn) self._turn_counter += 1 self._turn_index = self._turn_counter diff --git a/tests/plugins/memory/test_hindsight_provider.py b/tests/plugins/memory/test_hindsight_provider.py index db86f7626f..d916b25059 100644 --- a/tests/plugins/memory/test_hindsight_provider.py +++ b/tests/plugins/memory/test_hindsight_provider.py @@ -531,6 +531,22 @@ class TestSyncTurn: if provider._sync_thread: provider._sync_thread.join(timeout=5.0) + def test_sync_turn_preserves_unicode(self, provider_with_config): + """Non-ASCII text (CJK, ZWJ emoji) must survive JSON round-trip intact.""" + p = provider_with_config() + p._client = _make_mock_client() + p.sync_turn("안녕 こんにちは 你好", "👨‍👩‍👧‍👦 family") + p._sync_thread.join(timeout=5.0) + p._client.aretain_batch.assert_called_once() + item = p._client.aretain_batch.call_args.kwargs["items"][0] + # ensure_ascii=False means non-ASCII chars appear as-is in the raw JSON, + # not as \uXXXX escape sequences. + raw_json = item["content"] + assert "안녕" in raw_json + assert "こんにちは" in raw_json + assert "你好" in raw_json + assert "👨‍👩‍👧‍👦" in raw_json + # --------------------------------------------------------------------------- # System prompt tests