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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
