fix: skip memory prefetch on trivial user prompts (greetings)
When the user sends a greeting (hi/hey/hello) or trivial acknowledgement, skip memory-provider prefetch_all() to prevent context-dumping on sessions where the user is simply opening a conversation. This fixes the case where memory context containing instruction-like directives overrode the agent's configured persona on short first-turn messages. Additionally, add greeting words (hi/hey/hello/yo/sup) to the Honcho plugin's _TRIVIAL_PROMPT_RE so the plugin-level injection gate also skips greetings. Files changed: - run_agent.py: add trivial-query gate before prefetch_all() call - plugins/memory/honcho/__init__.py: add greetings to _TRIVIAL_PROMPT_RE
This commit is contained in:
parent
dd5a9502e3
commit
88ffede2d8
|
|
@ -988,11 +988,12 @@ class HonchoMemoryProvider(MemoryProvider):
|
|||
return r
|
||||
return ""
|
||||
|
||||
# Prompts that carry no semantic signal — trivial acknowledgements, slash
|
||||
# commands, empty input. Skipping injection here saves tokens and prevents
|
||||
# Prompts that carry no semantic signal — trivial acknowledgements, greetings,
|
||||
# slash commands, empty input. Skipping injection here saves tokens and prevents
|
||||
# stale user-model context from derailing one-word replies.
|
||||
_TRIVIAL_PROMPT_RE = re.compile(
|
||||
r'^(yes|no|ok|okay|sure|thanks|thank you|y|n|yep|nope|yeah|nah|'
|
||||
r'hi|hey|hello|yo|sup|'
|
||||
r'continue|go ahead|do it|proceed|got it|cool|nice|great|done|next|lgtm|k)$',
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
|
|
|||
18
run_agent.py
18
run_agent.py
|
|
@ -12118,11 +12118,27 @@ class AIAgent:
|
|||
# prefetch_all() on each tool call (10 tool calls = 10x latency + cost).
|
||||
# Use original_user_message (clean input) — user_message may contain
|
||||
# injected skill content that bloats / breaks provider queries.
|
||||
#
|
||||
# Skip prefetch on trivial prompts (greetings, acknowledgements) to
|
||||
# prevent memory-context injection on turns that carry no semantic signal.
|
||||
_TRIVIAL_QUERY_RE = re.compile(
|
||||
r'^(yes|no|ok|okay|sure|thanks|thank you|y|n|yep|nope|yeah|nah|'
|
||||
r'hi|hey|hello|yo|sup|'
|
||||
r'continue|go ahead|do it|proceed|got it|cool|nice|great|done|next|lgtm|k)$',
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
_ext_prefetch_cache = ""
|
||||
if self._memory_manager:
|
||||
try:
|
||||
_query = original_user_message if isinstance(original_user_message, str) else ""
|
||||
_ext_prefetch_cache = self._memory_manager.prefetch_all(_query) or ""
|
||||
_is_trivial = (
|
||||
not _query
|
||||
or _query.strip().startswith("/")
|
||||
or re.match(_TRIVIAL_QUERY_RE, _query.strip())
|
||||
)
|
||||
if not _is_trivial:
|
||||
_ext_prefetch_cache = self._memory_manager.prefetch_all(_query) or ""
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue