fix(memory): refresh system version facts on upgrade#1390
fix(memory): refresh system version facts on upgrade#1390kovtcharov-amd wants to merge 1 commit into
Conversation
Memory kept reporting the pre-upgrade GAIA/Lemonade versions: refresh was purely a 7-day age check with no trigger when a version actually changed, so facts could stay stale for up to a week — and a bump produced a duplicate row because version strings overlap below the dedup threshold. System context now refreshes as soon as a stored GAIA/Lemonade version differs from the live value, clears the old `system` entries before re-collecting so values are replaced rather than duplicated, and uses delete_by_category across the startup, CLI, and UI refresh paths (previously the startup path used delete_by_source while the others used delete_by_category). The meta fact is renamed to "last collected on" to match its actual regenerate-every-run behaviour, and the `--system` / `--reset-system` flags and the opt-in `system_context_enabled` setting are now documented.
Review: fix(memory): refresh system version facts on upgradeApprove with suggestions. This is a clean, well-scoped, well-tested fix for a real bug — stale version facts lingering after an upgrade because refresh was a pure 7-day age check and a version bump produced a duplicate (version strings fall below the 0.8 dedup threshold). The new version-aware trigger plus delete-before-recollect is the right shape, and the test coverage is genuinely good. One thing worth a second look: the broad I verified the supporting facts: Issues🟢 Swallowed clear failure can re-introduce duplicates ( The clear-before-recollect is best-effort: if existing:
try:
self._memory_store.delete_by_category("system")
except Exception as e:
logger.debug("[MemoryMixin] failed to clear system context: %s", e)
# ...falls through and re-stores every factIf the delete raises and is swallowed at 🟢 Broad except Exception:
pass
Strengths
VerdictApprove with suggestions — no blocking issues. Both notes are minor hardening around exception handling; neither needs to gate merge. Nice, surgical fix. |
Why this matters
After upgrading GAIA (or Lemonade), the memory system kept reporting the old versions — the Knowledge Browser showed
GAIA version: 0.17.6andLemonade Server version: 10.2.0long after the install was upgraded, so any agent that reads system facts into its prompt reasoned about a stale environment. The cause: system-context refresh was a pure 7-day age check with no trigger tied to an actual version change, and a version bump produced a duplicate fact rather than replacing the old one (version strings overlap ~0.75, below the 0.8 dedup threshold).After this change, system facts refresh as soon as the stored GAIA/Lemonade version differs from the live value — so versions correct themselves on the next agent startup instead of lagging up to a week — and a refresh replaces the old fact instead of leaving two contradictory rows.
Fixes #1384.
Test plan
pytest tests/unit/test_memory_mixin.py— 177 pass (10 new: version-mismatch detection, age trigger, no-duplicate after simulated bump, force-refresh no-duplicate, meta-fact rename)python util/lint.py --black --isort— passgaia memory bootstrap --system), bump__version__/LEMONADE_VERSION, restart an agent → memory shows the new version with exactly one GAIA-version and one Lemonade-version row