Zhuoxi2000 opened a new pull request, #1168: URL: https://github.com/apache/flink-agents/pull/1168
<!-- * 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: #1167 ### Purpose of change <!-- What is the purpose of this change? --> Tool results sent to DashScope now carry the `tool_call_id` of the call that produced them, as they do for the other providers. Before, the Tongyi connection kept DashScope's call id under a key the tool call action does not read, and looked for it on the tool message where the chat model action never puts it, so every tool result went out without an id. Runtime flow: `chat` now also records DashScope's call id as `original_id`, which the tool call action copies into the tool result's `external_id`; `__convert_to_tongyi_messages` sends that `external_id` as `tool_call_id`. Key decisions: use the key the other connections already use rather than teach the action about Tongyi's; keep `additional_kwargs.original_tool_call_id` and the old `tool_calls` lookup as fallbacks, so histories built before this change still convert. ### 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. --> Interaction decisions: not applicable; the tool message either has an `external_id` or falls back to the previous lookup. Behavioral contracts: 1. A parsed tool call carries DashScope's id as `original_id`. 2. An assistant message's tool calls are sent with DashScope's id. 3. A tool message with `extra_args["external_id"]` is sent with `tool_call_id` set to it. Failure behavior: none added. A tool message without an `external_id` and without tool calls is sent without `tool_call_id`, as before. ### Tests <!-- How is this change verified? --> | Contract | Test | |---|---| | 1, 2, 3 | `test_tongyi_chat_model.py::test_tool_call_ids_round_trip`, with `Generation.call` mocked; it fails on main | Not verified: a live DashScope multi-turn tool call. The Tongyi tests pass locally, with ruff. ### API <!-- Does this change touches any public APIs? --> No API change. Tongyi tool calls gain an `original_id` key; tool messages now include `tool_call_id`. ### 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 Opus 5.5) -- 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]
