[BUG] Memory prefetch drops short sentences from the search, so relevant memories are never retrieved
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
python/packages/kagent-adk/src/kagent/adk/tools/prefetch_memory_tool.pyから始め、特に_split_sentencesと呼び出し元のフォールバックを確認してください。返されたクエリがメモリ検索にどう使われるかを追い、その後、文の分割とprefetchの動作に関する既存のテストを確認してください。再現例の短い文が検索に反映されれば完了です。このツールに関連するテストを実行してください。
索引モデルが issue の本文から書いたものです。
説明
📋 Prerequisites
- I have searched the existing issues to avoid creating a duplicate
- By submitting this issue, you agree to follow our Code of Conduct
- I am using the latest version of the software
- I have tried to clear cache/cookies or used incognito mode (if ui-related)
- I can consistently reproduce this issue
🎯 Affected Service(s)
App Service
🚦 Impact/Severity
Minor inconvenience
🐛 Bug Description
PrefetchMemoryTool in python/packages/kagent-adk/src/kagent/adk/tools/prefetch_memory_tool.py loads relevant past context at the start of a conversation by splitting the first user message into sentences and searching memory for each one. _split_sentences drops any sentence shorter than _MIN_SENTENCE_CHARS (30):
def _split_sentences(text: str) -> list[str]:
sentences = re.split(r"(?<=[.!?])\s+", text.strip())
return [s.strip() for s in sentences if len(s.strip()) >= _MIN_SENTENCE_CHARS]
The docstring says it "falls back to the full text as a single query ... if the message is short enough to search as-is", but that fallback lives in the caller and only fires when the returned list is completely empty:
queries = _split_sentences(first_text.strip())
if not queries:
queries = [first_text.strip()]
So when a multi-sentence message mixes long and short sentences, the short ones are silently dropped and never searched, and because the list is non-empty the full-text fallback does not run either. A memory relevant only to the short sentence is therefore never retrieved.
🔄 Steps To Reproduce
- Enable agent memory and prefetch.
- Start a conversation whose first message mixes a long sentence with a short one, e.g. "Remember: prod is down. Fix it now please immediately." ("Remember: prod is down." is 23 characters, under the 30-char threshold.)
- Only the long sentence is searched against memory; the short one is dropped.
Minimal reproduction of the splitting function in isolation:
from kagent.adk.tools.prefetch_memory_tool import _split_sentences
print(_split_sentences("Remember: prod is down. Fix it now please immediately."))
# -> ['Fix it now please immediately.']
# "Remember: prod is down." is never searched, and because the list is non-empty
# the caller's full-text fallback does not run, so that context is lost.
🤔 Expected Behavior
The short sentence should still contribute to the memory search. Reasonable options:
- Keep every sentence as a query (a 23-character sentence like "Remember: prod is down." is meaningful), or
- When some sentences are filtered out, also include the full message as an additional query, so no part of the message is lost, or
- Only apply the length filter when it still leaves the message fully covered.
📱 Actual Behavior
For "Remember: prod is down. Fix it now please immediately.", only "Fix it now please immediately." is searched against memory. "Remember: prod is down." is silently dropped, and the whole-message fallback does not fire because the query list is non-empty. Any memory relevant only to "prod is down" is never retrieved, with no error or log.
💻 Environment
- Application version: latest
main - Affected component: Python ADK runtime (
kagent-adk), memory prefetch - File:
python/packages/kagent-adk/src/kagent/adk/tools/prefetch_memory_tool.py(_split_sentences) - OS: not OS-specific (pure Python logic)
🔧 CLI Bug Report
No response
🔍 Additional Context
This is provider-independent (it runs before any model or embedding call) and affects any agent with memory enabled. The current _MIN_SENTENCE_CHARS = 30 threshold has no fallback for the partial-drop case, only for the all-dropped case.
- Did it work before? This is the behavior since the prefetch tool's sentence-splitting was introduced; not a recent regression.
- Workarounds: none from config; it needs a code change.
I would like to work on this.
📋 Logs
No response
📷 Screenshots
No response
🙋 Are you willing to contribute?
- I am willing to submit a PR to fix this issue
- 主要言語
- Go
- スター
- 4.1k
- フォーク
- 859
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 169
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
kagent-dev/kagent のほかの issue
-
[BUG]対応中かも @helloxjade が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
kagent-dev/kagent#3385 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] Go Ollama adapter does not send tool_name on tool result messages対応中かも @mandipadk が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
kagent-dev/kagent#3371 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
kagent-dev/kagent#3247 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] Ollama ModelConfig options: integer coercion crashes on decimal strings, and boolean options only accept exact "true"対応中かも @piyush182004 が 10 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
kagent-dev/kagent#3245 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
ui: useAgentInstances(true) turns an all_creators refusal into a page error再び着手できるかも @suryakant-source が 10 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
kagent-dev/kagent#3212 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
kagent-dev/kagent の issue をすべて見る
似ている issue
-
Type: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
projectdiscovery/notify#569 ·
-
internal
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
Results from sources can contain invalid host names対応中かも @Mzack9999 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
projectdiscovery/subfinder#1983 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
bug triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
radius-project/radius#13566 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信