Skip to content

[Bug] L0 embedding silently fails — MAX_BATCH_SIZE=256 exceeds Tencent API limit of 10 #236

Description

@yrwd999

OpenClaw Version | OpenClaw 版本

2026.6.8

Plugin Version | 插件版本

0.3.6

Operating System | 操作系统

Linux

System Specification | 系统配置

No response

Describe the bug | 问题描述

L0 capture path 的背景 embedding 任务持续失败,但仅记录为 non-fatal WARN,导致向量 embedding 数据永久丢失,混合搜索降级为纯关键词搜索。

根因src/core/store/embedding.ts 第 374–375 行硬编码 MAX_BATCH_SIZE = 256,而dashscope embedding API 严格限制每批最多 10 条文本。当 L0 捕获的文本数在 11–256 之间时,embedBatch() 内部的 chunking 条件 processedTexts.length > MAX_BATCH_SIZE 不触发,批次直接以 >10 条发送至 API,返回 HTTP 400。

To Reproduce | 复现步骤

  1. 安装 memory-tencentdb 插件,配置 Dashscope embedding
  2. 正常使用 Agent 一段时间
  3. 观察日志:[memory-tdai] [capture] [L0-vec-index-bg] Background embedding failed (non-fatal)
  4. 查询数据库差值持续扩大

Expected behavior | 预期行为

  • 方案 A:MAX_BATCH_SIZE 应 ≤ 10,确保始终触发 chunking
  • 方案 B:batch size > 10 时应拆分为多个 ≤10 的子批次
  • 方案 C:API 返回 400 后应重试(指数退避)而非直接丢弃

Error Logs / Screenshots | 报错日志/截图

[memory-tdai] [capture] [L0-vec-index-bg] Background embedding failed (614ms, non-fatal): Embedding API error: HTTP 400 Bad Request —
{
"error": {
"message": "<400> InternalError.Algo.InvalidParameter: Value error, batch size is invalid, it should not be larger than 10.: input.contents",
"type": "InvalidParameter",
"code": "InvalidParameter"
}
}

Additional context | 补充信息

影响范围

  • L0 向量索引写入 0% 成功率(持续至今,约 2026-05-26 起)
  • L1/L2/L3 管线未受影响
  • recall 降级:hybrid 搜索退化为 keyword-only,语义相似度匹配完全失效

代码位置src/core/store/embedding.ts:374-483

  • 第 374 行:const MAX_BATCH_SIZE = 256;
  • 第 480–483 行:仅在 processedTexts.length > MAX_BATCH_SIZE 时才进行 chunking
  • 当文本数 11 ≤ n ≤ 256:chunking 逻辑不触发

建议修复

  1. 高优:将 MAX_BATCH_SIZE 改为 10
  2. 次优:在 auto-capture.ts 中先手动 chunk 为 ≤10 的子批次

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions