In provider mode, prefetch() returned the previous turn's cached result, so memory context was always one turn behind. With ~40ms local retrieval there's no reason for the lag.
Changes:
prefetch(query) reuses the in-flight background search when it matches the current query, else searches synchronously — same-turn injection
_prefetch_query scopes cached results to their query; result is reset when a new search starts and thread writes are guarded, preventing stale cross-turn injection after a timed-out join
Sync prefetch capped at 3s total (split across both requests in case-insensitive mode) so a hung server can't stall the LLM hot path for 10s
Verified: py_compile passes; two review passes, all findings addressed.
In provider mode, prefetch() returned the previous turn's cached result, so memory context was always one turn behind. With ~40ms local retrieval there's no reason for the lag.
Changes:
- prefetch(query) reuses the in-flight background search when it matches the current query, else searches synchronously — same-turn injection
- _prefetch_query scopes cached results to their query; result is reset when a new search starts and thread writes are guarded, preventing stale cross-turn injection after a timed-out join
- Sync prefetch capped at 3s total (split across both requests in case-insensitive mode) so a hung server can't stall the LLM hot path for 10s
- LocalMem0Client gains optional per-request timeout override
- AGENTS.md / README updated to match
Verified: py_compile passes; two review passes, all findings addressed.
prefetch() now reuses the in-flight background search when it matches
the current query, or falls back to a synchronous search (capped at 3s,
split across both requests in case-insensitive mode) so memories are
injected on the same turn instead of one turn behind.
- Track _prefetch_query to scope cached results to their query
- Reset _prefetch_result when starting a new background search to
prevent stale cross-turn injection after a timed-out join
- Guard background thread writes against superseded queries
- Add optional per-request timeout override to LocalMem0Client
- Update AGENTS.md and README to describe the same-turn flow
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
In provider mode, prefetch() returned the previous turn's cached result, so memory context was always one turn behind. With ~40ms local retrieval there's no reason for the lag.
Changes:
Verified: py_compile passes; two review passes, all findings addressed.
✅ No issues found — changes look consistent with the stated intent. Ready to be merged.