Repository navigation
fix(memory): embeddings fail when providers reject oversized batches - #138992
saladinyao-cyber wants to merge 1 commit into
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. Reviewed September 5, 2026, 7:00 AM ET / 11:00 UTC. ClawSweeper reviewWhat this changesMemory Core recognizes another explicit embedding batch-size rejection and uses its existing splitter to recover, with classifier, ordering, and HTTP coverage. Merge readiness✅ Ready for maintainer review The fix remains necessary on current main, with no blocking findings. The contributor’s added HTTP recovery evidence addresses the previous proof concern. Priority: P2 Review scores
Verification
How this fits togetherMemory Core turns memory chunks into vectors for semantic search. Its embedding manager sends batches to the configured provider, handles failures, and returns ordered vectors to the indexer. flowchart TD
A[Memory chunks] --> B[Embedding manager]
B --> C[Provider HTTP request]
C --> D{Explicit batch limit?}
D -->|Yes| E[Split into smaller batches]
E --> C
D -->|Success| F[Ordered vectors]
D -->|Other permanent error| G[Report failure]
F --> H[Memory index]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource 0, Tests +49. Total +49 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep batch-limit recovery in the shared classifier and existing bounded splitter, preserving input order and permanent-error handling. Do we have a high-confidence way to reproduce the issue? Yes, from source: send 33 inputs to an endpoint that rejects batches above ten with the reported HTTP 400 wording; current main propagates the error because neither classifier accepts it. The reviewer did not execute this scenario. Is this the best way to solve the issue? Yes. Extending the existing classifier repairs the owning boundary without duplicating batching logic or introducing a provider-specific cap; the HTTP scenario covers error propagation through the real client. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1a13b42b6b75. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
1b734c9 to
0253155
Compare
|
Added real behavior proof in @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
0253155 to
eb61001
Compare
Yigtwxx
left a comment
There was a problem hiding this comment.
Reviewed head eb610016289. The classifier change is correct and the HTTP test proves the recovery path end to end; I re-ran the same scenario through the real splitter on both arms and the control matches the description (on main the first request rethrows as a permanent failure, on this head it recovers). One non-blocking observation that the review bot did not cover, plus one nit.
The classifier now requires the numeric limit, but the splitter discards it.
The new alternative in SPLITTABLE_MEMORY_EMBEDDING_BATCH_ERROR_RE (manager-embedding-policy.ts:58) only accepts the message when it carries larger than\s+\d+, and the PR body makes that a deliberate part of the contract ("requires an explicit numeric maximum"). Every numeric form in that regex, including the two pre-existing OpenAI-style ones, therefore tells us the exact limit N. runMemoryEmbeddingBatchRetryWithSplit never reads it: manager-embedding-policy.ts:124 always halves (splitAt = Math.ceil(items.length / 2)), and onSplit receives message but not N.
Halving is correct, but every non-leaf node of the recursion is a request the provider is guaranteed to reject, and each of those re-sends the full payload of its subtree. I measured this with the real runMemoryEmbeddingBatchRetryWithSplit and a run that rejects any batch above N = 10 with the exact wording this PR recognizes (10 is also the real cap for the provider that emits this message, so it is not a synthetic worst case):
| batch | requests (rejected + ok) | item payloads sent | direct ceil(B/N) chunking |
overhead |
|---|---|---|---|---|
| 33 | 7 (3 + 4) | 99 | 4 requests, 33 payloads | 3.0x payload, 1.8x requests |
| 64 | 15 (7 + 8) | 256 | 7, 64 | 4.0x, 2.1x |
| 160 | 31 (15 + 16) | 800 | 16, 160 | 5.0x, 1.9x |
| 1000 | 255 (127 + 128) | 8000 | 100, 1000 | 8.0x, 2.5x |
The 33-row is exactly the [33, 17, 9, 8, 16, 8, 8] sequence the new test asserts, so the test is already encoding the cost. Batch sizes in this path are byte-bounded, not count-bounded (EMBEDDING_BATCH_MAX_TOKENS = 8000, manager-embedding-ops.ts:75), so the item count per batch is inversely proportional to chunk size; short entries under perEntry chunking reach the upper rows easily, and each rejected request also counts against the provider's rate limit.
This is pre-existing behavior for the two OpenAI-style forms and is not a reason to hold this PR. I am raising it here because this change is the one that turns "the message carries a number" into a requirement, which makes it the natural place to start using that number. A follow-up could parse N from the match and, when present, chunk items into ceil(len / N) groups in one step (each group still going through the retry loop, and still falling back to halving if the provider rejects it again, so a wrong or stale N cannot break correctness). Note that only changing splitAt to N would not be enough: that peels one accepted group off per level and still sends one rejected request per group.
Nit (tests). The retry.test.ts fixture and the policy test both cover the accept/reject wording well. One shape that is not covered and that the regex does accept: the same message with a trailing period (larger than 10.), which is how at least one OpenAI-compatible endpoint formats it. \d+\b matches it, so nothing is wrong, but pinning it would make the classifier's contract explicit if the regex is ever tightened.
Recover explicit numeric embedding row caps through the existing ordered splitter so full memory rebuilds finish and semantic search can use the complete index. Preserve terminal ambiguous and singleton errors and the shared text/structured recovery policy. Verified with a full 33-chunk rebuild and semantic search, native-batch fallback, service and connection-reset controls, independent behavior validation, and the memory-plugin test suite. Additional negative-case coverage: @saladinyao-cyber (#138992). Closes #137864. Co-authored-by: Ayaan Zaidi <[email protected]>
…w#138391) Recover explicit numeric embedding row caps through the existing ordered splitter so full memory rebuilds finish and semantic search can use the complete index. Preserve terminal ambiguous and singleton errors and the shared text/structured recovery policy. Verified with a full 33-chunk rebuild and semantic search, native-batch fallback, service and connection-reset controls, independent behavior validation, and the memory-plugin test suite. Additional negative-case coverage: @saladinyao-cyber (openclaw#138992). Closes openclaw#137864. Co-authored-by: Ayaan Zaidi <[email protected]>
…w#138391) Recover explicit numeric embedding row caps through the existing ordered splitter so full memory rebuilds finish and semantic search can use the complete index. Preserve terminal ambiguous and singleton errors and the shared text/structured recovery policy. Verified with a full 33-chunk rebuild and semantic search, native-batch fallback, service and connection-reset controls, independent behavior validation, and the memory-plugin test suite. Additional negative-case coverage: @saladinyao-cyber (openclaw#138992). Closes openclaw#137864. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 36d4827)
What Problem This Solves
Fixes an issue where users of OpenAI-compatible embedding providers could not index memory when a provider rejected an oversized item batch with an explicit numeric maximum. The request failed permanently instead of being split into smaller batches.
Why This Change Was Made
Recognize the provider-neutral error form
batch size is invalid, it should not be larger than <N>and route it through the existing recursive batch splitter. The classifier requires an explicit numeric maximum and does not depend on a provider name.User Impact
Memory indexing now automatically recovers from this explicit provider batch-size limit instead of failing with HTTP 400. Other input-validation errors remain permanent and are not retried or split.
Evidence
git diff --checkpassed.