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.
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Adds maxPersistedContextMessages to limit conversation messages stored in persisted agent_state snapshots, while keeping live runtime context unchanged. Also adds deleteSessionState APIs for explicit cleanup.
Findings
- [Info] Trimming only persistence snapshot, not live context. Correct separation.
- [Info] Default unlimited for backward compatibility. Good.
- [Info] Setting to 0 persists non-conversation state without messages. Useful for stateless agents.
- [Info] deleteSessionState APIs exposed through HarnessAgent. Good.
- [Info] Documentation added for standalone AgentStateStore and DistributedStore usage. Good.
- [Info] 2213 tests passed. Excellent.
Verdict
Important fix for Redis/Postgres state bloat. LGTM.
Automated review by github-manager
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