Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[BUG] Memory prefetch drops short sentences from the search, so relevant memories are never retrieved

オープン 初心者向け
#3,428 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
ai

調査の方向性

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
  1. Enable agent memory and prefetch.
  2. 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.)
  3. 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

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

kagent-dev/kagent のほかの issue

kagent-dev/kagent の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。