[Bug]: OpenAIMultiModalTool throws HTTP 503 on non-OpenAI proxies due to hardcoded gpt-4o fallback model
Describe the bug
OpenAIMultiModalTool.openaiImageToText hardcodes "gpt-4o" as the fallback model name when the LLM does not supply the optional model parameter. When deployed against a non-OpenAI-compatible backend (e.g. a MiniMax proxy), the backend returns HTTP 503 because it does not recognize gpt-4o.
To Reproduce
- Instantiate
OpenAIMultiModalToolwith a custombaseUrlpointing to a non-OpenAI backend:new OpenAIMultiModalTool(apiKey, "http://your-proxy-host/"); - Register the tool in a
Toolkitand run aReActAgentwith an image input. - The agent calls
openai_image_to_textwithout specifying themodelparameter (or the LLM picksgpt-4ofrom the description hints). - The tool sends
{ "model": "gpt-4o", ... }toPOST /v1/chat/completions. - The backend returns
503.
Expected behavior
OpenAIMultiModalTool should either:
- Accept a
defaultModelNameconstructor parameter so callers can override the fallback, or - Remove
"gpt-4o"/"gpt-4-vision-preview"from the@ToolParamdescription to avoid steering the LLM toward OpenAI-specific model names.
Error messages
io.agentscope.core.model.exception.InternalServerException: OpenAI API request failed with status 503
at io.agentscope.core.model.exception.OpenAIException.create(OpenAIException.java:88)
at io.agentscope.core.model.OpenAIClient.callApi(OpenAIClient.java:666)
at io.agentscope.core.model.OpenAIClient.callApi(OpenAIClient.java:609)
at io.agentscope.core.tool.multimodal.OpenAIMultiModalTool.lambda$openaiImageToText$8(OpenAIMultiModalTool.java:331)
Root cause in source (OpenAIMultiModalTool.java:286):
String finalModel = Optional.ofNullable(model)
.filter(s -> !s.trim().isEmpty())
.orElse("gpt-4o"); // hardcoded fallback
Environment
- AgentScope-Java Version: 2.0.0-RC2
- Java Version: 21
- OS: Windows 11
Additional context
The @ToolParam description for model currently reads:
"The vision model to use, e.g., 'gpt-4o', 'gpt-4-vision-preview'"
This actively guides the LLM to fill in gpt-4o, which makes the 503 hard to diagnose — the error looks like a transient service outage rather than a model-name mismatch.
Workaround (applied in this project)
Subclass OpenAIMultiModalTool, shadow the 4-parameter openaiImageToText override (no @Tool annotation so the framework scanner skips it), and expose a 3-parameter @Tool method that always injects the configured model name:
public class KstMultiModalTool extends OpenAIMultiModalTool {
private final String defaultModelName;
public KstMultiModalTool(String apiKey, String baseUrl, String defaultModelName) {
super(apiKey, baseUrl);
this.defaultModelName = defaultModelName;
}
@Override
public Mono<ToolResultBlock> openaiImageToText(
String imageUrls, String prompt, String model, Integer maxTokens) {
return super.openaiImageToText(imageUrls, prompt, defaultModelName, maxTokens);
}
@Tool(name = "openai_image_to_text",
description = "Convert image(s) to text. Analyzes images and returns text descriptions.")
public Mono<ToolResultBlock> analyzeImages(
@ToolParam(name = "image_urls", description = "Image URLs to analyze (comma-separated)")
String imageUrls,
@ToolParam(name = "prompt", description = "What to extract from the images", required = false)
String prompt,
@ToolParam(name = "max_tokens", description = "Maximum tokens in response", required = false)
Integer maxTokens) {
return super.openaiImageToText(imageUrls, prompt, defaultModelName, maxTokens);
}
}
我计划提交一个 PR 来修复这个问题,方案是:
- 新增一个 defaultModelName 构造参数,让调用方可以指定默认模型名
- 修改 openaiImageToText 的 @ToolParam description,去掉 gpt-4o、gpt-4-vision-preview 等 OpenAI 特定的模型名提示