Skip to content

feat (engine): replace AgentStateService examples with RedisSession (FakeRedis) and simplify service docs#427

Merged
AgentScopeTeam merged 22 commits intoagentscope-ai:mainfrom
rayrayraykk:dev/0128/v1.1.0beta1
Feb 2, 2026
Merged

feat (engine): replace AgentStateService examples with RedisSession (FakeRedis) and simplify service docs#427
AgentScopeTeam merged 22 commits intoagentscope-ai:mainfrom
rayrayraykk:dev/0128/v1.1.0beta1

Conversation

@rayrayraykk
Copy link
Copy Markdown
Member

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

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactoring

Component(s) Affected

  • Engine
  • Sandbox
  • Tools
  • Common
  • Documentation
  • Tests
  • CI/CD

Checklist

  • Pre-commit hooks pass
  • Tests pass locally
  • Documentation updated (if needed)
  • Ready for review

Testing

[How to test these changes]

Additional Notes

[Optional: any other context]

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @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 AgentStateService to the more integrated and robust RedisSession provided by the agentscope library. This change simplifies the codebase, improves consistency, and enhances the developer experience by leveraging fakeredis for convenient local testing. The associated documentation and examples have been thoroughly updated to reflect this new approach.

Highlights

  • State Management Overhaul: Replaced the custom AgentStateService with RedisSession from the agentscope library for agent state persistence, simplifying the state management mechanism.
  • Simplified Documentation: Removed legacy Agent State Service documentation sections and updated cookbook examples to reflect the new RedisSession usage, improving clarity and maintainability.
  • Development Environment Support: Integrated fakeredis to provide a Redis-backed session experience for local development and testing without requiring a live Redis instance.
  • Version and Dependency Updates: Bumped the project version to 1.1.0b1 and updated the agentscope dependency to >=1.0.14.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread cookbook/zh/agent_app.md Outdated
Comment thread cookbook/zh/agent_app.md
Comment thread cookbook/zh/cli.md Outdated
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 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 RedisSession with fakeredis for 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(), but state_service is never initialized in the init_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., just pass or remove the decorator entirely).
@agent_app.shutdown
async def shutdown_func(self):
    await self.state_service.stop()

Comment thread examples/integrations/ag-ui/agent.py
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings January 29, 2026 10:27
@rayrayraykk
Copy link
Copy Markdown
Member Author

/gemini review

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

Copilot reviewed 65 out of 67 changed files in this pull request and generated 3 comments.

Comment thread cookbook/en/ms_agent_framework_guidelines.md Outdated
Comment thread tests/test_data/agentscope_agent/agent.py
Comment thread cookbook/zh/ms_agent_framework_guidelines.md Outdated
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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!

Copilot AI review requested due to automatic review settings February 2, 2026 02:37
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

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()

Comment thread pyproject.toml
@AgentScopeTeam AgentScopeTeam merged commit 7045c42 into agentscope-ai:main Feb 2, 2026
7 checks passed
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.

4 participants