|
23 | 23 | from typing import Any, Callable, Dict, List, Optional |
24 | 24 |
|
25 | 25 | 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 |
27 | 27 | from tools.registry import tool_error |
28 | 28 |
|
29 | 29 | logger = logging.getLogger(__name__) |
@@ -1198,24 +1198,15 @@ def _run_dialectic_depth(self, query: str, *, use_query_rewrite: bool = True) -> |
1198 | 1198 |
|
1199 | 1199 | # Prompts that carry no semantic signal — trivial acknowledgements, greetings, |
1200 | 1200 | # 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. |
1204 | 1204 | _TRIVIAL_PROMPT_RE = TRIVIAL_PROMPT_RE |
1205 | 1205 |
|
1206 | 1206 | @classmethod |
1207 | 1207 | def _is_trivial_prompt(cls, text: str) -> bool: |
1208 | 1208 | """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) |
1219 | 1210 |
|
1220 | 1211 | def on_turn_start(self, turn_number: int, message: str, **kwargs) -> None: |
1221 | 1212 | """Track turn count for cadence and injection_frequency logic.""" |
|
0 commit comments