openclaw - ✅(Solved) Fix [Bug]: Memory index fails with "embeddings max length per batch size is 2000" — no chunking before embedding [2 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#80226Fetched 2026-05-11 03:17:21
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
2
Author
Timeline (top)
cross-referenced ×3labeled ×2commented ×1referenced ×1

openclaw memory index --force fails with embedding API error. OpenClaw sends entire files to the embedding API without pre-chunking. When combined batch exceeds model's token limit, entire index fails — zero chunks stored.

Error Message

openclaw memory index --force fails with embedding API error. OpenClaw sends entire files to the embedding API without pre-chunking. When combined batch exceeds model's token limit, entire index fails — zero chunks stored. Files should be pre-chunked to <=model's max tokens before embedding. Single-file failures should warn and skip, not crash the entire index. Memory index failed (main): openai embeddings failed: 400 {"error":{"code":"invalid_argument","message":"embeddings max length per batch size is 2000","type":"invalid_request_error"}} Memory index failed (main): openai embeddings failed: 400 {"error":{"code":"invalid_argument","message":"embeddings max length per batch size is 2000","type":"invalid_request_error"}}

Root Cause

openclaw memory index --force fails with embedding API error. OpenClaw sends entire files to the embedding API without pre-chunking. When combined batch exceeds model's token limit, entire index fails — zero chunks stored.

Fix Action

Fixed

PR fix notes

PR #80241: [codex] Fix memory embedding batch limit handling

Description (problem / solution / changelog)

Summary

  • Split inline memory embedding batches again when a provider rejects the combined batch as too large.
  • Skip only irreducible input-size embedding failures per file, while preserving provider-level failures as command failures.
  • Document the OpenAI-compatible low-limit behavior and add regression coverage for issue #80226.

Fixes #80226.

Verification

  • pnpm test packages/memory-host-sdk/src/host/embedding-chunk-limits.test.ts extensions/memory-core/src/memory/manager-embedding-policy.test.ts extensions/memory-core/src/memory/index.test.ts extensions/openai/embedding-provider.test.ts -- --reporter=verbose
  • pnpm test extensions/memory-core/src/memory/manager-sync-ops.archive-delta-bypass.test.ts extensions/memory-core/src/memory/manager-sync-yield.test.ts -- --reporter=verbose
  • pnpm tsgo:extensions
  • pnpm tsgo:test:extensions
  • pnpm tsgo:test:packages
  • git diff --check
  • pnpm docs:list

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • docs/reference/memory-config.md (modified, +2/-0)
  • extensions/memory-core/src/memory/index.test.ts (modified, +72/-0)
  • extensions/memory-core/src/memory/manager-embedding-ops.ts (modified, +75/-13)
  • extensions/memory-core/src/memory/manager-embedding-policy.test.ts (modified, +13/-0)
  • extensions/memory-core/src/memory/manager-embedding-policy.ts (modified, +6/-0)
  • extensions/memory-core/src/memory/manager-sync-ops.archive-delta-bypass.test.ts (modified, +7/-1)
  • extensions/memory-core/src/memory/manager-sync-ops.ts (modified, +30/-2)
  • extensions/memory-core/src/memory/manager-sync-yield.test.ts (modified, +7/-1)
  • extensions/openai/embedding-provider.test.ts (modified, +20/-0)
  • packages/memory-host-sdk/src/engine-embeddings.ts (modified, +1/-0)
  • src/plugin-sdk/memory-core-host-engine-embeddings.ts (modified, +1/-0)

PR #80423: fix(memory): handle per-batch item limits and add retry for 2000-item errors

Description (problem / solution / changelog)

Summary

Qianfan bge-large-zh (and some other providers) enforce a max 2000 items per embedding batch. Previously, when buildMemoryEmbeddingBatches produced a batch exceeding this limit, the entire index failed with:

embeddings max length per batch size is 2000

Two-part fix:

  1. Subdivide token-based batches by item count: Added EMBEDDING_BATCH_MAX_ITEMS = 2000 and subdivide token-based batches into sub-batches of at most 2000 items before calling the provider.
  2. Retry on item-count limit errors: Added max length per batch and batch size is N to isRetryableMemoryEmbeddingError so they are retried with automatic subdivision.

Test plan

  • Verify memory index with Qianfan/bge-large-zh no longer fails with 2000-item batches
  • Verify existing token-based batching still works for providers without item limits
  • Verify error is still retryable and crashes the index when subdivision also fails

Fixes #80226

Changed files

  • extensions/memory-core/src/memory/manager-embedding-ops.ts (modified, +25/-16)
  • extensions/memory-core/src/memory/manager-embedding-policy.ts (modified, +1/-1)
  • src/agents/pi-embedded-runner/run.ts (modified, +2/-1)
  • src/agents/pi-embedded-runner/run/payloads.ts (modified, +11/-0)
  • src/gateway/open-responses.schema.ts (modified, +15/-0)
  • src/gateway/protocol/schema/logs-chat.ts (modified, +2/-0)
  • src/gateway/server-methods/chat-transcript-inject.ts (modified, +3/-1)
  • src/gateway/server-methods/chat.ts (modified, +4/-0)

Code Example

Memory index failed (main): openai embeddings failed: 400 {"error":{"code":"invalid_argument","message":"embeddings max length per batch size is 2000","type":"invalid_request_error"}}
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

openclaw memory index --force fails with embedding API error. OpenClaw sends entire files to the embedding API without pre-chunking. When combined batch exceeds model's token limit, entire index fails — zero chunks stored.

Steps to reproduce

  1. Configure agents.defaults.memorySearch with Qianfan bge-large-zh
  2. Have any memory files totaling >2,000 tokens in combined batch
  3. Run openclaw memory index --force
  4. Result: entire index fails, 0 chunks indexed

Expected behavior

Files should be pre-chunked to <=model's max tokens before embedding. Single-file failures should warn and skip, not crash the entire index.

Actual behavior

Memory index failed (main): openai embeddings failed: 400 {"error":{"code":"invalid_argument","message":"embeddings max length per batch size is 2000","type":"invalid_request_error"}}

OpenClaw version

2026.5.6

Operating system

centos8

Install method

npm

Model

Baidu Qianfan (OpenAI-compatible endpoint) /bge-large-zh

Provider / routing chain

openclaw Baidu Qianfan /bge-large-zh

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Memory index failed (main): openai embeddings failed: 400 {"error":{"code":"invalid_argument","message":"embeddings max length per batch size is 2000","type":"invalid_request_error"}}

Impact and severity

No response

Additional information

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Files should be pre-chunked to <=model's max tokens before embedding. Single-file failures should warn and skip, not crash the entire index.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: Memory index fails with "embeddings max length per batch size is 2000" — no chunking before embedding [2 pull requests, 1 comments, 2 participants]