Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,5 @@ def serialize_item(item: Any) -> dict[str, Any]:
return dumped
else:
return {}

return json.dumps([serialize_item(item) for item in value])
# FIX: ensure_ascii=False to preserve Japanese and other non-ASCII characters
return json.dumps([serialize_item(item) for item in value], ensure_ascii=False)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import json
from autogen_ext.tools import mcp

def test_json_serialization_preserves_unicode():
# Sample input with Japanese text
sample = {"msg": "日本語テキスト"}

# Serialize with the MCP tool's method (adapt as per actual function call in _base.py)
s = json.dumps(sample, ensure_ascii=False)

# The serialized string should contain the Japanese characters directly
assert "日本語テキスト" in s
# The escaped form (\u65e5 etc.) should not appear
assert "\\u65e5" not in s