Skip to content

Conversation

@TheEpTic
Copy link

@TheEpTic TheEpTic commented Jan 26, 2026

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-OPENCODE prefix 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:

  1. New utility functions in src/shared/system-directive.ts:

    • hasSystemReminder(): Detects presence of system-reminder tags
    • removeSystemReminders(): Strips system-reminder content before keyword detection
  2. Updated keyword detector in src/hooks/keyword-detector/index.ts:

    • Calls removeSystemReminders() before running keyword pattern matching
    • Preserves user text while filtering automated system content
  3. Comprehensive test coverage:

    • 22 tests for system-reminder utility functions
    • 6 integration tests for keyword detector filtering
    • Edge cases: case-insensitive tags, multiple blocks, mixed content, etc.

Testing

All 46 tests pass, including:

  • System-reminder filtering prevents search/analyze mode triggers
  • User text keywords still detected correctly
  • Multiple system-reminder blocks handled properly
  • Case-insensitive tag matching
  • Multiline system-reminder content

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.

  • Bug Fixes
    • Strip blocks before keyword detection using removeSystemReminders() and hasSystemReminder().
    • Updated keyword detector to clean text prior to pattern matching; user content is preserved.
    • Added tests (22 utility, 6 integration) covering case-insensitive tags, multiple blocks, and multiline content.

Written for commit d6b344f. Summary will update on new commits.

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.
@github-actions
Copy link
Contributor

Thank you for your contribution! Before we can merge this PR, we need you to sign our Contributor License Agreement (CLA).

To sign the CLA, please comment on this PR with:

I have read the CLA Document and I hereby sign the CLA

This is a one-time requirement. Once signed, all your future contributions will be automatically accepted.


I have read the CLA Document and I hereby sign the CLA


TheEpTic seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@TheEpTic
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant