Skip to content

Fix memory_update: forward item_id by keyword in memU SQLite monkeypatch - #119

Merged
pufit merged 1 commit into
mainfrom
pufit/fix-memu-update-item-keyword
Jun 18, 2026
Merged

Fix memory_update: forward item_id by keyword in memU SQLite monkeypatch#119
pufit merged 1 commit into
mainfrom
pufit/fix-memu-update-item-keyword

Conversation

@pufit

@pufit pufit commented Jun 18, 2026

Copy link
Copy Markdown
Member

Problem

The memory_update tool (memU item update) silently failed for every update, returning Failed to update memory <id> instead of surfacing an error.

Root cause: the vector-index monkeypatch in nerve/memory/memu_bridge.py wraps SQLiteMemoryItemRepo.update_item and forwarded item_id positionally:

def _indexed_update_item(self, item_id, *args, **kwargs):
    result = _original_update_item(self, item_id, *args, **kwargs)  # positional

But memu-py==1.4.0 declares update_item(self, *, item_id, ...)item_id is keyword-only. The wrapper therefore called the original with self + item_id as two positionals, raising:

SQLiteMemoryItemRepo.update_item() takes 1 positional argument
but 2 positional arguments (and 3 keyword-only arguments) were given

update_item() in the bridge catches that TypeError and returns False, so the tool reported a silent failure rather than raising. delete_item(self, item_id) is not keyword-only, so the identical wrapper pattern worked there — which is why deletes succeeded and masked the bug. This has been latent since the memu-py==1.4.0 pin.

Fix

Forward args verbatim (matching the sibling _numpy_create_item wrapper) and derive item_id from kwargs/args for the index hook:

def _indexed_update_item(self, *args, **kwargs):
    result = _original_update_item(self, *args, **kwargs)
    item_id = kwargs.get("item_id", args[0] if args else None)
    ...

Tests

Added TestIndexedUpdateItemForwarding in tests/test_memu_bridge.py:

  • Guards that memu's update_item is keyword-only (catches future signature drift).
  • Exercises the real _patch_sqlite_bugs wrapper with a keyword-only spy original and asserts item_id is forwarded by keyword without a TypeError (restores global state afterward).

Full suite: 1158 passed, 2 skipped.

Generated by Nerve

memu-py 1.4.0's SQLiteMemoryItemRepo.update_item is keyword-only
(def update_item(self, *, item_id, ...)), but the _indexed_update_item
vector-index wrapper forwarded item_id positionally. That raised
"takes 1 positional argument but 2 were given", caught inside the bridge,
so every memory_update silently returned "Failed to update memory".
delete_item(self, item_id) is not keyword-only, which is why deletes kept
working and masked the bug.

Forward args verbatim (matching the _numpy_create_item wrapper) and derive
item_id from kwargs/args for the index hook. Add regression tests.
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