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:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user