Repository navigation
fix(memory): explain rejected embedding responses - #168035
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR adds specific embedding-response errors and safe remote request and response diagnostics. Example: A 40-input bge-m3 indexing request returns duplicate index 0 at position 1.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review This PR fixes a current diagnostic gap with a useful, focused change; no actionable introduced defects or unresolved merge concerns were found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherMemory indexing sends document batches through embedding providers, validates returned vectors, and retains successful embeddings before publishing a complete searchable index. flowchart TD
A[Memory document batches] --> B[Embedding provider HTTP request]
B --> C[Shared vector validator]
C --> D[Memory cache and dimension validation]
D --> E[Complete index publication]
B --> F[Safe diagnostics]
C --> F
Technical reviewBest possible solution: Land the diagnostic repair while preserving successful-work retention and complete-index publication. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically reports duplicate indexes and other invalid vectors through the same generic error; the supplied CLI baseline independently records that behavior, but this review executed no target code. Is this the best way to solve the issue? The change fits the existing validator, HTTP diagnostic, and memory-cache owners, preserves validation and retry contracts, and avoids expanding into incomplete-index publication. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0d3cfe67d3a3. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +124, Tests +94, Docs +7, Other -1. Total +224 across 16 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label 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 9, 2026, 9:10 PM ET / October 10, 2026, 01:10 UTC (Revision 3). |
|
Merged via squash.
|
* fix(memory): explain rejected embedding responses * style(memory): use canonical NaN property in diagnostics
Related: #146985 (diagnostics only).
What Problem This Solves
Fixes: memory indexing reports the same malformed-JSON error for several distinct invalid embedding responses, without enough request context to diagnose the provider.
User Impact
Errors identify the provider, model, batch size, and rejected condition.
OPENCLAW_DEBUG_MEMORY_EMBEDDINGS=1now shows request/response shape for OpenAI and generic OpenAI-compatible embeddings without logging headers, URLs, input text, or vector contents.A bad batch still aborts indexing. Successful-work retention and atomic publication of complete indexes remain unchanged; this PR does not implement partial searchable indexes.
Why This Change Was Made
The shared vector validator owns count, coordinate, and index errors; memory-core retains ownership of dimension validation and cache recovery. Both remote HTTP paths reuse the existing diagnostic owner while keeping their different response limits and redacted provider-error formats. Retry classification retains the original response error text, so model names and batch counts resembling HTTP status codes cannot create new retries or batch splits.
Thanks @jzmudzinski for the report.
Evidence
Real CLI proof used
pnpm openclaw --profile embed-diagnostics memory index --force --verbose, isolated state/config/workspace, and a loopback proxy forwarding to Ollama/v1/embeddings.OPENCLAW_DEBUG_MEMORY_EMBEDDINGS=1enabled the existing diagnostic switch. The proxy mutated genuinebge-m3output after Ollama computed it.Healthy indexing and the final healthy reindex both succeeded with 40 chunks and 1024-dimensional vectors. All seven failures preserved the exact published-row hash and 40-chunk count. The non-finite wire case used valid JSON
1e999(parsed as infinity); a direct-provider regression also covers NaN, which JSON cannot encode as a numeric literal.The full live matrix ran at
535d8531bc96871c226e4fbe7cfbcbc4443a6979; the remaining commit only replaces globalNaNwithNumber.NaNto satisfy lint. Final-headnomic-embed-texthealthy indexing and reindexing passed with 40 chunks and 768 dimensions; the duplicate-index failure preserved the published-row hash and reported its exact index/position. Thebge-m3andnomic-embed-textbaselines both reproduced the generic duplicate-index message on unchanged main code.Nine focused files passed: 148 tests, using
node scripts/run-vitest.mjs <files> --maxWorkers=1, 1560.56 s total wall time on the loaded shared host. The final-head fetch suite separately passed 24 tests in 10.62 s wall (4.75 s Vitest). Reported test time for the changed fetch/policy suites was 0.071/0.228 s. Existing HTTP/auth and SQLite recovery files took 1.15–389.88 s of test time; their existing lifecycle fixtures were retained and no process boots, timers, or sleeps were added. Regression controls failed on pre-fix code: 19 fetch cases, two recovery assertions, and four retry/split cases.Core production and core-test typechecks pass. The required fast ratchets, config docs, plugin inventory, import/dead-export checks, docs links, and core lint pass. The mock-export baseline shrinks by exactly one retired mock. Broad extension typechecking is limited by the missing QA Lab workspace dependency
@openclaw/crabbox-provider/cli-runtime-api.js; those files and dependency declaration are unchanged. The deprecation guard also reports an unchanged direct-config import insrc/gateway/server-methods/agents.ts, already present at the base commit. Extension lint passes after SDK declaration preparation with its documented build timeout set to 900000 ms; the default 300000 ms preparation budget had expired before lint could run. The declaration-enabled full build spent over 20 minutes in workspace declarations; the supported runtime-onlyOPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 pnpm buildpassed on the final head in 570.7 s.Independent Codex autoreview of the final head is scoped-clean at P0–P2, with no actionable findings. ClawSweeper reviewed
2a607eebcb10a813a7c0304053171027a8df531c: no findings, no Before merge items, ready for maintainer review; live proof rated sufficient. CI run 38010006201 passed on the same head (41 successful jobs, 23 skipped, zero failures), andopenclaw/ci-gateis successful. All nine selected Node test jobs passed in 62–214 s each (1152 aggregate job-seconds including setup); the fast baseline-ratchet job passed in 94 s. CI production types, test types, and extension lint passed, despite the noted broader local QA dependency limitation.Production: +176/-52 lines (net +124). Tests: +291/-197 (net +94). Docs: +7; baseline: -1. Production could not remain neutral without collapsing intentionally different HTTP-reader contracts or removing existing validation/recovery checks; the added branches distinguish failures, share safe metadata, and preserve retry classification.