Skip to content

[Bug]:ReActAgent 作为无状态单例,不应持有可变实例字段 activeRc #2528

Closed

Description

@xzxiaoshan

ReActAgent 在 2.0 架构中已被演进为一个可跨会话共享、按 (userId, sessionId) 槽位隔离的"无状态单例"对象。

然而,类上仍保留着:

/** Active per-call RuntimeContext, set during call lifecycle only. */
private volatile RuntimeContext activeRc;

作为一个本应无状态的单例对象,activeRc 是一个违反架构设计的可变状态变量:它把"当前调用的 RuntimeContext"以单实例字段的形式存放,在并发多会话调用下必然被互相覆写,volatile 只保证可见性、不保证生命周期语义的正确性。

如果按照 active 的概念,需要设计一个当前活动中的 RuntimeContext 容器,例如通过 ConcurrentHashMap 等合理的方式来记录多个活动中的 RuntimeContext ,agent 开始正式执行时,被记录,执行结束后自动被清理。

Activity

  1. added
    bug
    on Aug 2, 2026
  2. added
    area/core/agent
    area/core/memory
    on Aug 11, 2026
  3. moved this from Backlog to In progress in AgentScope Javaon Sep 24, 2026
  4. moved this from In progress to Done in AgentScope Javaon Sep 24, 2026
  5. added a commit that references this issue on Sep 24, 2026
    8d9bec6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/core/agentarea/core/memorybug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions