You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "weiqingy (via GitHub)" <gi...@apache.org> on 2026/09/02 19:03:50 UTC

[PR] [integrations][python] Apply DashScope native structured output [flink-agents]

weiqingy opened a new pull request, #1090:
URL: https://github.com/apache/flink-agents/pull/1090

   Linked issue: #280
   
   ### Purpose of change
   
   Passing an `output_schema` to the Tongyi connection raised `NotImplementedError`, because the connection had no native translation. DashScope does support schema-enforced structured output, so this adds it.
   
   The catch is that it applies to fewer models than you might expect. DashScope documents `json_schema` for five model families, but four of them are served on its multimodal interface, while this connection calls `Generation.call` on the text-generation interface. Calling one through the other fails with `url error`. That leaves the Qwen3.7-Max family as the only place native enforcement is reachable here.
   
   So the connection reports the capability for that family, and for everything else, including the `qwen-plus` default, it sends nothing new and keeps the existing prompt-based fallback. No behavior changes for anyone not on Qwen3.7-Max.
   
   Sources for the two halves of that intersection, both worth checking against the allowlist in the diff:
   - [structured output](https://help.aliyun.com/zh/model-studio/json-mode) for which models support `json_schema`
   - [text generation](https://help.aliyun.com/zh/model-studio/text-generation) for which models are text-interface
   
   Heads-up on the docs: the DashScope API reference pages still list only `text` and `json_object` for `response_format` and never mention `json_schema`. The feature guide above is the current source, and the error reference corroborates it by naming `json_schema` as a recognised key.
   
   ### Tests
   
   New file `test_tongyi_native_structured_output.py`, 16 cases, no API key or network needed. It asserts the request the SDK would actually receive: the parameter is present and correctly shaped on a capable model, absent on every other model, absent when no schema is passed, and a non-Pydantic schema falls back instead of failing. The capability check is tested against capable names, incapable names, a lookalike (`qwen3.7-maximum`), empty string and `None`.
   
   Each assertion was verified by mutating the source and confirming the intended test fails, so the tests are not passing by accident.
   
   **One limitation, stated plainly.** No vendor source shows `json_schema` on `Generation.call`. It is documented as a parameter of the native API, with the placement rule for HTTP callers, but the only native sample uses `MultiModalConversation.call` with a model this connection excludes. Every test here is a mock and I had no DashScope key, so the suite cannot settle it. What is established: the parameter provably reaches the request body, and if the provider rejects it the call fails loudly with a `RuntimeError` rather than silently returning an unconstrained answer. **If a reviewer has a key, one live call against `qwen3.7-max` would close this.**
   
   ### API
   
   No public API change. `supports_native_structured_output` is an existing hook this connection now overrides, and no dependency changes. Python only, since there is no Java Tongyi connection.
   
   ### Documentation
   
   - [ ] `doc-needed`
   - [ ] `doc-not-needed`
   - [x] `doc-included`
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   - [x] Yes
   - [ ] No
   
   Generated-by: Claude Code 2.1.251 (Claude Opus 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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [integrations][python] Apply DashScope native structured output [flink-agents]

Posted by "weiqingy (via GitHub)" <gi...@apache.org>.
weiqingy commented on PR #1090:
URL: https://github.com/apache/flink-agents/pull/1090#issuecomment-5517313487

   The one failing check is unrelated to this PR:
   
   - **it-java [ubuntu-latest] [java-21] [flink-2.2]**: `429 Too Many Requests` from Maven Central while resolving the Apache parent POM `org.apache:apache:pom:34`. It failed in the "Install flink-agents Java" step after 42 seconds, so nothing was compiled and no test ran. [Job log](https://github.com/apache/flink-agents/actions/runs/33671037333/job/100384423887).
   
   This PR only changes Python and docs. It touches no `.java` and no `pom.xml`, and the other four `it-java` jobs in the same run passed on the same commit.
   
   Could you please help re-trigger the failed job? Thanks!
   


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [integrations][python] Apply DashScope native structured output [flink-agents]

Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 commented on code in PR #1090:
URL: https://github.com/apache/flink-agents/pull/1090#discussion_r3966385385


##########
python/flink_agents/integrations/chat_models/tongyi_chat_model.py:
##########
@@ -35,6 +36,73 @@
 DEFAULT_REQUEST_TIMEOUT = 60.0
 DEFAULT_MODEL = "qwen-plus"
 
+# Models with documented json_schema support that are also served on the
+# text-generation endpoint this connection calls. That intersection is the
+# Qwen3.7-Max family: the other four json_schema families (Qwen3.7-Plus,
+# Qwen3.7-Flash, Qwen3.8-Flash, Qwen3.8-Max) route to the multimodal endpoint and
+# answer Generation.call with "url error".
+# json_schema model list and mode semantics:
+#   https://help.aliyun.com/zh/model-studio/json-mode
+# text- vs multimodal-interface routing:
+#   https://help.aliyun.com/zh/model-studio/text-generation
+#
+# Capability is documented per family, meaning the base name plus the dated
+# snapshots behind it, so a name matches the prefix itself or a name continuing it
+# after a "-" separator. That expresses the documented unit instead of a snapshot
+# census that goes stale, and it keeps out a different family that merely extends
+# the prefix, such as qwen3.7-maximum. The one snapshot the rule admits without
+# json_schema reaching it, qwen3.7-max-2026-06-08, is multimodal-routed and answers
+# this connection with "url error" whether or not a response_format rides along.
+#
+# A name outside the rule reports not-capable and degrades to the prompt-engineering
+# fallback rather than failing at the provider.
+_NATIVE_STRUCTURED_OUTPUT_ALIAS_PREFIXES = ("qwen3.7-max",)

Review Comment:
   `qwen3.7-max-2026-06-08` is incorrectly classified as supported by this prefix match. `TongyiChatModel` invokes `dashscope.Generation.call`, but the [Alibaba Cloud documentation](https://www.alibabacloud.com/help/en/model-studio/text-generation#dashscope-h4) states that this model uses the multimodal API and that directly substituting it into a text-generation request causes an error. Please replace the prefix match with an exact allowlist containing `qwen3.7-max`, `qwen3.7-max-preview`, `qwen3.7-max-2026-05-17`, and `qwen3.7-max-2026-05-20`.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [integrations][python] Apply DashScope native structured output [flink-agents]

Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 merged PR #1090:
URL: https://github.com/apache/flink-agents/pull/1090


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org