Fix: prevent system-reminder tags from triggering mode keywords (#1155)

Automated system messages with <system-reminder> tags were incorrectly
triggering [search-mode], [analyze-mode], and other keyword modes when
they contained words like "search", "find", "explore", etc.

Changes:
- Add removeSystemReminders() to strip <system-reminder> content before keyword detection
- Add hasSystemReminder() utility function
- Update keyword-detector to clean text before pattern matching
- Add comprehensive test coverage for system-reminder filtering

Fixes issue where automated system notifications caused agents to
incorrectly enter MAXIMUM SEARCH EFFORT mode.

Co-authored-by: TheEpTic <git@eptic.me>
This commit is contained in:
TheEpTic
2026-01-28 07:26:37 +00:00
committed by GitHub
parent 48f6c5e06d
commit 01500f1ebe
4 changed files with 407 additions and 2 deletions
+20
View File
@@ -26,6 +26,26 @@ export function isSystemDirective(text: string): boolean {
return text.trimStart().startsWith(SYSTEM_DIRECTIVE_PREFIX)
}
/**
* Checks if a message contains system-generated content that should be excluded
* from keyword detection and mode triggering.
* @param text - The message text to check
* @returns true if the message contains system-reminder tags
*/
export function hasSystemReminder(text: string): boolean {
return /<system-reminder>[\s\S]*?<\/system-reminder>/i.test(text)
}
/**
* Removes system-reminder tag content from text.
* This prevents automated system messages from triggering mode keywords.
* @param text - The message text to clean
* @returns text with system-reminder content removed
*/
export function removeSystemReminders(text: string): string {
return text.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/gi, "").trim()
}
export const SystemDirectiveTypes = {
TODO_CONTINUATION: "TODO CONTINUATION",
RALPH_LOOP: "RALPH LOOP",