Skip to content

[BUG] Memory read_only still persists update and recall access-time writes #7368

Description

@roli-lpci

Description

Memory.read_only blocks remember and remember_many, but two other implicit write paths still mutate the backing store: update rewrites a record, and recall refreshes last_accessed through touch_records. As a result, reading through a read-only Memory leaves a persistent trace.

Steps to Reproduce

  1. Create a Memory with local storage and store one record while writable.
  2. Set memory.read_only = True.
  3. Call update on that record; its content changes.
  4. Or call recall; the stored last_accessed timestamp advances.

Expected behavior

When read_only is true, implicit persistence paths leave stored records unchanged. Explicit deletion through forget and reset is a separate operation and can remain available.

Screenshots/Code snippets

A focused regression is available in PR #7367. It asserts that read-only update returns the existing record unchanged and that read-only recall does not advance last_accessed, with writable positive controls.

Operating System

Other: macOS Sequoia.

Python Version

3.12

crewAI Version

1.15.21

crewAI Tools Version

Not used.

Virtual Environment

Venv

Evidence

The two regression tests fail on the current implementation and pass with PR #7367. The full memory test directory passes: 134 passed, 19 skipped. Ruff and the repository gates are clean.

Possible Solution

Honor read_only before update writes and before recall invokes touch_records. Return the existing record from read-only update to match remember's silent no-op behavior.

Additional context

This preserves recall results and leaves explicit forget/reset behavior unchanged. The patch is limited to two behavior checks, documentation, and regression tests.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions