Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(session): resolve list modification detection bug in incremental updates#1228

Merged
LearningGp merged 3 commits into
agentscope-ai:mainfrom
jujn:fix_1225
Apr 29, 2026
Merged

fix(session): resolve list modification detection bug in incremental updates#1228
LearningGp merged 3 commits into
agentscope-ai:mainfrom
jujn:fix_1225

Conversation

@jujn
Copy link
Copy Markdown
Contributor

@jujn jujn commented Apr 15, 2026

Description

Close #1225
This PR fixes the session overwrite bug by implementing prefix hash comparison for incremental database inserts.

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@jujn jujn requested review from a team and Copilot April 15, 2026 08:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #1225 by changing list change-detection in session persistence to use a prefix-hash comparison, so append-only updates can be applied incrementally without triggering delete-and-reinsert.

Changes:

  • Update ListHashUtil.needsFullRewrite to compare the hash of the existing persisted prefix (0..existingCount) against the stored hash.
  • Adjust session implementations (MySQL / Redis / JSON) to call the updated needsFullRewrite signature.
  • Expand unit tests to validate the new prefix-hash behavior for modified, shrunk, and grown lists.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
agentscope-extensions/agentscope-extensions-session-redis/src/main/java/io/agentscope/core/session/redis/jedis/JedisSession.java Switches full-rewrite decision to the new needsFullRewrite(values, storedHash, existingCount) API.
agentscope-extensions/agentscope-extensions-session-redis/src/main/java/io/agentscope/core/session/redis/RedisSession.java Same as above for the adapter-based Redis session.
agentscope-extensions/agentscope-extensions-session-mysql/src/main/java/io/agentscope/core/session/mysql/MysqlSession.java Uses prefix-based rewrite detection for incremental DB inserts.
agentscope-core/src/test/java/io/agentscope/core/session/ListHashUtilTest.java Updates tests to exercise prefix-hash rewrite rules.
agentscope-core/src/main/java/io/agentscope/core/session/ListHashUtil.java Implements prefix-hash comparison in needsFullRewrite.
agentscope-core/src/main/java/io/agentscope/core/session/JsonSession.java Updates full-rewrite decision logic to match the new needsFullRewrite API.

Comment thread agentscope-core/src/main/java/io/agentscope/core/session/ListHashUtil.java Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ntscope/core/session/redis/jedis/JedisSession.java 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@LearningGp
Copy link
Copy Markdown
Collaborator

image

Copy link
Copy Markdown
Collaborator

@LearningGp LearningGp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

computeHash only samples 5 positions for lists with more than 5 elements. This could be problematic if historical messages are modified, but since this was not introduced in this PR, it's out of scope for now.

@LearningGp LearningGp merged commit e2b601c into agentscope-ai:main Apr 29, 2026
5 checks passed
@jujn jujn deleted the fix_1225 branch April 29, 2026 03:55
liangxingguang pushed a commit to liangxingguang/agentscope-java that referenced this pull request May 21, 2026
…updates (agentscope-ai#1228)

## Description

Close agentscope-ai#1225
This PR fixes the session overwrite bug by implementing prefix hash
comparison for incremental database inserts.

## Checklist

Please check the following items before code is ready to be reviewed.

- [ ]  Code has been formatted with `mvn spotless:apply`
- [ ]  All tests are passing (`mvn test`)
- [ ]  Javadoc comments are complete and follow project conventions
- [ ] Related documentation has been updated (e.g. links, examples,
etc.)
- [ ]  Code is ready for review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]:MysqlSession每次都会先删除后新增

3 participants