Skip to content
Open
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 @@ -68,7 +68,14 @@ private ModelContextWindows() {}
Map.entry("o3-mini", 200_000),
Map.entry("o3", 200_000),
Map.entry("o1-mini", 128_000),
Map.entry("o1", 200_000));
Map.entry("o1", 200_000),
Map.entry("gpt-5.4-mini", 400_000),
Map.entry("gpt-5.4", 1_050_000),
Map.entry("gpt-5.5", 1_050_000),
Map.entry("gpt-5.6-luna", 1_050_000),
Map.entry("gpt-5.6-terra", 1_050_000),
Map.entry("gpt-5.6-sol", 1_050_000),
Map.entry("gpt-6-astra", 1_050_000));

public static final Map<String, Integer> DEEPSEEK =
Map.ofEntries(
Expand All @@ -77,6 +84,7 @@ private ModelContextWindows() {}

public static final Map<String, Integer> GLM =
Map.ofEntries(
Map.entry("glm-5.3", 1_000_000),
Map.entry("glm-5.2", 1_000_000),
Map.entry("glm-5.1", 200_000),
Map.entry("glm-5-turbo", 200_000),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.agentscope.core.model;

import java.time.Duration;
import java.util.concurrent.TimeoutException;
import java.util.function.Predicate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -88,6 +89,8 @@ public static Flux<ChatResponse> applyTimeoutAndRetry(
Flux.error(
new ModelException(
"Model request timeout after " + timeout,
new TimeoutException(
"Model request timeout after " + timeout),
modelName,
provider)));
LOG.debug("Applied timeout: {} for model: {}", timeout, modelName);
Expand Down
12 changes: 6 additions & 6 deletions agentscope-distribution/agentscope-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@
<optional>true</optional>
</dependency>

<!-- <dependency>-->
<!-- <groupId>io.agentscope</groupId>-->
<!-- <artifactId>agentscope-extensions-model-openai-official</artifactId>-->
<!-- <scope>compile</scope>-->
<!-- <optional>true</optional>-->
<!-- </dependency>-->
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-extensions-model-openai-official</artifactId>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[HIGH] Adding this module to agentscope-all currently packages the classes but does not make the provider discoverable. The shade build warns that multiple model modules define META-INF/services/io.agentscope.core.model.spi.ModelProvider, and the generated agentscope-2.0.3-SNAPSHOT.jar keeps only the existing OpenAI entries: unzip -p agentscope-distribution/agentscope-all/target/agentscope-2.0.3-SNAPSHOT.jar META-INF/services/io.agentscope.core.model.spi.ModelProvider does not include io.agentscope.extensions.model.openaiofficial.OpenAIOfficialModelProvider, even though the class is present. Users depending on the advertised all-in-one agentscope artifact will therefore fail to resolve openai-official:<model> through ModelRegistry. Please configure the shade plugin to merge service descriptors, for example with org.apache.maven.plugins.shade.resource.ServicesResourceTransformer, and add a packaging assertion or smoke test that the shaded jar service file contains this provider.

<scope>compile</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.agentscope</groupId>
Expand Down
10 changes: 5 additions & 5 deletions agentscope-distribution/agentscope-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,11 @@
<artifactId>agentscope-extensions-model-openai</artifactId>
<version>${project.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.agentscope</groupId>-->
<!-- <artifactId>agentscope-extensions-model-openai-official</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-extensions-model-openai-official</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-extensions-model-gemini</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-extensions-model-openai-official</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-extensions-model-gemini</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.agentscope.core.e2e.providers.GeminiProvider;
import io.agentscope.core.e2e.providers.ModelCapability;
import io.agentscope.core.e2e.providers.ModelProvider;
import io.agentscope.core.e2e.providers.OpenAIOfficialResponsesProvider;
import io.agentscope.core.e2e.providers.OpenRouterProvider;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -88,6 +89,10 @@ public class ProviderFactory {
private static List<ModelProvider> getAllProviders() {
List<ModelProvider> providers = new ArrayList<>();

// OpenAI Official SDK providers (Responses API)
providers.add(new OpenAIOfficialResponsesProvider.Gpt54());
providers.add(new OpenAIOfficialResponsesProvider.Gpt54MultiAgent());

// DashScope Compatible providers
providers.add(new DashScopeCompatibleProvider.QwenPlusOpenAI());
providers.add(new DashScopeCompatibleProvider.QwenPlusMultiAgentOpenAI());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Copyright 2024-2026 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.agentscope.core.e2e.providers;

import io.agentscope.core.ReActAgent;
import io.agentscope.core.tool.Toolkit;
import io.agentscope.extensions.model.openaiofficial.OpenAIResponsesChatModel;
import io.agentscope.extensions.model.openaiofficial.ResponsesMultiAgentFormatter;
import java.util.HashSet;
import java.util.Set;

/**
* Provider for OpenAI models via the official OpenAI Java SDK (Responses API).
*/
@ModelCapabilities({ModelCapability.BASIC, ModelCapability.TOOL_CALLING})
public class OpenAIOfficialResponsesProvider extends BaseModelProvider {

private static final String API_KEY_ENV = "OPENAI_API_KEY";
private static final String BASE_URL_ENV = "OPENAI_BASE_URL";

public OpenAIOfficialResponsesProvider(String modelName, boolean multiAgentFormatter) {
super(API_KEY_ENV, modelName, multiAgentFormatter);
}

@Override
protected ReActAgent.Builder doCreateAgentBuilder(String name, Toolkit toolkit, String apiKey) {
String baseUrl = System.getenv(BASE_URL_ENV);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个只支持通过系统环境变量获取吗?
为什么不是从 spring 生命周期中的配置获取?


OpenAIResponsesChatModel.Builder builder =
OpenAIResponsesChatModel.builder().apiKey(apiKey).modelName(getModelName());

if (baseUrl != null && !baseUrl.isEmpty()) {
builder.baseUrl(baseUrl);
}

if (isMultiAgentFormatter()) {
builder.formatter(new ResponsesMultiAgentFormatter());
}

return ReActAgent.builder().name(name).model(builder.build()).toolkit(toolkit);
}

@Override
public String getProviderName() {
return "OpenAI-Official";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么这个不是静态常量?

}

@Override
public Set<ModelCapability> getCapabilities() {
Set<ModelCapability> caps = new HashSet<>(super.getCapabilities());
if (isMultiAgentFormatter()) {
caps.add(ModelCapability.MULTI_AGENT_FORMATTER);
}
return caps;
}

// ==========================================================================
// Provider Instances
// ==========================================================================

/** GPT-5.4 via OpenAI Official SDK (Responses API). */
@ModelCapabilities({
ModelCapability.BASIC,
ModelCapability.TOOL_CALLING,
ModelCapability.THINKING
})
public static class Gpt54 extends OpenAIOfficialResponsesProvider {
public Gpt54() {
super("gpt-5.4", false);
}

@Override
public String getProviderName() {
return "OpenAI-Official";
}
}

/** GPT-5.4 with Multi-Agent Formatter. */
@ModelCapabilities({
ModelCapability.BASIC,
ModelCapability.TOOL_CALLING,
ModelCapability.THINKING,
ModelCapability.MULTI_AGENT_FORMATTER
})
public static class Gpt54MultiAgent extends OpenAIOfficialResponsesProvider {
public Gpt54MultiAgent() {
super("gpt-5.4", true);
}

@Override
public String getProviderName() {
return "OpenAI-Official (Multi-Agent)";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥这不是静态常量呢?

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2024-2026 the original author or authors.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-extensions-model</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>agentscope-extensions-model-openai-official</artifactId>
<name>AgentScope Java - Extensions - Model - OpenAI Official</name>
<description>OpenAI official SDK model provider extension for AgentScope Java</description>

<dependencies>
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-core</artifactId>
</dependency>

<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
</dependency>

<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Loading
Loading