agentscope-ai / agentscope-ai/agentscope-java

[Bug]: OpenAIChatModel structuted output fails on DeepSeek/vLLM — supportsNativeStructuredOutput() returns true for unsupported backends

Đang mở
#1,742 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
area/core/model bug
Ngôn ngữ chính
Java
Star
5.6k
Fork
1.3k
Merge trung bình
4 ngày 12 giờ
Pull request đã merge (30 ngày)
77

Mô tả

## Summary

`OpenAIChatModel.supportsNativeStructuredOutput()` hardcodes `true`, but many OpenAI-compatible backends (DeepSeek, vLLM, Ollama, SiliconFlow) do not support `response_format`. This causes `agent.call(msg, OutputClass.class)` to fail with HTTP 400 on those backends.

## Root Cause

`OpenAIChatModel.java:195`:

```java
@Override
public boolean supportsNativeStructuredOutput() {
return true; // ← assumes ALL OpenAI-compatible APIs support response_format
}
```

`ReActAgent.doStructuredCall()` trusts this unconditionally:

```java
if (model.supportsNativeStructuredOutput()) {
return doNativeStructuredCall(msgs, jsonSchema); // sends response_format → 400
}
```

## Reproduction

```java
ReActAgent agent = ReActAgent.builder()
.model(OpenAIChatModel.builder()
.baseUrl("https://api.deepseek.com")
.modelName("deepseek-chat")
.formatter(new DeepSeekFormatter())
.build())
.build();

agent.call(userMsg, OutputClass.class).block();
// DeepSeek: "This response_format type is unavailable now" (400)
```

## Affected Backends

All OpenAI-compatible APIs using `OpenAIChatModel` that don't support `response_format`: DeepSeek, vLLM, Ollama, SiliconFlow, TogetherAI (partial).

## Fix

Add automatic fallback in `doStructuredCall()`: when native path fails, retry with the fallback (generate_response tool) path.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.