mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
fix(hindsight): preserve non-ASCII text in retained conversation turns
This commit is contained in:
@@ -890,7 +890,7 @@ class HindsightMemoryProvider(MemoryProvider):
|
|||||||
if session_id:
|
if session_id:
|
||||||
self._session_id = str(session_id).strip()
|
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._session_turns.append(turn)
|
||||||
self._turn_counter += 1
|
self._turn_counter += 1
|
||||||
self._turn_index = self._turn_counter
|
self._turn_index = self._turn_counter
|
||||||
|
|||||||
@@ -531,6 +531,22 @@ class TestSyncTurn:
|
|||||||
if provider._sync_thread:
|
if provider._sync_thread:
|
||||||
provider._sync_thread.join(timeout=5.0)
|
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
|
# System prompt tests
|
||||||
|
|||||||
Reference in New Issue
Block a user