Skip to content

fix(observations): explicit clear resets the memory even with no observations to delete - #5775

Merged
nicoloboschi merged 1 commit into
mainfrom
triage/5731
Oct 19, 2026
Merged

nicoloboschi merged 1 commit into
mainfrom
triage/5731

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

Fixes #5731.

Problem

DELETE /v1/default/banks/{bank_id}/memories/{memory_id}/observations says it resets the memory for re-consolidation and triggers a consolidation job. It only did either when it deleted at least one observation. A fact consolidation kept nothing from stays marked consolidated, so clearing it answered 200 {"deleted_count": 0} and changed nothing.

The deleted_count > 0 guards date back to the original import (#560); no recorded reason. This is not #5054 (automatic retry of skipped facts, by design): this is an explicit, operator-requested reset of one memory.

Fix

clear_observations_for_memory now always clears the memory's own consolidated marker and, when auto-consolidation is on, submits a job. Memory text, document, chunks and updated_at are untouched, as before.

Behaviour changes

  • Every explicit per-memory clear queues a consolidation job (with auto-consolidation on), even if nothing was reset.
  • Calling it on an observation id or unknown id queues a job that finds nothing to do (the requeue itself already skips non-world/experience rows).

Tests

  • api-slim: test_no_observations_still_resets_memory (replaces the test that pinned the old behaviour) and an HTTP-route test. Both fail before, pass after.
  • system story in test_25_observation_lifecycle.py: consolidation keeps nothing, clearing that memory triggers a new pass that produces the observation. Fails before ("the cleared memory was never consolidated again"), passes after.

Thanks @koriyoshi2041 for the independent repro and fix on the issue.

…rvations to delete (#5731)

DELETE /memories/{id}/observations promised to reset the memory for
re-consolidation, but only did so when it deleted at least one
observation. A memory consolidation had kept nothing from stayed marked
consolidated and no job was queued. The reset and the auto-consolidation
submit now run on every explicit clear; the document change history still
records a clear only when it removed observations.

Review fixes: system story asserts the first consolidation pass ran;
test helper documents why it reads the marker directly.
@nicoloboschi
nicoloboschi merged commit 4ad3ec6 into main Oct 19, 2026
115 of 117 checks passed
@nicoloboschi
nicoloboschi deleted the triage/5731 branch October 19, 2026 16:44
@nicoloboschi nicoloboschi mentioned this pull request Nov 3, 2026
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.

Explicit source observation clear does not reset consolidated sources when deleted_count is zero

1 participant