Skip to content

refactor: remove SessionStore, migrate to StorageProvider - #180

Merged
Leoyzen merged 4 commits into
refactor/agentwolf_v1from
refactor/remove-sessionstore
Jul 17, 2026
Merged

refactor: remove SessionStore, migrate to StorageProvider#180
Leoyzen merged 4 commits into
refactor/agentwolf_v1from
refactor/remove-sessionstore

Conversation

@Leoyzen

@Leoyzen Leoyzen commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Remove the deprecated SessionStore Protocol and MemorySessionStore class, migrating all session persistence to StorageProvider / SessionPersistence.

Closes #170

Motivation

AgentPool had two coexisting session storage hierarchies:

  1. SessionStore (deprecated, sessions/store.py) — 4-method Protocol with only MemorySessionStore as implementation
  2. SessionPersistence (current, agentpool_storage/protocols.py) — 6-method Protocol backed by StorageProvider

All production code already used SessionPersistence. SessionStore was dead code — only MemorySessionStore survived as a config fallback and test fixture. This dual hierarchy caused confusion and maintenance burden.

Changes

Production code

  • Delete src/agentpool/sessions/store.py (SessionStore Protocol + MemorySessionStore class)
  • Remove SessionStore re-export from sessions/__init__.py (keep SessionPersistence)
  • Remove get_session_store() from StorageConfig and SQLStorageConfig
  • Fix MemoryStorageProvider.delete_session() to clean up checkpoints (was a bug — MemorySessionStore did this but MemoryStorageProvider didn't)
  • Add no-op MemoryStorageProvider.update_sdk_session_id() override (base class raises NotImplementedError)

Test migration (17 files)

Migrated all test files from MemorySessionStore to MemoryStorageProvider:

  • Import changes: from agentpool.sessions.storefrom agentpool_storage.memory_provider.provider
  • API changes: .save().save_session(), .load().load_session(), .delete().delete_session(), .list_sessions().list_session_ids()
  • Checkpoint API: save_checkpoint 3rd param now str (JSON-encoded), load_checkpoint returns tuple[str, str]
  • list_sessions(parent_id=)list_session_ids() + load_session() + Python-side filter by SessionData.parent_id
  • Fix async with store: pattern in test_create_child_session.py (MemoryStorageProvider.cleanup() clears data on exit)

Verification

  • ruff check src/ — all checks passed
  • pytest — 192 passed, 1 skipped, 0 failures (across all 17 migrated test files)
  • Zero remaining references to MemorySessionStore or agentpool.sessions.store in src/ or tests/

Breaking changes

  • SessionStore Protocol and MemorySessionStore class removed (were already deprecated)
  • StorageConfig.get_session_store() method removed (dead code)
  • MemoryStorageProvider constructor takes MemoryStorageConfig | None, not a path string

Leoyzen added 2 commits July 17, 2026 19:19
fastmcp 3.4.4 passes follow_redirects=True to httpx_client_factory,
but our factory also passed it explicitly, causing
'httpx.AsyncClient() got multiple values for keyword argument'
on MCP server initialization.

Use kwargs.setdefault() so caller-provided value takes precedence.
Remove the deprecated SessionStore Protocol and MemorySessionStore class.
All session persistence now uses StorageProvider/SessionPersistence.

Changes:
- Delete src/agentpool/sessions/store.py (SessionStore, MemorySessionStore)
- Remove SessionStore re-export from sessions/__init__.py
- Remove get_session_store() from StorageConfig and SQLStorageConfig
- Fix MemoryStorageProvider.delete_session() to clean up checkpoints
- Add no-op MemoryStorageProvider.update_sdk_session_id() override
- Migrate 17 test files from MemorySessionStore to MemoryStorageProvider
- Fix async with store: pattern in test_create_child_session.py
  (MemoryStorageProvider.cleanup() clears data on __aexit__)

Closes #170

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

Copy link
Copy Markdown

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 removes the deprecated SessionStore and MemorySessionStore implementations, transitioning the codebase and test suites to use MemoryStorageProvider and the SessionPersistence protocol. Additionally, it refactors mcp_server.py to prevent duplicate follow_redirects arguments when initializing httpx.AsyncClient. The review feedback points out minor code quality issues, including PEP 8 spacing violations in test_session_hierarchy.py and duplicate # type: ignore comments in test_resume_concurrency.py.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.


async def test_create_with_parent_id(
self, mock_pool: MagicMock, memory_store: MemorySessionStore
self, mock_pool: MagicMock, memory_store: MemoryStorageProvider

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

There are multiple consecutive spaces before mock_pool: MagicMock. Please format this line to adhere to PEP 8 spacing guidelines.

Suggested change
self, mock_pool: MagicMock, memory_store: MemoryStorageProvider
self, mock_pool: MagicMock, memory_store: MemoryStorageProvider
References
  1. Adhere to PEP 8 spacing guidelines by avoiding multiple consecutive spaces. (link)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed. ruff format already corrected the consecutive spaces in the latest push.


async def test_create_with_invalid_parent(
self, mock_pool: MagicMock, memory_store: MemorySessionStore
self, mock_pool: MagicMock, memory_store: MemoryStorageProvider

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

There are multiple consecutive spaces before mock_pool: MagicMock. Please format this line to adhere to PEP 8 spacing guidelines.

Suggested change
self, mock_pool: MagicMock, memory_store: MemoryStorageProvider
self, mock_pool: MagicMock, memory_store: MemoryStorageProvider
References
  1. Adhere to PEP 8 spacing guidelines by avoiding multiple consecutive spaces. (link)

await original_save(data)

store.save = tracking_save # type: ignore[method-assign]
store.save_session = tracking_save # type: ignore[method-assign] # type: ignore[method-assign]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

There is a duplicate # type: ignore[method-assign] comment on this line. Please remove the duplicate to keep the code clean.

Suggested change
store.save_session = tracking_save # type: ignore[method-assign] # type: ignore[method-assign]
store.save_session = tracking_save # type: ignore[method-assign]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed. Duplicate # type: ignore[method-assign] removed in latest push.

await original_save(data)

store.save = tracking_save # type: ignore[method-assign]
store.save_session = tracking_save # type: ignore[method-assign] # type: ignore[method-assign]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

There is a duplicate # type: ignore[method-assign] comment on this line. Please remove the duplicate to keep the code clean.

Suggested change
store.save_session = tracking_save # type: ignore[method-assign] # type: ignore[method-assign]
store.save_session = tracking_save # type: ignore[method-assign]

Leoyzen added 2 commits July 17, 2026 20:34
- Fix import sorting in test_acp_session_manager_child_session.py
- Run ruff format on all test files (fixes consecutive spaces)
- Remove deleted agentpool.sessions.store from import linter config
- Remove duplicate # type: ignore[method-assign] in test_resume_concurrency.py
@Leoyzen
Leoyzen merged commit 94dc4b1 into refactor/agentwolf_v1 Jul 17, 2026
5 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.

1 participant