You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
memos_search returns Chinese text as \uXXXX unicode escapes (Hermes adapter missing ensure_ascii=False) #2255
When calling memos_search / memos_timeline / memos_skill_get etc. through the Hermes adapter, Chinese content in the returned JSON is rendered as \uXXXX unicode escapes instead of readable UTF-8 text.
instead of the actual Chinese characters. The data itself is correct in the DB; only the JSON returned to the host LLM is escaped.
Root cause
In the Hermes adapter adapters/hermes/memos_provider/__init__.py, the json.dumps(...) calls that serialize tool results to the LLM are missing ensure_ascii=False. Python's default is ensure_ascii=True, which escapes all non-ASCII characters to \uXXXX.
Affected lines (as of 2.0.15): memos_search (~1531), memos_get (~1580), memos_timeline (~1599), memos_skill_list (~1605), memos_environment (~1614 and ~1641), memos_skill_get (~1670).
Notably, a few other json.dumps calls in the same file DO already pass ensure_ascii=False (e.g. ~742, ~1015, ~1021), so this is just inconsistent — the tool-result serializers were missed.
Impact
For Chinese (and any non-ASCII) users, every memory retrieval result is hard to read and increases token/cognitive load on the host LLM. Functional correctness of retrieval is unaffected.
Suggested fix
Add ensure_ascii=False to the json.dumps(...) calls that serialize tool results back to the host (the ones listed above). One-line change each; verified it fixes the escape issue locally on 2.0.15.
Summary: Fixed #2255: Chinese memory content returned by the Hermes adapter's memos_* tools was being serialized to the host LLM as \uXXXX escapes because every json.dumps(...) inside MemTensorProvider.handle_tool_call (apps/memos-local-plugin/adapters/hermes/memos_provider/init.py) relied on Python's default ensure_ascii=True. Data in the DB was always correct; only the on-wire JSON was mangled, inflating tokens and making retrieval unreadable for Chinese users.
Added ensure_ascii=False to every json.dumps call inside handle_tool_call — both the tool-result branches called out in the issue (memos_search, memos_get trace/policy/world_model, memos_timeline, memos_skill_list, memos_environment list+query, memos_skill_get) and the error / fallthrough branches. The uniform pattern matches the three json.dumps calls elsewhere in the same file (L742/1015/1021) that already set the flag.
Added HandleToolCallEnsureAsciiTests to apps/memos-local-plugin/tests/python/test_hermes_provider_pipeline.py — 8 regression cases that assert each affected tool returns raw Chinese characters, contains no \u escape marker, and round-trips through json.loads. Confirmed the tests fail without the fix and pass with it. Full test file test_hermes_provider_pipeline.py is 35/35 green (27 pre-existing + 8 new); ruff check and ruff format --check both clean on the touched files.
Categorized as an opsp Bug quick-fix (no proposal/spec/design), one-line change per return statement. Committed on bugfix/autodev-2255-20260816025022257 and pushed to origin. Reviewers: @whipser030, @hijzy.
Activity
Memtensor-AI commentedon Aug 16, 2026
🤖 AutoDev has picked up this issue and started working on it.
Task ID:
48b062ae885009c2Working branch:
bugfix/autodev-2255-20260816025022257Target branch:
latest dev* branchWorkflow: opsp (analysis → coding → testing → PR)
I will post the PR link here once done. If I need more information, I will ask in the comments.
fix(hermes-adapter): pass ensure_ascii=False in handle_tool_call json…
Memtensor-AI commentedon Aug 16, 2026
✅ AutoDev task
48b062ae885009c2completed.Summary: Fixed #2255: Chinese memory content returned by the Hermes adapter's memos_* tools was being serialized to the host LLM as
\uXXXXescapes because everyjson.dumps(...)insideMemTensorProvider.handle_tool_call(apps/memos-local-plugin/adapters/hermes/memos_provider/init.py) relied on Python's defaultensure_ascii=True. Data in the DB was always correct; only the on-wire JSON was mangled, inflating tokens and making retrieval unreadable for Chinese users.Added
ensure_ascii=Falseto everyjson.dumpscall insidehandle_tool_call— both the tool-result branches called out in the issue (memos_search, memos_get trace/policy/world_model, memos_timeline, memos_skill_list, memos_environment list+query, memos_skill_get) and the error / fallthrough branches. The uniform pattern matches the threejson.dumpscalls elsewhere in the same file (L742/1015/1021) that already set the flag.Added
HandleToolCallEnsureAsciiTeststoapps/memos-local-plugin/tests/python/test_hermes_provider_pipeline.py— 8 regression cases that assert each affected tool returns raw Chinese characters, contains no\uescape marker, and round-trips throughjson.loads. Confirmed the tests fail without the fix and pass with it. Full test filetest_hermes_provider_pipeline.pyis 35/35 green (27 pre-existing + 8 new);ruff checkandruff format --checkboth clean on the touched files.Categorized as an opsp Bug quick-fix (no proposal/spec/design), one-line change per return statement. Committed on bugfix/autodev-2255-20260816025022257 and pushed to origin. Reviewers: @whipser030, @hijzy.
Base branch:
mainBranch:
bugfix/autodev-2255-20260816025022257Commit:
fa4bb36PR: #2256
Assigned to: @syzsunshine219
Reviewers: @whipser030, @hijzy
Fix #2255: memos_search returns Chinese text as \uXXXX unicode escape…
fix(hermes-adapter): pass ensure_ascii=False in handle_tool_call json…
Fix MemTensor#2255: memos_search returns Chinese text as \uXXXX unico…