Skip to content

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

Closed

Description

@wxh2010zd

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

Labels:bug build dependencies

Describe the bug

agentscope-all(io.agentscope:agentscope)聚合包使用 maven-shade-plugin 将 agentscope-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-starter 和 agentscope-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 jar:BOOT-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-core、agentscope-harness 等),聚合包仅作为独立分发物供直接下载使用,不进入任何 starter 的依赖树。
  2. 聚合包独立 GAV + 原子构建:将 all-in-one 的 artifactId 与模块区分开(如 agentscope-all),并在同一 reactor 内与各模块同步构建发布,保证 shade 的类永远与当次模块版本一致。
  3. CI 一致性校验(兜底):发布流水线对比聚合包内 adapter 类与对应模块 jar 的字节码,不一致即构建失败。


Activity

  1. added
    bug
    on Sep 10, 2026
  2. ZYZ666-RGB commented on Sep 10, 2026

    @ZYZ666-RGB
    Contributor

    Hi, I'd like to work on this issue.

    I inspected the current POMs and confirmed that the base Spring Boot starter still depends on the shaded io.agentscope:agentscope artifact.

    I propose to:

    • Reproduce the duplicate-class problem in a minimal packaged Spring Boot application.
    • Adjust starter dependencies to use the appropriate ordinary modules.
    • Add dependency, packaged-class, and auto-configuration regression checks.

    I have not yet run the reproduction. Before implementation, could you confirm which provider/extension modules the base starter should continue to supply, so existing functionality is preserved?

    I checked related PRs and did not find one covering this dependency fix. Could you assign this issue to me if the scope looks good? Thanks!

  3. wxh2010zd commented on Sep 11, 2026

    @wxh2010zd
    Author

    Hi, I'd like to work on this issue.

    I inspected the current POMs and confirmed that the base Spring Boot starter still depends on the shaded io.agentscope:agentscope artifact.

    I propose to:

    • Reproduce the duplicate-class problem in a minimal packaged Spring Boot application.
    • Adjust starter dependencies to use the appropriate ordinary modules.
    • Add dependency, packaged-class, and auto-configuration regression checks.

    I have not yet run the reproduction. Before implementation, could you confirm which provider/extension modules the base starter should continue to supply, so existing functionality is preserved?

    I checked related PRs and did not find one covering this dependency fix. Could you assign this issue to me if the scope looks good? Thanks!

    Hi, I'd like to work on this issue.

    I inspected the current POMs and confirmed that the base Spring Boot starter still depends on the shaded io.agentscope:agentscope artifact.

    I propose to:

    • Reproduce the duplicate-class problem in a minimal packaged Spring Boot application.
    • Adjust starter dependencies to use the appropriate ordinary modules.
    • Add dependency, packaged-class, and auto-configuration regression checks.

    I have not yet run the reproduction. Before implementation, could you confirm which provider/extension modules the base starter should continue to supply, so existing functionality is preserved?

    I checked related PRs and did not find one covering this dependency fix. Could you assign this issue to me if the scope looks good? Thanks!

    Thanks for looking into this issue! Your proposed solution sounds like the right approach to fix this dependency conflict.
    To answer your question, the agentscope-spring-boot-starter should only include the core modules that are essential for any AgentScope application to run. It should not depend on the agentscope-all aggregate package or any specific, optional extension modules (like agentscope-extensions-agui).
    Users who need specific extensions should explicitly add them as dependencies in their own projects. This will prevent the classpath duplication issue you've identified.

  4. oss-maintainer commented on Sep 11, 2026

    @oss-maintainer
    Collaborator

    Issue Evaluation

    Category: bug | Status: Confirmed

    Verified against main @ c5db8f7.

    Root cause:

    • agentscope-distribution/agentscope-all/pom.xml:29 publishes the aggregate as io.agentscope:agentscope, and its maven-shade-plugin execution (lines 456-476) flattens io.agentscope:agentscope-core plus every io.agentscope:agentscope-extensions-* (including agentscope-extensions-agui, line 71) into that single jar.
    • agentscope-extensions/agentscope-spring-boot-starters/agentscope-spring-boot-starter/pom.xml:47-51 declares a non-optional, non-provided compile dependency on io.agentscope:agentscope.

    So any project that adds the starter and an explicit extension module gets two copies of the same fully-qualified classes; in a Spring Boot fat jar BOOT-INF/lib/agentscope-<v>.jar sorts before agentscope-extensions-agui-<v>.jar, so the shaded copy wins at runtime.

    Impact: code from the explicitly pinned extension module is silently ignored — the reported "class file updated, old logic still running" symptom. Severity: high for starter users combining extension modules.

    Suggested fix (repo decision needed): make agentscope-all stop shading the extension modules it does not own, and/or mark the io.agentscope:agentscope dependency in the starters as provided/optional so users depend on concrete modules. At minimum the build should fail (or at least warn) when a shaded class is also shipped by an individual module, and the shaded artifact content should be pinned to the same commit as the module releases.

    This one touches the packaging strategy for all starters, so we are flagging it for maintainer input rather than auto-generating a PR.


    Automated evaluation by github-manager-bot

  5. added
    area/build
    on Sep 11, 2026
  6. added a commit that references this issue on Sep 17, 2026
    0b0f1c8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/buildbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions