Fix: Prevent system-reminder tags from triggering mode keywords #1155
+407
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Automated system messages with
<system-reminder>tags were incorrectly triggering mode keywords like[search-mode],[analyze-mode], etc. when they contained words such as "search", "find", "explore", "investigate", etc.This caused agents to incorrectly enter MAXIMUM SEARCH EFFORT mode when receiving automated system notifications, leading to confusing behavior and wasted computational resources.
Root Cause
The
isSystemDirective()function only checked for[SYSTEM DIRECTIVE: OH-MY-OPENCODEprefix but did not filter out XML-style<system-reminder>tags. When these automated system messages contained search-related keywords, the keyword detector would match them and inject mode directives.Solution
Added comprehensive filtering for
<system-reminder>tags:New utility functions in
src/shared/system-directive.ts:hasSystemReminder(): Detects presence of system-reminder tagsremoveSystemReminders(): Strips system-reminder content before keyword detectionUpdated keyword detector in
src/hooks/keyword-detector/index.ts:removeSystemReminders()before running keyword pattern matchingComprehensive test coverage:
Testing
All 46 tests pass, including:
Impact
✅ Fixes false-positive mode triggers from automated system messages
✅ Preserves legitimate user keyword detection
✅ No breaking changes to existing functionality
✅ Comprehensive test coverage ensures robustness
Summary by cubic
Prevented automated messages from triggering mode keywords like [search-mode] and [analyze-mode]. This stops false mode switches from system notifications while keeping user keyword detection unchanged.
Written for commit d6b344f. Summary will update on new commits.