**<u>AgentScope-Java is an open-source project. To involve a broader community, we recommend asking your questions in English.</u>** **Describe the bug** 开启长期记忆后,每次对话完成,会同步卡在那里等待,能不能做成异步的。 对话完成后,有的时候要等两三分钟 版本号:2.0.0 和 最尊重的2.0.1都有。 --- 这个问题是当成正常的功能不修改,还是定义成BUG后面会改呀。
Activity
guslegend0510 commentedon Aug 24, 2026
感谢反馈。
目前
STATIC_CONTROL和BOTH模式已经支持异步写入长期记忆,可以通过以下配置开启:longTermMemoryAsyncRecord 当前默认值为 false。如果没有显式开启,框架会等待长期记忆的 record() 操作完成后再结束本次调用。当记忆服务或其使用的模型响应较慢时,就可能出现等待两三分钟的情况。
开启异步写入后,回复流程不会再等待长期记忆保存完成。不过需要注意:该模式属于后台异步写入,如果应用立即退出,尚未完成的记忆写入可能无法保存。
在这个PR中已经修复了 #1177 @luoshu-open
luoshu-open commentedon Aug 24, 2026
@guslegend0510 可是我在最新的2.0.1版本,没有看到这个方法
guslegend0510 commentedon Aug 24, 2026
对应源码位置:
https://github.com/agentscope-ai/agentscope-java/blob/v2.0.1/agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java#L4602-L4605
麻烦检查一下项目实际解析到的 agentscope-core 版本,可能存在依赖版本冲突。
同时确认导入的是:
import io.agentscope.core.ReActAgent;
正常情况下可以这样配置:
ReActAgent agent = ReActAgent.builder()
.name("Assistant")
.model(model)
.longTermMemory(longTermMemory)
.longTermMemoryMode(LongTermMemoryMode.BOTH)
.longTermMemoryAsyncRecord(true)
.build();
luoshu-open commentedon Aug 25, 2026
@guslegend0510
@deprecated(forRemoval = true, since = "2.0.0")
public Builder longTermMemoryAsyncRecord(boolean asyncRecord) {
this.longTermMemoryAsyncRecord = asyncRecord;
return this;
}
为什么这个功能上线就要被移除呀?有Deprecated注解。
另外我使用的是 HarnessAgent ,这个类是没有的
guslegend0510 commentedon Aug 25, 2026
@luoshu-open 你说得对,抱歉,我之前是按照
ReActAgent的长期记忆兼容链路排查的,没有注意到你使用的是HarnessAgent。longTermMemoryAsyncRecord(...)上的@Deprecated并不是单独废弃异步功能,而是因为 2.0 将原来的LongTermMemory + ReActAgent整套旧接口标记为了待移除,并改用 Harness 的记忆管线。我重新检查了
HarnessAgent在 2.0.1 中的实现,目前确实没有对应的异步配置。luoshu-open commentedon Aug 25, 2026
@guslegend0510 后续版本有计划添加 HarnessAgent 的异步配置吗?
guslegend0510 commentedon Aug 25, 2026
会的
luoshu-open commentedon Aug 25, 2026
谢谢,期待新版本