← All tasks
javaagentscope-ai/agentscope-java #3083Not a task: already works

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

envgap__agentscope-ai__agentscope-java-3083

01 / FAILURE SIGNATURE

As reported upstream

No identifying execution failure has been captured.
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
6c8ccc5c64a9366afb092d1ecac5c5e04f054c03
Manifest
agentscope-extensions/agentscope-spring-boot-starters/agentscope-agui-spring-boot-starter/pom.xml
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

agentscope-ai/agentscope-java #3083 · read the original issue
<html>
<body>
<!--StartFragment--><html><head></head><body><p><strong>Issue 标题</strong>:<code>agentscope-all</code> 聚合包通过 <code>agentscope-spring-boot-starter</code> 传递依赖,导致 classpath 出现重复类,运行时加载旧版代码(shade 产物与模块版本不同步)</p>
<p><strong>Labels</strong>:<code>bug</code> <code>build</code> <code>dependencies</code></p>
<h3>Describe the bug</h3>
<p><code>agentscope-all</code>(<code>io.agentscope:agentscope</code>)聚合包使用 <code>maven-shade-plugin</code> 将 <code>agentscope-core</code> 及所有 <code>agentscope-extensions-*</code> 的类打平成一个 fat jar。而 <code>agentscope-spring-boot-starter</code> 又将该聚合包作为传递依赖引入。</p>
<p>当用户工程同时依赖 <code>agentscope-spring-boot-starter</code> 和具体的 <code>agentscope-extensions-agui</code> 模块时,classpath 上会出现<strong>两套完全相同全限定名</strong>的类(如 <code>io.agentscope.core.agui.adapter.strategy.*</code>):</p>

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


<p>在 Spring Boot repackage 生成的 fat jar 中,<code>BOOT-INF/lib/</code> 下的 jar 按<strong>字母序</strong>加载,<code>agentscope-2...</code> 排在 <code>agentscope-extensions-agui...</code> 之前,导致旧版类被优先加载。最终表现为:<strong>jar 内 class 文件已更新,但运行时行为仍是旧版逻辑</strong>。</p>
<h3>Steps to reproduce</h3>
<ol>
<li>在项目中引入 <code>agentscope-spring-boot-starter</code> 和 <code>agentscope-extensions-agui</code>(均为 <code>2.0.3-SNAPSHOT</code>)。</li>
<li>执行 <code>mvn clean package</code> 生成 Spring Boot fat jar。</li>
<li>运行 fat jar,观察 <code>io.agentscope.core.agui.adapter.strategy.*</code> 相关行为。</li>
</ol>
<h3>Expected behavior</h3>
<p>classpath 上应只存在一份 <code>io.agentscope.core.agui.adapter.strategy.*</code> 类,且为最新版本(包含 #3010 的 <code>replyId</code> / <code>blockId</code> 修复)。</p>
<h3>Actual behavior</h3>
<p>classpath 上存在两份同名类,Spring Boot fat jar 按字母序优先加载聚合包中的旧版类,导致 #3010 的修复在运行时不生效。</p>
<h3>Root cause analysis</h3>
<p><strong>问题本质</strong>:<code>agentscope-all</code> 聚合包的设计定位是"独立分发的 all-in-one 产物",不应作为其他模块的传递依赖。当它被 starter 传递引入后,与用户显式声明的具体模块产生类冲突。</p>
<p><strong>为什么 IDEA 正常、jar 异常</strong>:</p>
<ul>
<li><strong>IDEA</strong>:按 Maven 依赖树顺序加载类,用户直接声明的 <code>agentscope-extensions-agui</code> 靠前,优先加载新版类。</li>
<li><strong>Spring Boot fat jar</strong>:<code>BOOT-INF/lib/</code> 按 jar 文件名字母序加载,<code>agentscope-2.0.3-SNAPSHOT.jar</code> &lt; <code>agentscope-extensions-agui-2.0.3-SNAPSHOT.jar</code>,聚合包中的旧类被优先加载。</li>
</ul>
<p>同一份依赖,两种加载顺序,结果完全相反。</p>
<h3>Environment</h3>
<ul>
<li>AgentScope Java version: <code>2.0.3-SNAPSHOT</code></li>
<li>JDK: 17+</li>
<li>Build tool: Maven 3.8+</li>
<li>Spring Boot: 2.x / 3.x</li>
</ul>
<h3>Additional context</h3>
<h4>Workaround</h4>
<p>在用户工程 <code>pom.xml</code> 中,对 <code>agentscope-agui-spring-boot-starter</code> 排除聚合包:</p>
<pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;io.agentscope&lt;/groupId&gt;
    &lt;artifactId&gt;agentscope-agui-spring-boot-starter&lt;/artifactId&gt;
    &lt;exclusions&gt;
        &lt;exclusion&gt;
            &lt;groupId&gt;io.agentscope&lt;/groupId&gt;
            &lt;artifactId&gt;agentscope&lt;/artifactId&gt;
        &lt;/exclusion&gt;
    &lt;/exclusions&gt;
&lt;/dependency&gt;
</code></pre>
<p>排除后,fat jar 中不再包含重复类,运行时行为正确。</p>
<h4>Suggested fixes</h4>
<ol>
<li><strong>starter 不得传递依赖聚合包(根治)</strong>:<code>agentscope-spring-boot-starter</code> 应只依赖具体模块(<code>agentscope-core</code>、<code>agentscope-harness</code> 等),聚合包仅作为独立分发物供直接下载使用,不进入任何 starter 的依赖树。</li>
<li><strong>聚合包独立 GAV + 原子构建</strong>:将 all-in-one 的 <code>artifactId</code> 与模块区分开(如 <code>agentscope-all</code>),并在同一 reactor 内与各模块同步构建发布,保证 shade 的类永远与当次模块版本一致。</li>
<li><strong>CI 一致性校验(兜底)</strong>:发布流水线对比聚合包内 adapter 类与对应模块 jar 的字节码,不一致即构建失败。</li>
</ol>
<hr>
<hr>
</body></html><!--EndFragment-->
</body>
</html>
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]