agentscope-ai / agentscope-ai/agentscope-java

[Bug]: #3010合并后agentscope-all 聚合包通过 agentscope-spring-boot-starter 传递依赖,导致 classpath 出现重复类,运行时加载旧版代码(shade 产物与模块版本不同步)

Aberta
#3,083 3 comentários 0 reações 0 responsáveis Ver no GitHub
area/build bug
Linguagem predominante
Java
Estrelas
5.6k
Forks
1.3k
Merge médio
4d 12h
PRs com merge (30d)
77

Descrição

Issue 标题agentscope-all 聚合包通过 agentscope-spring-boot-starter 传递依赖,导致 classpath 出现重复类,运行时加载旧版代码(shade 产物与模块版本不同步)


Labelsbug build dependencies


Describe the bug


agentscope-allio.agentscope:agentscope)聚合包使用 maven-shade-pluginagentscope-core 及所有 agentscope-extensions-* 的类打平成一个 fat jar。而 agentscope-spring-boot-starter 又将该聚合包作为传递依赖引入。


当用户工程同时依赖 agentscope-spring-boot-starter 和具体的 agentscope-extensions-agui 模块时,classpath 上会出现两套完全相同全限定名的类(如 io.agentscope.core.agui.adapter.strategy.*):

来源 | 内容
-- | --
agentscope-2.0.3-SNAPSHOT.jar(聚合包) | 旧版 adapter(包含 -reasoning、reasoningMessageId() 等旧接口)—— shade 时打包的 extensions 快照与最新发布版本不同步
agentscope-extensions-agui-2.0.3-SNAPSHOT.jar | 新版 adapter(#3010 修复后,使用 replyId / blockId)

在 Spring Boot repackage 生成的 fat jar 中,BOOT-INF/lib/ 下的 jar 按字母序加载,agentscope-2... 排在 agentscope-extensions-agui... 之前,导致旧版类被优先加载。最终表现为:jar 内 class 文件已更新,但运行时行为仍是旧版逻辑


Steps to reproduce



  1. 在项目中引入 agentscope-spring-boot-starteragentscope-extensions-agui(均为 2.0.3-SNAPSHOT)。

  2. 执行 mvn clean package 生成 Spring Boot fat jar。

  3. 运行 fat jar,观察 io.agentscope.core.agui.adapter.strategy.* 相关行为。


Expected behavior


classpath 上应只存在一份 io.agentscope.core.agui.adapter.strategy.* 类,且为最新版本(包含 #3010 的 replyId / blockId 修复)。


Actual behavior


classpath 上存在两份同名类,Spring Boot fat jar 按字母序优先加载聚合包中的旧版类,导致 #3010 的修复在运行时不生效。


Root cause analysis


问题本质agentscope-all 聚合包的设计定位是"独立分发的 all-in-one 产物",不应作为其他模块的传递依赖。当它被 starter 传递引入后,与用户显式声明的具体模块产生类冲突。


为什么 IDEA 正常、jar 异常



  • IDEA:按 Maven 依赖树顺序加载类,用户直接声明的 agentscope-extensions-agui 靠前,优先加载新版类。

  • Spring Boot fat jarBOOT-INF/lib/ 按 jar 文件名字母序加载,agentscope-2.0.3-SNAPSHOT.jar < agentscope-extensions-agui-2.0.3-SNAPSHOT.jar,聚合包中的旧类被优先加载。


同一份依赖,两种加载顺序,结果完全相反。


Environment



  • AgentScope Java version: 2.0.3-SNAPSHOT

  • JDK: 17+

  • Build tool: Maven 3.8+

  • Spring Boot: 2.x / 3.x


Additional context


Workaround


在用户工程 pom.xml 中,对 agentscope-agui-spring-boot-starter 排除聚合包:


<dependency>

<groupId>io.agentscope</groupId>
<artifactId>agentscope-agui-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>io.agentscope</groupId>
<artifactId>agentscope</artifactId>
</exclusion>
</exclusions>
</dependency>

排除后,fat jar 中不再包含重复类,运行时行为正确。


Suggested fixes



  1. starter 不得传递依赖聚合包(根治)agentscope-spring-boot-starter 应只依赖具体模块(agentscope-coreagentscope-harness 等),聚合包仅作为独立分发物供直接下载使用,不进入任何 starter 的依赖树。

  2. 聚合包独立 GAV + 原子构建:将 all-in-one 的 artifactId 与模块区分开(如 agentscope-all),并在同一 reactor 内与各模块同步构建发布,保证 shade 的类永远与当次模块版本一致。

  3. CI 一致性校验(兜底):发布流水线对比聚合包内 adapter 类与对应模块 jar 的字节码,不一致即构建失败。





Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.