feat (engine): replace AgentStateService examples with RedisSession (FakeRedis) and simplify service docs#427
Conversation
Summary of ChangesHello @rayrayraykk, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request streamlines agent state management by migrating from a custom Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is a significant and well-executed refactoring that replaces the custom AgentStateService with the upstream agentscope.session.RedisSession. This simplifies the codebase, improves the API for state management, and aligns with using more standard components. The use of fakeredis in examples is an excellent pattern for local development.
The documentation has been thoroughly updated to reflect these changes, including removing the old service documentation and updating all code examples. The small fixes to the sandbox platform detection and container environment variables are also good improvements.
My review focuses on minor inconsistencies in the Chinese documentation, where some docstrings remained in English. These are small fixes to improve readability for the target audience. Overall, this is a high-quality contribution.
There was a problem hiding this comment.
Pull request overview
This PR modernizes the session state management approach by replacing the legacy Agent State Service infrastructure with AgentScope's native RedisSession (backed by fakeredis for development/testing). The changes significantly simplify the architecture by removing Runtime-side state management abstractions and delegating persistence to the agent framework itself.
Changes:
- Removed legacy state service infrastructure (
InMemoryStateService,RedisStateService,StateServiceFactory) and all associated tests - Updated all examples and tests to use
RedisSessionwithfakeredisfor session state persistence - Removed state service documentation and added comprehensive sandbox service documentation
- Version bumped from v1.1.0a1 to v1.1.0b1 with agentscope dependency updated to >=1.0.14
- Fixed platform detection for GUI sandbox to cover broader ARM architecture support
- Fixed NGINX_TIMEOUT environment variable handling with proper string conversion and fallback
Reviewed changes
Copilot reviewed 54 out of 56 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_state_service_factory.py | Deleted - removed factory tests for deprecated state service |
| tests/unit/test_redis_state_service.py | Deleted - removed Redis state service unit tests |
| tests/integrated/test_runner_stream_ms.py | Replaced state service with simple dict-based thread storage for MS Agent Framework tests |
| tests/integrated/test_runner_stream_agentscope*.py | Updated to use RedisSession with fakeredis for session management |
| tests/integrated/test_agent_app.py | Updated to use RedisSession instead of InMemoryStateService |
| tests/integrated/test_agui_integration.py | Updated to use RedisSession for AG-UI integration tests |
| tests/deploy/*.py | All deployment tests updated to use RedisSession pattern |
| tests/test_data/agentscope_agent/agent.py | Updated example agent to use RedisSession |
| tests/deploy/assets/agent_for_test.py | Updated test asset agent to use RedisSession |
| src/agentscope_runtime/engine/services/agent_state/* | Deleted - removed all deprecated state service implementation files |
| src/agentscope_runtime/sandbox/manager/sandbox_manager.py | Fixed NGINX_TIMEOUT to use string conversion with fallback |
| src/agentscope_runtime/sandbox/box/gui/gui_sandbox.py | Broadened ARM platform detection from exact match to substring check |
| src/agentscope_runtime/common/container_clients/*.py | Removed unused _is_browser_image methods |
| src/agentscope_runtime/version.py | Version bump to v1.1.0b1 |
| pyproject.toml | Version bump and agentscope dependency updated to >=1.0.14 |
| examples/**/*.py | All examples updated to use RedisSession with fakeredis |
| cookbook/**/service/*.md | Removed deprecated state service documentation |
| cookbook/**/sandbox/sandbox_service.md | Added comprehensive sandbox service documentation |
| cookbook/_toc.yml | Updated TOC to remove service docs section and add sandbox service docs |
| README*.md | Updated code examples to use RedisSession |
Comments suppressed due to low confidence (1)
examples/deployments/detached_local_deploy/app_agent.py:34
- This shutdown function references
self.state_service.stop(), butstate_serviceis never initialized in theinit_func. This will cause an AttributeError at runtime. The shutdown function should either be removed or updated to match the pattern used in other files (e.g., justpassor remove the decorator entirely).
@agent_app.shutdown
async def shutdown_func(self):
await self.state_service.stop()
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request is a significant and well-executed refactoring. It replaces the custom AgentStateService with the more standard agentscope.session.RedisSession, simplifying the state management logic and reducing custom code. The use of fakeredis for local development and testing is a great choice. The changes are consistently applied across the documentation, examples, and tests, which is commendable for a change of this scale. The overall result is a cleaner, more maintainable, and more standardized codebase.
I've found one minor issue in an example file that needs to be addressed. Otherwise, great work!
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 66 out of 68 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
examples/deployments/detached_local_deploy/app_agent.py:34
- The shutdown function still references
self.state_service.stop()which no longer exists after the migration to RedisSession. This line should be removed or the shutdown function should be updated to just pass.
@agent_app.shutdown
async def shutdown_func(self):
await self.state_service.stop()
Description
[Describe what this PR does and why]
This PR updates documentation and cookbook examples to use RedisSession (backed by fakeredis for local/dev) for session state persistence, and removes the legacy Agent State Service documentation sections.
Type of Change
Component(s) Affected
Checklist
Testing
[How to test these changes]
Additional Notes
[Optional: any other context]