Skip to content

fix: avoid magic keyword activation on informational queries#1737

Merged
Yeachan-Heo merged 1 commit intodevfrom
fix/issue-1735-keyword-intent-detection
Mar 18, 2026
Merged

fix: avoid magic keyword activation on informational queries#1737
Yeachan-Heo merged 1 commit intodevfrom
fix/issue-1735-keyword-intent-detection

Conversation

@Yeachan-Heo
Copy link
Owner

@Yeachan-Heo Yeachan-Heo commented Mar 18, 2026

Summary

  • skip magic keyword activation when prompts are asking what a keyword means or how to use it
  • cover informational intent patterns for English, Korean, Japanese, and Chinese in both source and packaged keyword-detector artifacts
  • make session-scoped state_clear also remove legacy non-session state files (including older root-level legacy files) and add regression tests

Testing

  • npx vitest run src/hooks/keyword-detector/tests/index.test.ts src/installer/tests/hook-templates.test.ts src/tools/tests/state-tools.test.ts src/lib/tests/mode-state-io.test.ts src/hooks/tests/bridge-routing.test.ts src/hooks/tests/bridge.test.ts src/hooks/tests/bridge-openclaw.test.ts src/tests/hooks.test.ts src/tools/tests/cancel-integration.test.ts src/tests/smoke-slack-and-state.test.ts
  • npm run build

Notes

  • a broader unrelated test, src/tests/cleanup-validation.test.ts, timed out in builtin skill resolution during an exploratory run and was not needed for validating this fix

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2617876b95

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

const INFORMATIONAL_INTENT_PATTERNS: RegExp[] = [
/\b(?:what(?:'s|\s+is)|what\s+are|how\s+(?:to|do\s+i)\s+use|explain|explanation|tell\s+me\s+about|describe)\b/i,

Choose a reason for hiding this comment

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

P1 Badge Stop treating imperative "explain" prompts as informational

The English informational regex now includes bare verbs like explain and describe, so actionable prompts such as use ralph to explain this bug or autopilot explain this code are classified as informational and no mode is activated. This is a functional regression from the previous keyword behavior and breaks common command phrasing where users intentionally invoke a mode to provide an explanation.

Useful? React with 👍 / 👎.

Comment on lines +126 to +129
const start = Math.max(0, position - INFORMATIONAL_CONTEXT_WINDOW);
const end = Math.min(text.length, position + keywordLength + INFORMATIONAL_CONTEXT_WINDOW);
const context = text.slice(start, end);
return INFORMATIONAL_INTENT_PATTERNS.some(pattern => pattern.test(context));

Choose a reason for hiding this comment

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

P2 Badge Scope informational checks to the matched clause

The fixed ±80-character context window can suppress a valid command mention if an informational phrase appears nearby in the same prompt; for example, What is ralph? ralph fix this bug fails to trigger because the second ralph still falls inside the what is window. This causes mixed "ask then execute" prompts to be dropped even when they contain an explicit actionable keyword.

Useful? React with 👍 / 👎.

@Yeachan-Heo Yeachan-Heo merged commit 288bd97 into dev Mar 18, 2026
7 checks passed
sheldonhull pushed a commit to sheldonhull/oh-my-claudecode that referenced this pull request Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant