Skip to content

refactor(memory): convert memory classes to serializable#4761

Merged
greysonlalonde merged 4 commits intomainfrom
gl/refactor/memory-basemodel
Mar 9, 2026
Merged

refactor(memory): convert memory classes to serializable#4761
greysonlalonde merged 4 commits intomainfrom
gl/refactor/memory-basemodel

Conversation

@greysonlalonde
Copy link
Contributor

@greysonlalonde greysonlalonde commented Mar 7, 2026

Note

Medium Risk
Refactors core memory types (Memory, MemoryScope, MemorySlice) to Pydantic BaseModel, which can subtly change initialization/attribute semantics and impacts any code relying on the previous private _read_only flag or direct patching of instance methods.

Overview
Memory refactor for serialization: Memory, MemoryScope, and MemorySlice are converted to Pydantic BaseModels with fields + model_post_init/validators to set up runtime-only dependencies (LLM/embedder/storage) while keeping instances serializable.

API/behavior adjustments: replaces the private _read_only flag with a public read_only boolean (and MemoryScope.read_only passthrough), tightens depth typing to Literal["shallow", "deep"], and updates remember/tooling to no-op consistently when read_only=True.

Integration/test updates: agent memory save paths (CrewAgentExecutorMixin, LiteAgent, create_memory_tools) now check memory.read_only, and tests patch Memory methods at the class level to avoid Pydantic instance attribute restrictions while updating constructors to keyword-based MemoryScope(memory=..., root_path=...) / MemorySlice(memory=..., scopes=...).

Written by Cursor Bugbot for commit 6df5421. This will update automatically on new commits. Configure here.

@greysonlalonde greysonlalonde requested review from a team and joaomdmoura March 7, 2026 19:52
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@greysonlalonde greysonlalonde merged commit cd42bcf into main Mar 9, 2026
45 checks passed
@greysonlalonde greysonlalonde deleted the gl/refactor/memory-basemodel branch March 9, 2026 03:08
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.

2 participants