Repository navigation
fix(google): cap Gemini embedding request batches - #134173
linhongyu510 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 real behavior proof before merge. What this changesThe PR splits Gemini document embeddings into sequential requests containing at most 100 inputs. Example: Memory indexing submits 250 short document chunks to Gemini.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 3 items remain This PR addresses a confirmed Gemini indexing failure that remains on current main, but should use Memory Core’s existing request-cap contract instead of adding another batching owner. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherMemory Core groups uncached chunks and invokes the Google embedding provider, which sends authenticated HTTP requests and returns validated vectors for indexing. flowchart LR
A[Memory chunks] --> B[Memory Core request splitter]
B --> C[Google embedding provider]
C --> D[Shared HTTP transport]
D --> E[Gemini API]
E --> F[Validated vectors]
F --> G[Memory index]
Technical reviewBest possible solution: Declare Gemini’s 100-input cap on the existing provider contract and let Memory Core own splitting, retries, timeouts, and successful-slice persistence. Do we have a high-confidence way to reproduce the issue? Affected-release reports and current source establish oversized requests and terminal handling of Google’s rejection; this read-only review executed no target code. Is this the best way to solve the issue? The API limit belongs in Google’s provider metadata, while the already approved shared splitter supplies the requested behavior with less production code and consistent slice lifecycle handling. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 18892937f802. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +11, Tests +147. Total +158 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 (9 earlier review cycles; latest 8 shown)
Reviewed November 14, 2026, 6:57 AM ET / 11:57 UTC (Revision 10). |
84fd879 to
0f03c3e
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
0f03c3e to
efa22e3
Compare
|
Not stale, and the @clawsweeper's objection was correct and worth taking literally: the existing cases stub So the proof is now a With the cap removed, the server rejects exactly as Gemini would: With the cap in place, over the same server: batches observed One thing I want to be straight about rather than overclaim: this is a faithful local reproduction of the documented API contract, not a capture against live Gemini — I do not have a key I can attach output from here. If the gate specifically requires a transcript from the real endpoint, that needs someone with credentials, and I am happy to hand over the exact script. But the failure mode this PR fixes is now demonstrated end to end over real HTTP instead of asserted against a mock. Both commits cherry-picked onto current |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
Gemini batchEmbedContents accepts at most 100 requests per call (https://ai.google.dev/api/embedding#method:-models.batchembedcontents). Slice document inputs into <=100-request sub-batches, concatenate the ordered embeddings, and stop on the first sub-batch failure. Rebased onto current main.
45ee899 to
8f72445
Compare
Closes #134015
What Problem This Solves
Fixes an issue where Gemini-backed memory indexing aborted when a token-bounded group contained more than 100 short chunks. The provider sent the full group to
batchEmbedContents, exceeding Gemini's per-request limit instead of completing the sync.Why This Change Was Made
The Gemini provider now owns its API-specific limit and sends document embeddings in sequential batches of at most 100 requests. It preserves input/output order and reuses the existing authentication, SSRF, abort, response-validation, and vector-sanitization path for every sub-batch. Generic memory batching and other providers are unchanged.
User Impact
Memory sync and
openclaw memory indexcan process large sets of short chunks with the default inline Gemini embedding path instead of failing at 101 requests. If a later sub-batch fails, the original provider error is still surfaced and no further batches are sent.Evidence
expected [101] to deeply equal [100, 1]while the other 40 provider tests passed.[100],[100, 1], and[100, 100, 1], with exact output ordering.pnpm build: passed on the rebased head.oxfmt --check: passed.oxlint: 0 warnings / 0 errors.git diff --check: passed.Review Follow-up
batchEmbedContentsAPI contract and linking the Google API documentation.oxfmt --checkalso passed.Risk
Low and provider-scoped. Calls with at most 100 inputs retain the existing single-request behavior. Larger calls become sequential requests, avoiding extra concurrency and preserving rate-limit and cancellation semantics.
AI Assistance Disclosure
TRAE assisted with issue and source inspection, implementation planning, test drafting, the provider-scoped code change, and local verification. The contributor selected and approved the provider-boundary design, reviewed the resulting scope, and retains responsibility for the contribution. No credentials or private production data were provided to the assistant.