fix(state): bound persisted session context#2178
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR adds two features to ReActAgent:
maxPersistedContextMessages— limits the number of recent conversation messages stored in persistedagent_statesnapshots, preventing unbounded storage growth for long sessions. Trimming only affects the persistence snapshot, not the live runtime context.deleteSessionState(...)— public API allowing applications to explicitly delete persisted session data and clean local caches.
Changes are well-scoped, code style consistent with project conventions, tests cover core paths and edge cases (negative limit rejection, auto-persistence trimming, post-delete cache eviction), and documentation is provided in both English and Chinese. The PR directly addresses issue #2173.
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR adds two features to ReActAgent:
maxPersistedContextMessages— limits the number of recent conversation messages stored in persistedagent_statesnapshots, preventing unbounded storage growth for long sessions. Trimming only affects the persistence snapshot, not the live runtime context.deleteSessionState(...)— public API allowing applications to explicitly delete persisted session data and clean local caches.
Changes are well-scoped, code style consistent with project conventions, tests cover core paths and edge cases (negative limit rejection, auto-persistence trimming, post-delete cache eviction), and documentation is provided in both English and Chinese. The PR directly addresses issue #2173.
Summary
maxPersistedContextMessagesto limit the number of recent conversation messages stored in persistedagent_statesnapshots.deleteSessionState(...)APIs so applications can explicitly remove persisted session data and local state caches.HarnessAgent.AgentStateStoreandDistributedStoreusage.The default remains unlimited for backward compatibility. Setting
maxPersistedContextMessagesto0persists non-conversation agent state without storing conversation messages.Testing
mvn -pl agentscope-core -Dtest=ReActAgentPerSessionStateTest testmvn -pl agentscope-harness -am -Dtest=HarnessAgentTest -Dsurefire.failIfNoSpecifiedTests=false testmvn -pl agentscope-core testFull core test result: 2,213 tests passed, 0 failures, 0 errors, 9 skipped.
Fixes #2173