AgentScope-Java is an open-source project. To involve a broader community, we recommend asking your questions in English.
Describe the bug
MysqlSession.save(SessionKey, String, List<? extends State>) may trigger unnecessary full list rewrites for List<Msg> even when messages are logically identical.
ListHashUtil.computeHash() relies on element hashCode(). For nested message content, semantically equivalent lists can still produce different hashes, causing needsFullRewrite(...) to evaluate to true.
To Reproduce
Steps to reproduce the behavior:
- Use two newly created
List<Msg> instances with logically identical messages:
- user:
"hello"
- assistant:
"hello"
- Ensure all visible fields are set identically (e.g., same
id, timestamp, role, and text content), then call:
ListHashUtil.computeHash(firstList)
ListHashUtil.computeHash(secondList)
- Compare the two hash strings.
Minimal example:
List<Msg> first = List.of(
Msg.builder().id("m-user-1").timestamp("2026-05-08 14:00:00.000")
.role(MsgRole.USER).content(TextBlock.builder().text("hello").build()).build(),
Msg.builder().id("m-assistant-1").timestamp("2026-05-08 14:00:01.000")
.role(MsgRole.ASSISTANT).content(TextBlock.builder().text("hello").build()).build()
);
List<Msg> second = List.of(
Msg.builder().id("m-user-1").timestamp("2026-05-08 14:00:00.000")
.role(MsgRole.USER).content(TextBlock.builder().text("hello").build()).build(),
Msg.builder().id("m-assistant-1").timestamp("2026-05-08 14:00:01.000")
.role(MsgRole.ASSISTANT).content(TextBlock.builder().text("hello").build()).build()
);
String h1 = ListHashUtil.computeHash(first);
String h2 = ListHashUtil.computeHash(second);
Expected behavior
For logically equivalent message lists, computeHash should be stable and equal, so needsFullRewrite(...) does not force delete + rewrite.
Error messages
No runtime exception in normal flow.
Observed behavioral mismatch in hash values for equivalent lists, e.g.:
h1 = de9291ea
h2 = 68bb1c12
This leads to unnecessary full rewrites (DELETE + INSERT all) in session persistence paths.
Environment (please complete the following information):
- AgentScope-Java Version: 1.0.13-SNAPSHOT
- Java Version: 17
- OS: macOS
Additional context
- Related files:
agentscope-core/src/main/java/io/agentscope/core/session/ListHashUtil.java
agentscope-extensions/agentscope-extensions-session-mysql/src/main/java/io/agentscope/core/session/mysql/MysqlSession.java
agentscope-core/src/main/java/io/agentscope/core/state/State.java
agentscope-core/src/main/java/io/agentscope/core/message/Msg.java
AgentScope-Java is an open-source project. To involve a broader community, we recommend asking your questions in English.
Describe the bug
MysqlSession.save(SessionKey, String, List<? extends State>)may trigger unnecessary full list rewrites forList<Msg>even when messages are logically identical.ListHashUtil.computeHash()relies on elementhashCode(). For nested message content, semantically equivalent lists can still produce different hashes, causingneedsFullRewrite(...)to evaluate totrue.To Reproduce
Steps to reproduce the behavior:
List<Msg>instances with logically identical messages:"hello""hello"id,timestamp,role, and text content), then call:ListHashUtil.computeHash(firstList)ListHashUtil.computeHash(secondList)Minimal example:
Expected behavior
For logically equivalent message lists,
computeHashshould be stable and equal, soneedsFullRewrite(...)does not force delete + rewrite.Error messages
No runtime exception in normal flow.
Observed behavioral mismatch in hash values for equivalent lists, e.g.:
h1 = de9291eah2 = 68bb1c12This leads to unnecessary full rewrites (
DELETE + INSERT all) in session persistence paths.Environment (please complete the following information):
Additional context
agentscope-core/src/main/java/io/agentscope/core/session/ListHashUtil.javaagentscope-extensions/agentscope-extensions-session-mysql/src/main/java/io/agentscope/core/session/mysql/MysqlSession.javaagentscope-core/src/main/java/io/agentscope/core/state/State.javaagentscope-core/src/main/java/io/agentscope/core/message/Msg.java