[Bug] SQLite 后端丢了 sendDimensions,腾讯 TokenHub 的 embedding 模型直接不可用

Open
#2,011 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
20/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript
Domain
backend, databases

Research direction

Read MemoryCore/src/core/store/store-pool.ts and compare createSqliteStore() with the configuration passed by factory.ts. The issue identifies the missing sendDimensions setting and says a test was added; inspect the linked PR for its test location and run that test. Done means SQLite embedding requests honor sendDimensions: false and the regression test passes.

Written by the indexing model from the issue text.

Description

先说结论

store-pool.ts 构造 embedding 服务时漏传了 sendDimensions,导致 SQLite 后端下这个
开关永远是 true,dimensions 参数被无条件塞进每次请求。

后果不是「效果差一点」,而是:只要 embedding 模型不接受这个参数,一条向量都写不进去。
腾讯 TokenHub 的 kinfra-text-embedding-4b 就是这种情况,全程 400。

更难受的是它不报错。embedding 失败被当成 non-fatal,服务照常跑,
/health 一直显示 embeddingService: true,实际检索早就退化成纯关键词匹配了。

怎么发现的

我们按官方方式部署(start-memory-core.sh + .env),.env 里明确写了:

MEMORY_EMBEDDING_SEND_DIMENSIONS=false

生成的 tdai-gateway.yaml 也确实带上了 sendDimensions: false,容器内外都核对过。
但 embedding 全部 400。

单独打接口,只差这一个参数:

请求 结果
{"model":"kinfra-text-embedding-4b","input":["测试"]} 200,2560 维
加上 "dimensions":2560 400

返回(apiKey 脱敏,request_id 保留):

{"error":{"type":"invalid_request_error","code":"400001",
"message":"The request is invalid: dimensions is not supported by this model.",
"source":"client","request_id":"3a6610b7-…"}}

原因

MemoryCore/src/core/store/store-pool.ts 的 createSqliteStore():

const embCfg = this.memoryCfg.embedding;   // 完整配置,sendDimensions 就在里面
embeddingService = createEmbeddingService({
  provider: embCfg.provider,
  baseUrl: embCfg.baseUrl,
  apiKey: embCfg.apiKey,
  model: embCfg.model,
  dimensions: embCfg.dimensions,
  maxInputChars: embCfg.maxInputChars,     // 就差上面一行
}, this.logger as StoreLogger);

factory.ts 是传了的,而且两个地方构造的是同一个类、打同一个地址,所以这应该只是漏写,
不是两条路径有意区分。

影响范围

凡是「拒绝 dimensions 参数」的服务都会中:BGE-M3(config.ts 注释里就点名了)、
Qwen-embedd、腾讯 TokenHub kinfra-text-embedding-4b,以及自建 vLLM / Xinference /
Ollama 一类严格校验参数的网关。

我们这边跑了几个星期,库里是:

l0_conversations  6,236 行
l0_vec_rowids         0 行
embedding_meta      空

一条向量都没有,而服务全程「健康」。

以前有人报过

#1343 是 2026-09-11 提的,多人独立确认,跨多个版本;#1344 同一天提了修复。
这次是我们在 v2.0.4 上又踩到,顺手补了测试和 PR。

修法

一行,没有副作用(tcvdb / mongodb 不经过这里):

   dimensions: embCfg.dimensions,
+  sendDimensions: embCfg.sendDimensions,
   maxInputChars: embCfg.maxInputChars,

顺带一提

修好之后 /health 会重新变绿,但历史数据仍然是零向量。「修好未来、补不回过去」这个
中间态目前没有指标能看出来,也还没有 backfill 入口,这两块可能值得单独跟。


修复 PR:https://github.com/TencentCloud/TencentDB-Agent-Memory/pull/2010

Dominant language
TypeScript
Stars
31.1k
Forks
3.1k
Avg merge
12h 44m
Merged PRs (30d)
14

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TencentCloud/TencentDB-Agent-Memory

All issues in TencentCloud/TencentDB-Agent-Memory

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.