Skip to content

v0.5.1 — memory remove no longer wipes a whole theme

Choose a tag to compare

@andreab67 andreab67 released this 07 Sep 15:20
· 95 commits to main since this release
37b72d5

Upgrade promptly — this fixes a data-loss bug

memory remove deleted every mirrored entry for a theme, not one.

_worker passed old_text=item.content for a remove. But the built-in tool's remove op carries its target in old_text and leaves content empty (tools/memory_tool.py — remove requires old_text), and the host forwards it through metadata, not content. So item.content was always "", store.remove built content LIKE '%%', and that matches every row — one memory remove wiped the entire mirror for that (agent_identity, target).

Verified against Postgres: DELETE … WHERE c LIKE '%%' removes all rows. Checked the reference deployment for damage — none; every theme's history is continuous, so removes are evidently rare in practice.

Fixed at two layers, because one is not enough for a silent full-scope delete:

  • _worker reads extra["old_text"] and refuses a remove with no usable target
  • store.remove() rejects an empty pattern outright, so the destructive delete is unreachable by omission from any caller
  • remove() now deletes at most one row (lowest id), matching the built-in — which requires a unique match and errors on ambiguity — and this class's own replace()

The built-in store was never affected; only the pgvector mirror.

Also fixed

  • Empty-content rows are no longer created or retried forever. Nothing rejected empty add/replace, so a row could exist that embed() can never process (EmbeddingError("empty input") is unconditional for blank text). The nightly backfill then re-tried it on every run, pinning failed above zero and making remaining == 0 unreachable — destroying the one signal an operator watches, since a permanently-stuck row became indistinguishable from a new genuine failure. Empty writes are now skipped (remove exempt), and un-embeddable rows are excluded from the sweep and reported as unembeddable, so remaining can reach zero again.
  • The whitespace predicate matches Python. Postgres trim() strips spaces only, so a row holding just a newline or tab still slipped through and still failed forever. All sites now use content ~ '\S'.
  • Those predicates are raw strings. As plain f-strings, \S is an invalid Python escape — four DeprecationWarnings today, SyntaxWarning on 3.12+, and under -W error the module fails to import, which would make hermes-agent's loader silently fall back to built-in memory. Both reproduced and fixed.
  • hermes-pgvector stats reports backfillable and un-embeddable counts separately; the fail-soft backfill path returns the unembeddable key its contract promises.

Validation

118 tests skip-mode, 164 against live Postgres 16 + pgvector 0.8.6 with all four migrations applied. Two review passes: the first found the data-loss bug, the second found the broken escape sequence in that fix. Attached artifacts are sha256-identical to the PyPI files.

Full changelog: v0.5.0...v0.5.1