Summary
Thanks for Agent Framework and the Bedrock integration — it's been great to use.
When the Bedrock Converse API returns a structured json content block, BedrockChatClient serializes it to text with json.dumps(json_value). Because json.dumps defaults to ensure_ascii=True, any non-ASCII characters (CJK, emoji, accented Latin, etc.) are escaped to \uXXXX sequences and surface garbled to the user.
Location: python/packages/bedrock/agent_framework_bedrock/_chat_client.py, in _parse_message_contents:
if (json_value := block.get("json")) is not None:
contents.append(Content.from_text(text=json.dumps(json_value), raw_representation=block))
continue
Reproduction
A json content block carrying {"greeting": "你好世界", "emoji": "🎉"} is turned into the text:
{"greeting": "你好世界", "emoji": "🎉"}
instead of the readable:
{"greeting": "你好世界", "emoji": "🎉"}
Expected behavior
Non-ASCII characters should be preserved as-is, matching the rest of the codebase. The sibling OpenAI client uses ensure_ascii=False (python/packages/openai/agent_framework_openai/_chat_client.py), and 16+ call sites across the repo already pass ensure_ascii=False for user-facing / span serialization. This one line in the Bedrock client is the outlier. PR #3894 ("Python: Fix non-ascii chars in span attributes") fixed the same class of issue in observability.
Proposed fix
Add ensure_ascii=False to that single json.dumps call, with a regression test. I'd like to take this on — PR to follow.
This issue was prepared with the help of an AI agent (Claude Code); a human reviewed the reproduction and proposed fix before filing.
Summary
Thanks for Agent Framework and the Bedrock integration — it's been great to use.
When the Bedrock Converse API returns a structured
jsoncontent block,BedrockChatClientserializes it to text withjson.dumps(json_value). Becausejson.dumpsdefaults toensure_ascii=True, any non-ASCII characters (CJK, emoji, accented Latin, etc.) are escaped to\uXXXXsequences and surface garbled to the user.Location:
python/packages/bedrock/agent_framework_bedrock/_chat_client.py, in_parse_message_contents:Reproduction
A
jsoncontent block carrying{"greeting": "你好世界", "emoji": "🎉"}is turned into the text:instead of the readable:
Expected behavior
Non-ASCII characters should be preserved as-is, matching the rest of the codebase. The sibling OpenAI client uses
ensure_ascii=False(python/packages/openai/agent_framework_openai/_chat_client.py), and 16+ call sites across the repo already passensure_ascii=Falsefor user-facing / span serialization. This one line in the Bedrock client is the outlier. PR #3894 ("Python: Fix non-ascii chars in span attributes") fixed the same class of issue in observability.Proposed fix
Add
ensure_ascii=Falseto that singlejson.dumpscall, with a regression test. I'd like to take this on — PR to follow.This issue was prepared with the help of an AI agent (Claude Code); a human reviewed the reproduction and proposed fix before filing.