Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,33 @@ public String getModelName() {
return modelName;
}

/**
* DashScope does not support native schema-constrained structured output.
*
* <p>The DashScope native text-generation protocol
* ({@code /api/v1/services/aigc/text-generation/generation}) only accepts
* {@code response_format: {"type": "json_object"}} and does <b>not</b> support
* {@code {"type": "json_schema", ...}}. Sending a json_schema payload is either
* ignored or rejected with HTTP 400. Because the native structured-output path
* ({@link io.agentscope.core.ReActAgent}) relies on {@code response_format} carrying
* the JSON Schema (and does not inject the schema into the prompt), it cannot produce
* schema-conforming output on this channel.
*
* <p>Returning {@code false} routes structured-output calls to the tool-based fallback
* path ({@code doFallbackStructuredCall}), which uses Qwen function-calling to return
* reliable, schema-conforming results. This also keeps
* {@link #supportsNativeStructuredOutputWithTools()} consistent, since it falls back to
* this method.
Comment on lines +405 to +409
*
* <p>Do not flip this back to {@code true} without first wiring json_object support into
* the request and handling DashScope's "messages must contain the word json" requirement
* — see issue #1852.
*
* @return always {@code false} for the DashScope native channel
*/
@Override
public boolean supportsNativeStructuredOutput() {
return true;
return false;
}

public static class Builder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@ void testBasicModelCreation() {
assertNotNull(customModel, "Custom model should be created");
}

@Test
@DisplayName("Should report native structured output as unsupported (issue #1852)")
void testNativeStructuredOutputUnsupported() {
// DashScope's native text-generation protocol only accepts
// response_format {"type":"json_object"} and not {"type":"json_schema"},
// so native schema-constrained structured output must be disabled. This
// routes structured calls to the tool-based fallback path. Do not flip
// this expectation without wiring json_object support — see issue #1852.
assertFalse(
model.supportsNativeStructuredOutput(),
"DashScope must not advertise native structured output");
assertFalse(
model.supportsNativeStructuredOutputWithTools(),
"DashScope must not advertise native structured output with tools");
}

// ========== Streaming Configuration Tests ==========

@Test
Expand Down