Zhuoxi2000 opened a new pull request, #1501:
URL: https://github.com/apache/flink-agents/pull/1501
<!--
* Thank you very much for contributing to Flink Agents.
* Please add the relevant components in the PR title. E.g., [api],
[runtime], [java], [python], [hotfix], etc.
-->
<!-- Please link the PR to the relevant issue(s). Hotfix doesn't need this.
-->
Linked issue: #1500
### Purpose of change
<!-- What is the purpose of this change? -->
A Python sub-agent that returns a dict or a list had its non-ASCII text
escaped as `\uXXXX` in the tool message handed back to the model.
`to_chat_message_content` called `json.dumps` without `ensure_ascii=False`.
It now keeps the text as is, like Java's
`ToolResultUtils.toChatMessageContent` and like `to_tool_response` in the same
file.
### Behavioral Semantics
<!-- For a non-trivial code change whose implementation is largely
AI-assisted: interaction decisions, behavioral contracts, and failure behavior.
See `contribution-guides/ai-assisted-pr.md`. Remove this heading and this
comment otherwise. -->
| Sub-agent result | Tool message before | Tool message now |
| ---------------- | ------------------- | ---------------- |
| `{"city": "北京"}` | `{"city":"北京"}` | `{"city":"北京"}` |
| `["café"]` | `["café"]` | `["café"]` |
| `"北京"` (a string) | `北京` | `北京` (unchanged) |
ASCII-only results, scalars and `None` render as before.
### Tests
<!-- How is this change verified? -->
- `test_chat_message_content_keeps_non_ascii_text_in_containers` in
`test_tool_result_utils.py` fails on `main` and passes with the fix.
- `ToolResultUtilsTest.chatMessageContentKeepsNonAsciiTextInContainers` pins
the same output on the Java side, which already behaved this way.
- Python `plan/tests/actions` and `runtime/tests`: 1000 passed; the 4
failures in `test_media_durable.py` also fail on `main` here. `mvn verify -pl
plan` passes (928 tests). Ruff is clean.
### API
<!-- Does this change touches any public APIs? -->
No public API change.
### Documentation
<!-- Do not remove this section. Check the proper box only. -->
- [ ] `doc-needed` <!-- Your PR changes impact docs -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-included` <!-- Your PR already contains the necessary
documentation updates -->
### Was this patch authored or co-authored using generative AI tooling?
<!-- Do not remove this section. Check the proper box only. -->
- [x] Yes
- [ ] No
If yes, include a `Generated-by: <tool name and version> (<model name and
version>)` line, for example `Generated-by: Claude Code 2.1.226 (Claude Opus
4.6)`, in the commit message so it reaches Git history. Repeat the same line
here for reviewer visibility. See the [ASF generative tooling
guidance](https://www.apache.org/legal/generative-tooling.html).
Generated-by: Claude Code 2.1.259 (Claude Fable 5.2)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]