Skip to content

fix(memory): requeue failed index_file paths in MemorySyncManager (#638) - #646

Closed
Tiktokaiagent wants to merge 4 commits into
use-agent-os:mainfrom
Tiktokaiagent:fix/638-memory-sync-retry
Closed

fix(memory): requeue failed index_file paths in MemorySyncManager (#638)#646
Tiktokaiagent wants to merge 4 commits into
use-agent-os:mainfrom
Tiktokaiagent:fix/638-memory-sync-retry

Conversation

@Tiktokaiagent

@Tiktokaiagent Tiktokaiagent commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

When _do_file_sync() calls index_file() and it raises, the path's mtime was already recorded in _mtimes, so the next watcher tick skips it as unchanged. The file remains on disk but searches use stale or missing index data.

Fix

  • Pop the path from _mtimes on index_file() exception so the next watcher tick sees it as new
  • Set _dirty = True to ensure the next search-time sync retries

Changes

  • src/agentos/memory/sync_manager.py: 2 lines changed

Tests

New regression test in tests/test_memory_sync_manager_architecture.py:

$ uv run pytest tests/test_memory_sync_manager_architecture.py -v --tb=short
...
tests/test_memory_sync_manager_architecture.py::test_sync_manager_scans_archive_as_curated_memory_subdir PASSED
tests/test_memory_sync_manager_architecture.py::test_sync_force_rescans_unchanged_memory_sources PASSED
tests/test_memory_sync_manager_architecture.py::test_sync_force_overrides_search_clean_fast_path PASSED
tests/test_memory_sync_manager_architecture.py::test_failed_index_file_is_requeued_for_retry PASSED
============================== 4 passed in 0.31s ===============================
  • This pull request fully resolves the linked issue.
  • Bug fix: no breaking changes to existing behavior
  • Minimal 2-line change, single file

Fixes #638

@Tiktokaiagent Tiktokaiagent changed the title fix(memory): requeue failed index_file paths in MemorySyncManager fix(memory): requeue failed index_file paths in MemorySyncManager (#638) Aug 31, 2026
@Tiktokaiagent
Tiktokaiagent force-pushed the fix/638-memory-sync-retry branch from c4537a0 to e77c1d7 Compare September 1, 2026 01:28
Tiktokaiagent and others added 2 commits September 1, 2026 17:30
When _do_file_sync calls index_file() and it raises, the path's mtime
was already recorded in _mtimes, so the next watcher tick would skip
it and never retry. The file remains on disk but searches use stale
index data.

Fix: pop the path from _mtimes on exception and set _dirty=True so the
next watcher tick (or search-time sync) retries indexing.

Fixes use-agent-os#638
…e-agent-os#638)

- test_failed_index_file_is_requeued_for_retry — verifies that when
  index_file raises, the path is removed from _mtimes so the next
  watcher tick retries indexing instead of skipping it as unchanged.

- uv run pytest tests/test_memory_sync_manager_architecture.py -v — 4 passed
@Tiktokaiagent
Tiktokaiagent force-pushed the fix/638-memory-sync-retry branch from 7cdc525 to 7ccec63 Compare September 1, 2026 17:31
@Tiktokaiagent
Tiktokaiagent force-pushed the fix/638-memory-sync-retry branch from 7ccec63 to 4ec1302 Compare September 1, 2026 17:49
@andreapn

andreapn commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Closing — this does not meet the acceptance criteria in issue #638.

Popping the path from _mtimes does get it retried on the next full-scan sync, but the _dirty flag does not survive. _do_file_sync() sets self._dirty = True, and then sync() runs its else branch immediately afterwards:

self._dirty = bool(self._pending_changes or self._pending_deletes or session_sync_failed)

Since the failed path is not put back on _pending_changes, that evaluates to False. Verified in a worktree against your branch:

after failed sync: calls=['MEMORY.md']  _dirty=False  pending=set()

The issue asks for "keep the manager dirty while a failed path is pending" — without it, nothing triggers a search-time retry and the file waits for the poll interval.

#781 was picked for this issue. Thanks for looking at it.

@andreapn andreapn closed this Sep 2, 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.

[Bug]: MemorySyncManager never retries files after transient index failure

2 participants