Skip to content

fix: prevent hang with long messages by truncating queries and adding…#248

Closed
smasunspot wants to merge 1 commit intoCortexReach:masterfrom
smasunspot:fix/long-message-timeout
Closed

fix: prevent hang with long messages by truncating queries and adding…#248
smasunspot wants to merge 1 commit intoCortexReach:masterfrom
smasunspot:fix/long-message-timeout

Conversation

@smasunspot
Copy link
Copy Markdown

… max length skip

  • Add truncateQueryForEmbedding() to limit embedding queries to 512 chars
  • Add isQueryTooLongForRecall() to skip auto-recall for very long prompts
  • Add new config autoRecallMaxQueryChars (default: 4000) to control max prompt length
  • Update retriever.ts to use query truncation before embedding

Fixes #244

… max length skip

- Add truncateQueryForEmbedding() to limit embedding queries to 512 chars
- Add isQueryTooLongForRecall() to skip auto-recall for very long prompts
- Add new config autoRecallMaxQueryChars (default: 4000) to control max prompt length
- Update retriever.ts to use query truncation before embedding

Fixes #244
@rwmjhb
Copy link
Copy Markdown
Collaborator

rwmjhb commented Mar 18, 2026

感谢提交!这个问题是真实的,不过 #238 已经合并并覆盖了这个场景:

  • index.ts 中 auto-recall 查询已截断到 1000 字符
  • embedder 层增加了 10s AbortController 超时
  • CJK-aware chunking + 递归深度限制防止无限循环

另外这个 PR 有两个副作用需要注意:

  1. truncateQueryForEmbedding(512) 加在了 retriever.tsvectorOnlyRetrievalhybridRetrieval 中,影响所有检索路径(包括手动 memory_recall),不只是 auto-recall
  2. isQueryTooLongForRecall 超过 4000 字符直接跳过 recall,比截断后继续检索更激进,用户会完全得不到记忆注入

由于 #238 已覆盖此场景,关闭此 PR。

@rwmjhb rwmjhb closed this Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Long messages cause hang with MiniMax M2.5

2 participants