Skip to content

fix(memory): skip drift guard for add (append-only) action (#42874) - #52091

Merged
kshitijk4poor merged 1 commit into
mainfrom
salvage/42874-memory-drift-guard-add
Jun 24, 2026
Merged

fix(memory): skip drift guard for add (append-only) action (#42874)#52091
kshitijk4poor merged 1 commit into
mainfrom
salvage/42874-memory-drift-guard-add

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Summary

memory(action=add) no longer refuses legitimate appends when the on-disk MEMORY.md byte count differs from the in-memory base cache. The drift guard is now skipped for the append-only add action but remains active for replace/remove which flush full state.

Changes

  • tools/memory_tool.py: add skip_drift keyword parameter to _reload_target(); add() passes skip_drift=True while replace()/remove() continue using the drift guard unchanged
  • tests/tools/test_memory_tool.py: updated test_add_succeeds_despite_drift to verify add proceeds with drift

Validation

  • 18 drift/add tests pass
  • No conflicts — clean cherry-pick onto current main

Salvaged from #42880 by @liuhao1024.

Closes #42874

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: salvage/42874-memory-drift-guard-add vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 11197 on HEAD, 11195 on base (🆕 +2)

🆕 New issues (2):

Rule Count
unresolved-attribute 2
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_credits_session_start_micros` on type `AIAgent`
run_agent.py:2984: [unresolved-attribute] unresolved-attribute: Object of type `Self@get_credits_spent_micros` has no attribute `_credits_session_start_micros`

✅ Fixed issues (1):

Rule Count
invalid-assignment 1
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to attribute `_credits_session_start_micros` of type `int`

Unchanged: 5914 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working tool/memory Memory tool and memory providers comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have labels Jun 24, 2026
The drift guard (introduced for #26045) correctly protects replace/remove
from clobbering un-roundtrippable content, but it also fires on the add
path. Since add only appends and never overwrites, the guard is
unnecessary and causes false positives when prior add() calls in the same
session shift the byte count of the on-disk file.

Add skip_drift parameter to _reload_target() and pass True from add().
Replace/remove continue to use the drift guard unchanged.

Salvaged from #42880 by @liuhao1024.

Closes #42874
@kshitijk4poor
kshitijk4poor force-pushed the salvage/42874-memory-drift-guard-add branch from 0873885 to 25e2312 Compare June 24, 2026 19:21
@kshitijk4poor
kshitijk4poor enabled auto-merge June 24, 2026 19:25
@kshitijk4poor
kshitijk4poor merged commit 6800fd6 into main Jun 24, 2026
27 checks passed
@kshitijk4poor
kshitijk4poor deleted the salvage/42874-memory-drift-guard-add branch June 24, 2026 19:28
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…-memory-drift-guard-add

fix(memory): skip drift guard for add (append-only) action (NousResearch#42874)
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
…-memory-drift-guard-add

fix(memory): skip drift guard for add (append-only) action (NousResearch#42874)
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
…-memory-drift-guard-add

fix(memory): skip drift guard for add (append-only) action (NousResearch#42874)
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
…-memory-drift-guard-add

fix(memory): skip drift guard for add (append-only) action (NousResearch#42874)
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
…-memory-drift-guard-add

fix(memory): skip drift guard for add (append-only) action (NousResearch#42874)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] memory(action=add) refuses legitimate appends when disk MEMORY.md byte size differs from in-memory base cache (drift guard over-reach, ref #26045)

3 participants