diff --git a/autogen/function_utils.py b/autogen/function_utils.py index dd225fd4719..6b9b6f5b129 100644 --- a/autogen/function_utils.py +++ b/autogen/function_utils.py @@ -353,4 +353,4 @@ def serialize_to_str(x: Any) -> str: elif isinstance(x, BaseModel): return model_dump_json(x) else: - return json.dumps(x) + return json.dumps(x, ensure_ascii=False) diff --git a/test/test_function_utils.py b/test/test_function_utils.py index adddbf32e26..0475044b49f 100644 --- a/test/test_function_utils.py +++ b/test/test_function_utils.py @@ -391,6 +391,10 @@ async def f( assert actual[1] == "EUR" +def test_serialize_to_str_with_nonascii() -> None: + assert serialize_to_str("中文") == "中文" + + def test_serialize_to_json() -> None: assert serialize_to_str("abc") == "abc" assert serialize_to_str(123) == "123"