Skip to content

Conversation

nambili-samuel
Copy link

@nambili-samuel nambili-samuel commented Sep 6, 2025

Why are these changes needed?

Related issue number

Checks

@nambili-samuel
Copy link
Author

Fix JSON serialization and add corresponding test

Description:
This PR addresses a bug in the MCP tool (autogen_ext/tools/mcp/_base.py) where JSON serialization did not set ensure_ascii=False.

Problem:

Non-ASCII characters, including Japanese, were escaped as Unicode codepoints (e.g., "\u65e5\u672c").
Escaped characters reduce readability and can degrade LLM understanding and generation quality in non-English environments.

Solution:

Updated JSON serialization in _base.py to include ensure_ascii=False.
Added a new test (test_mcp_json_serialization.py) to verify that non-ASCII characters (e.g., Japanese text) are serialized correctly without escaping.

Files Changed:

(1) python/packages/autogen-ext/src/autogen_ext/tools/mcp/_base.py
(2) python/packages/autogen-ext/tests/tools/test_mcp_json_serialization.py

Impact:

Fixes JSON serialization for non-ASCII characters. Ensures improved LLM compatibility in multilingual environments.

Testing:

Added unit tests for Japanese characters serialization.
Verified existing functionality is unaffected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant