Skip to content

Commit 34d6095

Browse files
committed
refactor(honcho): delegate _is_trivial_prompt wholly to the shared classifier
Simplify-pass finding: sharing only the REGEX left the wrapper logic (empty/strip/slash checks) duplicated, half-defeating the no-drift goal. The classmethod now calls agent/memory_provider.is_trivial_prompt directly; _TRIVIAL_PROMPT_RE stays as a class attr for backward compatibility with any external referents.
1 parent c093492 commit 34d6095

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

plugins/memory/honcho/__init__.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from typing import Any, Callable, Dict, List, Optional
2424

2525
from agent.memory_manager import sanitize_context
26-
from agent.memory_provider import TRIVIAL_PROMPT_RE, MemoryProvider
26+
from agent.memory_provider import TRIVIAL_PROMPT_RE, MemoryProvider, is_trivial_prompt
2727
from tools.registry import tool_error
2828

2929
logger = logging.getLogger(__name__)
@@ -1198,24 +1198,15 @@ def _run_dialectic_depth(self, query: str, *, use_query_rewrite: bool = True) ->
11981198

11991199
# Prompts that carry no semantic signal — trivial acknowledgements, greetings,
12001200
# slash commands, empty input. Skipping injection here saves tokens and prevents
1201-
# stale user-model context from derailing one-word replies. The pattern is
1202-
# shared with the core prefetch gate (agent/memory_provider.TRIVIAL_PROMPT_RE)
1203-
# so the provider-side classifier and the core gate can never drift apart.
1201+
# stale user-model context from derailing one-word replies. Classification is
1202+
# fully delegated to the shared agent/memory_provider.is_trivial_prompt so the
1203+
# provider-side classifier and the core prefetch gate can never drift apart.
12041204
_TRIVIAL_PROMPT_RE = TRIVIAL_PROMPT_RE
12051205

12061206
@classmethod
12071207
def _is_trivial_prompt(cls, text: str) -> bool:
12081208
"""Return True if the prompt is too trivial to warrant context injection."""
1209-
if not text:
1210-
return True
1211-
stripped = text.strip()
1212-
if not stripped:
1213-
return True
1214-
if stripped.startswith("/"):
1215-
return True
1216-
if cls._TRIVIAL_PROMPT_RE.match(stripped):
1217-
return True
1218-
return False
1209+
return is_trivial_prompt(text)
12191210

12201211
def on_turn_start(self, turn_number: int, message: str, **kwargs) -> None:
12211212
"""Track turn count for cadence and injection_frequency logic."""

0 commit comments

Comments
 (0)