Repository navigation
fix: 记忆检索链路太慢 - #588
Merged
origami-chen merged 2 commits intoOct 9, 2026
Merged
fix: 记忆检索链路太慢#588
Conversation
Account-mode memory models resolved to vendor openai_compatible with gateway aliases such as memory_summary, so no thinking field was sent and retrieval calls requested with thinking disabled still ran with the Bailian default. Send both enable_thinking and thinking.type for memmy_account, keep JSON mode when disabled, and restore the account evolution thinking budget. Co-authored-by: Cursor <cursoragent@cursor.com>
Account-mode memory summary can be assigned a custom provider preset that targets the account gateway, so the source provider is not memmy_account. Match the gateway endpoint path as well so those requests also send the Bailian thinking switches. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题定位
记忆检索变慢,是因为账号模式下检索调用摘要模型时,请求里没有带关闭思考的字段,模型按默认开着思考跑。
检索链路里的查询抽取和 LLM 过滤都传了
thinkingMode: "disabled",但这个选项在组装请求体时被丢掉了。账号模式有两种配置,两种都对不上现有的判断规则:sourceProvider是memmy_account,vendor 映射表里没有这一项,落到了openai_compatible。openai,地址却指向账号网关api.memmy.cn/api/agentExternal/v1,模型名是网关别名memory_summary。两种情况下,vendor、模型名和网关地址都匹配不上已知的思考字段写法,请求体里什么都不带。网关把请求原样转给百炼,百炼按模型默认开着思考,而且网关不做字段转换。这是 2026-08-11 模型目录重构留下的回归,重构前账号模式写死 vendor 为
qwen,请求会带enable_thinking。同一条过滤请求的对比:旧版不带字段时返回约 270 个思考 token,耗时 15 到 60 秒;带上关闭字段后思考 token 为 0,输出只有 12 个 token。
修改内容
只改了
Memory/src/model/llm.ts和Memory/tests/llm-thinking.test.ts。memmy_account,或请求地址包含/api/agentExternal/时,同时发送百炼的两套开关:enable_thinking和thinking.type。Qwen、DeepSeek、GLM、Kimi 认前者,MiniMax 认后者,网关别名背后是哪个模型客户端无从得知。response_format;开启思考时去掉 JSON mode,并重新带上thinking_budget: 1000,账号进化模型原来设的预算因此生效。测试结果
npm run memory:test:1076 个通过,1 个跳过。npm run lint和npm run typecheck通过。新增用例在原代码上会失败。memory_search全部成功,没有超时或兜底,平均 4.3 秒,最慢 6.4 秒。查询抽取 2.2 到 3.5 秒,LLM 过滤 1.6 到 3.9 秒。修复前近 7 天 41 次平均 63 秒,最慢 117 秒。