-
Notifications
You must be signed in to change notification settings - Fork 128
[WIP] feat(core): Redesign Session and StateModule API for type-safe state persistence #388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…persistence Change-Id: Ibce1f62ce38ac544b80433507bfe2c00ce30c469
There was a problem hiding this 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 introduces a major redesign of the session and state management API to provide type-safe state persistence for AgentScope. The new API replaces string-based session identifiers with a SessionKey interface and introduces a State marker interface for persistable objects, enabling compile-time type safety and better incremental storage support.
Key changes:
- New
SessionKey/SimpleSessionKeyandStateinterfaces for type-safe session and state management - New
StateModule.saveTo()/loadFrom()methods replacing the legacystateDict()API StatePersistenceconfiguration record allowing fine-grained control over which components are persisted- Toolkit no longer extends
StateModuleBase; its activeGroups state is now managed by ReActAgent
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 21 comments.
Show a summary per file
| File | Description |
|---|---|
State.java |
New marker interface for persistable state objects |
SessionKey.java |
New marker interface for session identifiers |
SimpleSessionKey.java |
Default string-based SessionKey implementation with validation |
StatePersistence.java |
Configuration record for controlling component state management |
AgentMetaState.java |
Record for agent metadata persistence |
ToolkitState.java |
Record for toolkit active groups persistence |
PlanNotebookState.java |
Record for plan state persistence |
StateModule.java |
Added new saveTo/loadFrom API, deprecated legacy methods |
Session.java |
Added type-safe save/get methods with SessionKey, deprecated string-based methods |
JsonSession.java |
Implemented new API with JSONL incremental storage for lists |
InMemorySession.java |
Implemented new API with in-memory storage (full replacement) |
Msg.java |
Now implements State interface |
ContentBlock.java |
Now implements State interface |
InMemoryMemory.java |
Implemented saveTo/loadFrom with new API |
PlanNotebook.java |
Implemented StateModule, added saveTo/loadFrom support |
Toolkit.java |
Removed StateModuleBase inheritance, added setActiveGroups method |
ReActAgent.java |
Added StatePersistence configuration and saveTo/loadFrom implementation |
SupervisorAgent.java |
Updated to reflect Toolkit no longer being a StateModule component |
| Test files | Comprehensive test coverage for new API across all components |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
agentscope-core/src/main/java/io/agentscope/core/tool/Toolkit.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/main/java/io/agentscope/core/session/JsonSession.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/main/java/io/agentscope/core/memory/InMemoryMemory.java
Show resolved
Hide resolved
agentscope-core/src/main/java/io/agentscope/core/plan/PlanNotebook.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/test/java/io/agentscope/core/state/SimpleSessionKeyTest.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/test/java/io/agentscope/core/state/StateRecordsTest.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/test/java/io/agentscope/core/state/StateRecordsTest.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/test/java/io/agentscope/core/state/StateRecordsTest.java
Outdated
Show resolved
Hide resolved
…persistence Change-Id: I0ff5a9f563e7a7096db38278c64b76cf33a19abf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 33 out of 33 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
agentscope-core/src/main/java/io/agentscope/core/session/JsonSession.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/main/java/io/agentscope/core/session/InMemorySession.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/main/java/io/agentscope/core/memory/InMemoryMemory.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/main/java/io/agentscope/core/plan/PlanNotebook.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/main/java/io/agentscope/core/plan/PlanNotebook.java
Outdated
Show resolved
Hide resolved
...sor-agent/src/main/java/io/agentscope/examples/bobatea/supervisor/agent/SupervisorAgent.java
Outdated
Show resolved
Hide resolved
…persistence Change-Id: I674b243d3a8080f05ae3004c540c36521de954c4
…persistence Change-Id: I66d3744dfe16b4874932d9803e7209a50c45a999
…persistence Change-Id: If97082b04df8cc643332f266ad3501dd47383466
Change-Id: Ia5df1edfd7bbd9293b50044731af9abddcac6075
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 50 out of 50 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…persistence Change-Id: I5053d7e81bddaa0453809f55f8d76ac015aa6c75
…persistence Change-Id: Id263ec3145d934fc51b6926f0e87f2b85381d0d3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 53 out of 53 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| void testSaveAndGetListState() throws SQLException { | ||
| when(mockStatement.execute()).thenReturn(true); | ||
| when(mockStatement.executeUpdate()).thenReturn(1); | ||
| when(mockStatement.executeQuery()).thenReturn(mockResultSet); |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ResultSet is not always closed on method exit.
| void testGetNonExistentListState() throws SQLException { | ||
| when(mockStatement.execute()).thenReturn(true); | ||
| when(mockStatement.executeUpdate()).thenReturn(1); | ||
| when(mockStatement.executeQuery()).thenReturn(mockResultSet); |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ResultSet is not always closed on method exit.
…persistence Change-Id: I7eed1f45bf8a0ba62214694c833cd52229bb16b1
…persistence Change-Id: Iff9e88c41e5807db3f2dfd3459d8ab16867dd2d6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 53 out of 53 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.