Repository navigation
fix(memory): format Nemotron embeddings and refresh aliased vectors - #184142
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesAdds Nemotron embedding prefixes, paired formatting overrides, and Ollama digest-aware vector identity with compatible legacy-cache adoption. Example: Index “remember this” and search “find this” using nvidia/Nemotron-3-Embed-8B-BF16.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR addresses a current memory-retrieval defect and has no actionable findings; the earlier upgrade-proof blocker is resolved, while exact-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherMemory Core converts memory documents and search queries into provider requests, then stores and retrieves vectors through its existing database publication owner. flowchart LR
A[Memory documents and queries] --> B[Resolved memory settings]
B --> C[Shared input formatter]
C --> D[Embedding provider transport]
D --> E[Embedding vectors]
F[Ollama model digest] --> G[Index and cache identity]
G --> H[Database publication owner]
E --> H
Technical reviewBest possible solution: Keep formatting, digest-aware identity, and compatible cache adoption within the existing formatter and atomic publication owners. Do we have a high-confidence way to reproduce the issue? Current-main source establishes raw Nemotron inputs and digestless Ollama identity, matching the affected-release report and supplied before-fix CLI reproduction; no target code was executed during this review. Is this the best way to solve the issue? The patch extends existing formatting and publication owners, preserves query-only cache reuse, and covers the earlier Gemini override and upgrade concerns without unnecessary parallel machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4d560fde03f9. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +189, Tests +435, Docs +55, Generated 0, Other -1. Total +678 across 33 files. Added test files: 0. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed October 26, 2026, 3:31 AM ET / 07:31 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…penclaw#184142) * test(memory): define paired embedding prefix contract * fix(memory): format Nemotron inputs and refresh aliased vectors * test(memory): narrow the embedding fixture provider * fix(memory): honor explicit document formats in Gemini * fix(memory): distinguish explicit raw document identity * fix(memory): preserve vectors when adopting Ollama digests
What Problem This Solves
Fixes missing query/document task prefixes for Nemotron embedding models and stale vectors after an Ollama embedding alias changes its backing model. Fixes #182842. Thanks @ajmtrz for the report and retrieval measurements.
User Impact
Recognizable Nemotron-3-Embed and Nemotron-3.5-Embed models receive
"query: "and"passage: "prefixes. Aliased models can setmemory.search.inputFormat: { query: "query: ", document: "passage: " }. Whitespace is preserved; empty strings select raw text. A nonemptyqueryInstructionstill wins for queries. Explicit document formatting also replaces Gemini's default template in synchronous and asynchronous requests.Built-in format upgrades rebuild affected indexes once. Explicit document-prefix changes and changed Ollama digests invalidate both the index and embedding cache; use
openclaw memory index --forcewhen configuration identity reports a mismatch. Query-only changes preserve document vectors. Compatible digestless Ollama indexes adopt the first observed digest while preserving cached vectors. The old index cannot establish whether an alias was retargeted before that first observation; reset memory first if it was.Ollama checks its advertised digest when the embedding provider opens, so an already-open provider must reopen after alias retargeting. Embedding-only endpoints without
/api/tagsremain supported; usememory resetafter changing an alias on those endpoints. Global--forcecache behavior is unchanged.Why This Change Was Made
The shared formatter owns both roles, and its revisioned identity isolates document-format changes. Native Ollama adds its resolved model digest to that identity. The existing atomic provider-key migration adopts compatible legacy cache rows; alias cache reads require matching published metadata so leftover or unpublished legacy vectors cannot contaminate a later digest. No new schema or persistence owner was introduced.
NVIDIA documents the exact prefixes in the Nemotron-3 model card and Nemotron-3.5 saved prompts. Matching stays narrow because other Nemotron families have different contracts.
Production: +250/-61 lines; tests: +527/-92; docs/generated: +67/-12; one obsolete mock-baseline line removed. Necessary growth supplies paired config, identity/format plumbing, bounded authenticated digest lookup, and safe legacy-cache adoption. Formatting stays in the existing embedding-policy owner; the oversized embedding-ops module shrinks.
Evidence
memory index --force. Regressions failed before repair. The published-upgrade follow-up also reproduced one unnecessary ordinary-document request and three stale-cache paths before repair.1db10d3ce63bb9ec01ac7e1e74b1034fa770839e: scoped-clean. Full build passes (791.60s elapsed, including artifact-lock waiting; active phases 544.4s).Upgrade proof
On macOS, installed published
[email protected]into an isolated npm prefix, HOME, state, and config; indexed/searched a syntheticMEMORY.md; then manually replaced the package in that same prefix with the validated tarball built from1db10d3ce63bb9ec01ac7e1e74b1034fa770839e. This was a local npm package replacement, not an automatic update. Both restored states matched every published memory table before the candidate first opened them. The ordinary case used real Ollamanomic-embed-text:latest; the Nemotron name used a deterministic Ollama-compatible endpoint with different vectors for raw, automatic, and explicit document formats.The upgrade proof exposed and now covers the ordinary-model cache migration bug fixed in the follow-up: the earlier candidate sent one unnecessary unchanged document request. The repaired candidate preserves its vector bytes and cache timestamps, adopts the digest key atomically, and retires the legacy namespace.
A literal zero index rewrite is not possible against this stable baseline: main already changed chunking revision 5→6 in #168867. Both cases undergo that inherited one-time chunking rebuild. This PR adds zero document re-embeddings for the ordinary model; it preserves the old cache/vector bytes through that rebuild.
Captured identity and request excerpts (synthetic text; local paths omitted):
Explicit override replay passed all six index/search commands in 37.184s.
{query: "lookup: ", document: "record: "}sends those exact bytes and embeds once. Changing only the query to"find: "preserves the provider key, cache bytes/timestamps, and makes zero document requests. The raw pair sends the original unprefixed bytes under a distinct key and embeds once. Retrieval succeeds in every case.Both published-state Doctor migrations completed successfully in parallel (82.888s each). Final config validation passes. Final Doctor output on each state is
{"ok":true,"checksRun":41,"checksSkipped":30,"findings":[]}(19.257s/19.268s); versioned SQLite stores have no pending migrations or schema mismatch, and Doctor leaves every memory table unchanged. The isolated diagnostic config declares its existing local Qwen model and disables the unused legacy browser relay, removing unrelated discovery/legacy-relay warnings. No operator state or Gateway was used.The candidate tarball passed the canonical integrity/import-graph check and the installed build reports the exact head above. Manual replacement took 137.688s plus a 1.356s allowlisted dependency rebuild. Exact Nemotron quality remains untested; this verifies its input contract, persisted-vector replacement, retrieval, and upgrade behavior using synthetic vectors, with real nomic as the ordinary-model control.