Repository navigation
perf(memory): honor explicit embedding batch item limits - #140508
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 uses an embedding endpoint’s explicitly reported item cap to size recovery requests, retaining binary splitting when the cap is unusable. Example: Memory indexing submits 33 chunks to an endpoint that rejects batches above 10 inputs.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still uses binary recovery, and this focused optimization preserves ordering and caching without introducing an actionable defect. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherMemory Core batches uncached chunks, calls the configured embedding provider, and returns ordered vectors while caching each successful recovery slice. flowchart TD
A[Memory indexing] --> B[Uncached chunks]
B --> C[Memory Core retry owner]
C --> D[Embedding endpoint]
D --> E[Reported item cap]
E --> C
C --> F[Ordered vectors and cache]
Technical reviewBest possible solution: Use validated explicit caps within the existing recovery owner while retaining binary fallback, ordered results, and existing cache persistence. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically halves rejected batches despite a reported cap, and supplied baseline CLI runs record the resulting redundant requests; no target code was executed during this read-only review. Is this the best way to solve the issue? The change fits the existing retry owner, reduces rejected requests, and avoids a new persistent limit cache, universal default, or public provider contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bc8f693df3ae. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +20, Tests +83, Docs +4. Total +107 across 6 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 HistoryReview history (15 earlier review cycles; latest 8 shown)
Reviewed October 9, 2026, 11:23 PM ET / October 10, 2026, 03:23 UTC (Revision 16). |
cf5ebef to
d6f0ed5
Compare
|
Addressed the review at @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Updated the PR context to use the required @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Yigtwxx
left a comment
There was a problem hiding this comment.
Reviewed head d6f0ed5fa10 against main d3101b5229b. This is the follow-through on the splitter note from #138992: the classifier already required the number and the splitter ignored it. The change is small and lands where it should, in runMemoryEmbeddingBatchRetryWithSplit, with the binary path kept as the fallback for absent, ambiguous, non-positive or stale limits. Three things measured, then the two CI reds, which the ClawSweeper verdict does not mention.
Measured. (1) The three touched test files pass on this head under the memory shard, 40/40. Mutation: making parseMemoryEmbeddingBatchItemLimit return undefined turns exactly 10 tests red, the three new policy cases, the six retry-boundary expectations (text and structured) and the loopback integration case, with the other 30 still green, so the new coverage is carried by the limit path and not by the surrounding harness. (2) Request counts with the real policy functions over five consecutive 40-item batches against a 10-item cap, for all three message shapes the regex accepts: main 35 requests / 15 rejected, this head 25 / 5. None of the three messages matches isRetryableMemoryEmbeddingError, so there is no backoff before the split. (3) The stale-limit row is real: a provider that reports 3 but accepts 2 goes 4, 3, 2, 1, 1, one wasted request rather than a loop.
CI. check-dependencies is a genuine red from this branch: knip --production reports Unused exports (1): extensions/memory-core/src/memory/manager-embedding-policy.ts: parseMemoryEmbeddingBatchItemLimit. The export exists only for manager-embedding-policy.test.ts; the repository's dead-export ratchet counts test-only exports, so it needs to become module-private, with the parse table folded into cases that drive runMemoryEmbeddingBatchRetryWithSplit (the "uses an explicit item limit" and "falls back" cases already cover every row of the parse test except the two-number-ambiguity string, which fits in the fallback table). The PR context and evidence red is stale rather than yours: it ran at 23:53Z, and the current body passes evaluatePullRequestContext from scripts/github/real-behavior-proof-policy.mjs locally (status: passed), so it clears on the next push. The bot's "add data-model compatibility proof" checkbox has nothing to attach to: the diff touches the policy, the ops log line and tests, no store or schema file.
One note for the description, not a blocker. The limit is not retained between calls, and buildMemoryEmbeddingBatches sizes batches by an 8000-byte budget with no item cap, so on a provider with a 10-item cap every batch above ten items still pays one rejected request; the five-batch run above is 5 rejections where a limit remembered for the life of the provider instance would be 1. That is a separate change with its own cache-invalidation questions and I would not fold it into this PR, but the body's "rejected requests: 1" describes one batch, and saying so keeps the claim exact for an index run of many batches.
d6f0ed5 to
2175311
Compare
Yigtwxx
left a comment
There was a problem hiding this comment.
Re-measured head 425603d7f23 after the force-push, against the same memory shard as before.
parseMemoryEmbeddingBatchItemLimitis module-private now and the direct-parse cases were folded into the tworunMemoryEmbeddingBatchRetryWithSplitcells (explicit limit with order preserved; unusable, ambiguous, oversized and stale limits falling back to binary).check-dependenciesis green on this head, so the knip--productionred fromd6f0ed5fa10is gone. All 49 checks pass, nothing red.- The three touched test files pass locally, 39/39.
- Mutation: making the parser return
undefinedturns exactly 9 tests red (the two new policy cells, the six retry-boundary expectations for text and structured errors, and the loopback integration case) with the other 30 still green. Coverage of the limit path survived the fold.
Nothing further from my side.
425603d to
961c254
Compare
|
Rebased onto current The rebase preserves upstream's new retry-profile/cooldown flow and adds only the item-limit-aware partitioning behavior; it does not restore the removed retry APIs. The parser remains module-private and is exercised through Post-rebase verification:
There is still no schema, persisted record, vector metadata, configuration, or migration change; the old data-model checkbox is not applicable to this in-memory retry policy. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
Yigtwxx
left a comment
There was a problem hiding this comment.
Re-measured head 6cdb8ba162e (parent 7c51ba75120) because the surface moved since my last note on db0788348ed, not just the base. Two things changed that the body does not mention, and one of them removes a regression cell that main relies on.
1. The item-cap parser gained a fourth phrasing, and it changes the observable Zhipu sequence.
db0788348ed parsed three phrasings. 6cdb8ba162e adds input array max\s+(\d+) (with the same lookahead the splittable classifier already uses). That is the Zhipu BigModel 1214 body from #139040, so a real Zhipu rejection now takes the item-limit branch instead of binary halving. I checked out this head and ran main's unchanged generic-embedding-provider.integration.test.ts (the 1214 / input array max 64 cell over the real transport, 100 inputs):
FAIL halves an oversized batch until the provider input array limit is met
AssertionError: expected [ 100, 64, 36 ] to deeply equal [ 100, 50, 50 ]
100, 64, 36 is the better sequence (one rejected request instead of two), so this is an improvement, but it is a behavior change for the provider that motivated the fallback, and the body's "Parse only item-cap phrasings already admitted by the current splittable-error classifier" reads as if nothing observable moves for existing providers. Worth one sentence in the body.
2. The #139040 regression cell was rewritten rather than updated.
Instead of changing that cell's expectation to [100, 64, 36], the PR replaces it: the constant is now a DashScope-style InvalidParameter / batch size is invalid, it should not be larger than 10 body (still named ZHIPU_REJECTION_BODY), the limit drops to 10, and the input count to 33. After this PR:
- the real Zhipu
1214body has no transport-level cell at all, so the new fourth alternative and its lookahead are only exercised by the classifier's terminal-rejection cells (input array max 64 tokens,64tokens,64.5, which correctly do not split) and never by a successful parse; - binary halving has no transport-level cell either; the only remaining coverage is the unit-level
binary:4:2:2expectation inmanager-embedding-policy.test.ts.
The PR's own cells are green on this head (55/55 across the two memory-core files, Node 24.21.0), so this is about what got dropped, not what was added.
Suggestion, small: keep the DashScope cell, restore the Zhipu cell with [100, 64, 36] (it passes on this head; that is exactly what I observed), and rename the constant. If you want a halving cell over the real transport as well, a splittable message with no parseable number (request header fields too large is already in the classifier) would keep 100, 50, 50 alive without touching the parser.
None of this changes my read of the implementation: ordering, onSuccess pairing, and the stale-cap fallback still hold. It is a coverage and body-accuracy ask, not a correctness one.
|
Addressed the latest transport-coverage review in
Evidence: the three related Memory Core test files pass 88/88; extension production/test typechecks pass; changed-file Oxlint reports 0 warnings/errors; changed-file Oxfmt and @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Yigtwxx
left a comment
There was a problem hiding this comment.
Re-measured 13e53ceac35 against the three asks, with my own runs rather than the PR's numbers (Node 24.21.0):
- The three memory-core files pass 88/88 here as well.
- Mutation on this head: removing only the
input array max\s+(\d+)alternative fromMEMORY_EMBEDDING_BATCH_ITEM_LIMIT_REturns exactly one cell red, the restored Zhipu one (expected [ 100, 50, 50 ] to deeply equal [ 100, 64, 36 ]); the DashScope cell and the newrequest header fields too largehalving cell stay green. So the fourth phrasing is now proven through the real transport by its own cell, and the binary fallback has a transport-level cell again. - The body now states the Zhipu sequence change (
100, 50, 50→100, 64, 36) explicitly, and the constants are named for what they carry.
Nothing outstanding from me.
|
Maintainer follow-up for unchanged head 13e53ce: could you confirm whether the remaining data-model compatibility checkbox applies to this patch? I rechecked the complete five-file PR diff. The only production changes are (1) a module-private error-message item-cap parser and sequential recursive slices in manager-embedding-policy.ts, including split diagnostic metadata, and (2) the corresponding log wording in manager-embedding-ops.ts. The other three files are tests. There are no schema/DDL, migration, serialized-record, cache-key, provider-identity, embedding-dimension, or configuration-format changes in this diff. The parsed cap is local to recovery, not persisted or remembered across calls; the existing onSuccess callback is passed to each child slice. The observable change is request grouping, not a stored-data format migration. On partial failure, different slice boundaries can change how much successful work has already been cached; this was measured in the earlier contributor review and is not a claim of identical partial-progress behavior. The current tests cover input/output pairing, per-slice callbacks, DashScope and Zhipu transport recovery, and binary fallback. Yigtwxx independently reported 88/88 tests and no outstanding asks on this exact head on September 15; I have not rerun those tests today. The latest durable bot review itself says no persistent state is added and no blocking correctness finding remains. Based on the diff, I believe a schema migration is not required. If a specific existing-install compatibility scenario is still required, please identify it so I can provide targeted evidence rather than expand this PR. Current hosted checks are green (52 successful, 47 skipped), and GitHub reports a clean merge. The September 26 fresh-review workflow ended in failure without replacing the durable verdict, so its remaining review-started notice should not be read as a completed review. No code changes or automated repair/review commands are included in this follow-up. |
|
Following up specifically on the new September 30 Revision 14 review, for unchanged head The review now explicitly states that "The earlier migration blocker does not apply" and "No stored-data contract changes, so migration compatibility proof is not applicable." However, its Before merge checklist and Stored data model section still request migration/upgrade proof. These sections appear inconsistent with the reviewed disposition. Could a maintainer confirm whether the remaining compatibility item can be marked not applicable and proceed with the normal merge review? If it is still applicable, please identify the specific persisted contract or upgrade scenario that needs evidence so I can address it narrowly. The independent exact-head 88/88 review reports no outstanding requests. No new code, rebase, or test rerun is claimed here, and this is not a request to bypass checks or approval. Thank you. |
|
@steipete — could you clarify the remaining compatibility item on this PR before I refresh the branch? The September 30 ClawSweeper Revision 14 says the earlier migration blocker does not apply and that there is no stored-data contract change, but its Before merge checklist still asks for data-model migration/upgrade proof. The exact head remains 13e53ce, with green hosted checks; GitHub also reported a merge conflict against current main in today's check (mergeability briefly returned unknown on a subsequent API read). If migration proof is not applicable, could you confirm that this checklist item can be treated as such and proceed with normal review? If it is applicable, please name the specific persisted contract or existing-install scenario to demonstrate. Once that is clear, I can resolve the conflict against current main, rerun the affected checks, and update the evidence. I am not requesting an approval bypass. Thank you. |
|
@steipete — brief follow-up on unchanged head 13e53ce: can the remaining migration/upgrade-proof checklist item be treated as not applicable, as the September 30 review states there is no stored-data contract change? If you still need compatibility proof, please name the specific existing-install scenario. Once the requirement is clear, I can resolve the current-main conflict and provide fresh checks on the refreshed head. Thank you. |
Merge current main without rewriting contributor history. Share the binary and explicit-cap retry loop, preserve diagnostic error classification, and cover transport ordering and unusable caps.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…0508) * perf(memory): honor explicit embedding batch item limits * test(memory): restore embedding transport coverage --------- Co-authored-by: saladinyao-cyber <[email protected]>
What Problem This Solves
Memory indexing retries avoidably oversized embedding requests after an endpoint explicitly reports its maximum number of inputs. For 33 chunks and a reported cap of 10, current main sends
33, 17, 9, 8, 16, 8, 8, rejecting three requests.User Impact
Recovery sends
33, 10, 10, 10, 3, with only the initial rejection. Returned vectors remain paired with their original chunks and cache entries. Unusable or conflicting caps retain binary recovery. No configuration, schema, cache identity, vector format, dependency, or public SDK changes are required.Why This Change Was Made
The existing Memory Core retry owner now selects a valid reported cap and uses the same sequential slicing loop for cap-aware and binary recovery. It preserves current main's invalid-response diagnostics guard from #168035 and recognizes the English and Chinese Zhipu cap messages already admitted by the classifier. This is reactive recovery after a real rejection; proactive provider metadata remains separate work in #141686.
The contributor's commits and credit to @saladinyao-cyber are preserved. Current main was merged into the branch without rebasing or force-pushing. The implementation was reduced from 52 net production lines to 20; those remaining lines parse and validate a reported cap in the existing retry owner. Against the merged main: production +31/-11, tests +102/-19, docs +4/-0.
Evidence
pnpm build: passed (2671.17 seconds). Formatting, scoped diff checks, and all eight CI ratchets passed: max-lines, line-cap, assertion safety, database workers, timeout races, mock exports, config docs, and plugin inventory.Baseline:
afb4f0ff366b2003977662d1b73e58dfb5b9c897, including #168035. Candidate:a4cd293caf2a5d16c34e39af6d663a19cf1d1d02.Real local-model proof uses the supported
pnpm openclaw --profile memory-misc memory index --force --verbose,memory status --json, andmemory search ... --jsonentry points with isolated state. A loopback proxy rejects requests above ten inputs and forwards accepted requests to Ollama. The cap is a controlled endpoint contract; native Ollama does not claim this ten-item restriction. The fixture is 33 distinct curated MEMORY.md entries with normal chunking settings.Both
nomic-embed-text(768 dimensions) andbge-m3(1024 dimensions) reproduce the baseline sequence and the repaired33, 10, 10, 10, 3sequence. Each goes from seven requests/three rejections to five requests/one rejection. Read-only verification matches all 33 persisted index/cache vectors byte-for-byte to their corresponding real model responses. The full top-six rankings and vector scores remain identical, and repeated forced indexing adds zero document embedding requests.Compatibility was exercised by opening the main-created nomic index with the candidate CLI, forcing a reindex, and searching it. All 33 cached vectors were reused without new document requests and the ranking stayed unchanged. There is no stored-data migration in this change.
Cold CLI startup varied sharply during the shared-host campaign. The measured improvement is fewer requests with identical behavior; these runs do not establish a wall-clock speedup.