Skip to content

fix(openviking): synchronous prefetch with current turn's query - #49889

Closed
wgd753 wants to merge 1 commit into
NousResearch:mainfrom
wgd753:fix/ov-sync-prefetch
Closed

fix(openviking): synchronous prefetch with current turn's query#49889
wgd753 wants to merge 1 commit into
NousResearch:mainfrom
wgd753:fix/ov-sync-prefetch

Conversation

@wgd753

@wgd753 wgd753 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Problem

The OpenViking memory provider's prefetch() method returns stale results from a background thread that fired at the end of the previous turn. The current turn's query parameter is completely ignored, meaning automatic memory context is always about the wrong topic.

First turn gets zero context. Every subsequent turn gets stale context from the previous topic.

Root Cause

plugins/memory/openviking/__init__.pyprefetch() currently ignores its query parameter and returns whatever the background thread cached from the previous turn's topic.

Fix

prefetch() now performs a synchronous POST /api/v1/search/find using the current turn's query parameter — matching Claude Code's plugin behavior.

  1. Uses the actual query — searches for the current topic, not the previous one
  2. Score threshold — minimum _PREFETCH_MIN_SCORE = 0.35, filters noise
  3. Timeout guard_PREFETCH_TIMEOUT = 1.5s prevents slow OV from blocking the turn loop
  4. Stale cache drained — previous turn's background-thread result is discarded

queue_prefetch() is unchanged — it still fires background searches at turn-end for pre-warming, but prefetch() no longer consumes its output.

Related

prefetch() now performs a synchronous OV search with the current
query instead of returning stale background-thread results from
the previous turn. This fixes the stale-context problem where
automatic memory injection was always about the wrong topic.

- Drain stale background cache (discard previous turn's results)
- Sync search with current query via POST /api/v1/search/find
- Add _PREFETCH_TIMEOUT (1.5s) to prevent blocking the turn loop
- Add _PREFETCH_MIN_SCORE (0.35) noise filter

queue_prefetch() is unchanged — it still fires background searches
at turn-end for pre-warming, but prefetch() no longer consumes
its output.

Closes: NousResearch#5820
@alt-glitch alt-glitch added type/bug Something isn't working comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Jun 21, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #33260 — same fix: making OpenViking prefetch() perform a synchronous POST /api/v1/search/find with the current turn's query instead of returning stale background-thread results, with the same score threshold (0.35) and a timeout guard. #33260 (open, filed 2026-05-27) is the canonical version. Related: #32444 (broader OpenViking runtime-reliability PR covering the same code path).

@wgd753

wgd753 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

Agreed, this is a duplicate of #33260 — same core fix (sync prefetch with current query, score threshold 0.35, drain stale cache).

One difference our version has that #33260 doesn't: a _PREFETCH_TIMEOUT = 1.5s guard to prevent a slow/unreachable OV server from blocking the agent turn loop. Would be great if #33260 could pick that up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins duplicate This issue or pull request already exists 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.

feat(memory): Allow synchronous recall for current turn as option for honcho and hindsight

2 participants