Skip to content

fix: skip keyword injection for non-OMO agents (fixes #2024)#2765

Merged
code-yeongyu merged 1 commit intodevfrom
fix/issue-2024
Mar 23, 2026
Merged

fix: skip keyword injection for non-OMO agents (fixes #2024)#2765
code-yeongyu merged 1 commit intodevfrom
fix/issue-2024

Conversation

@code-yeongyu
Copy link
Copy Markdown
Owner

@code-yeongyu code-yeongyu commented Mar 23, 2026

Problem

The keyword-detector hook injects [search-mode]/[analyze-mode] into all agents in the main session, including the built-in OpenCode Builder/Plan agents that do not understand these keywords.

Fix

Check the current agent before keyword injection. Skip injection for non-OMO agents (built-in Builder, Plan, etc.).

Fixes #2024

Automated fix by Sisyphus (oh-my-opencode)


Summary by cubic

Skip injecting [search-mode] and [analyze-mode] for non-OMO agents (OpenCode-Builder, Plan) to prevent invalid prompts; keep injection for OMO agents. Fixes #2024.

  • Bug Fixes
    • Added isNonOmoAgent and exported it through ultrawork and constants.
    • Updated keyword-detector hook to early-return for non-OMO agents and log the skip.
    • Added tests for Builder, Plan, custom builder names, and confirmed injection still occurs for OMO agents like Sisyphus.

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

Copy link
Copy Markdown

@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.

2 issues found across 5 files

Confidence score: 3/5

  • Potential user-facing behavior change: keyword injection may run for the default OpenCode agent because build isn’t recognized, which could alter detection behavior in src/hooks/keyword-detector/ultrawork/source-detector.ts.
  • Similar compatibility gap in src/hooks/keyword-detector/hook.ts where isNonOmoAgent misses the build agent, making agent filtering inconsistent and likely incorrect.
  • Given the high severity/confidence of agent-name mismatches, there’s some regression risk despite a small scope change.
  • Pay close attention to src/hooks/keyword-detector/ultrawork/source-detector.ts, src/hooks/keyword-detector/hook.ts - agent name checks should include build to prevent unintended keyword injection.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/hooks/keyword-detector/hook.ts">

<violation number="1" location="src/hooks/keyword-detector/hook.ts:49">
P1: Custom agent: **Opencode Compatibility**

The OpenCode native agent is named `build`, which is missed by the `isNonOmoAgent` check (which only looks for `builder` and `plan`). Explicitly check for `build` to ensure the native subagent doesn't receive unsupported keyword injections.</violation>
</file>

<file name="src/hooks/keyword-detector/ultrawork/source-detector.ts">

<violation number="1" location="src/hooks/keyword-detector/ultrawork/source-detector.ts:33">
P1: Custom agent: **Opencode Compatibility**

The built-in OpenCode agent is named `build`, not `builder`. Update the condition to check for `build` so that keyword injection is correctly skipped for the default agent.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

const currentAgent = getSessionAgent(input.sessionID) ?? input.agent

// Skip all keyword injection for non-OMO agents (e.g., OpenCode-Builder, Plan)
if (isNonOmoAgent(currentAgent)) {
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Mar 23, 2026

Choose a reason for hiding this comment

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

P1: Custom agent: Opencode Compatibility

The OpenCode native agent is named build, which is missed by the isNonOmoAgent check (which only looks for builder and plan). Explicitly check for build to ensure the native subagent doesn't receive unsupported keyword injections.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/hooks/keyword-detector/hook.ts, line 49:

<comment>The OpenCode native agent is named `build`, which is missed by the `isNonOmoAgent` check (which only looks for `builder` and `plan`). Explicitly check for `build` to ensure the native subagent doesn't receive unsupported keyword injections.</comment>

<file context>
@@ -45,6 +45,12 @@ export function createKeywordDetectorHook(ctx: PluginInput, _collector?: Context
       const currentAgent = getSessionAgent(input.sessionID) ?? input.agent
 
+      // Skip all keyword injection for non-OMO agents (e.g., OpenCode-Builder, Plan)
+      if (isNonOmoAgent(currentAgent)) {
+        log(`[keyword-detector] Skipping keyword injection for non-OMO agent`, { sessionID: input.sessionID, agent: currentAgent })
+        return
</file context>
Suggested change
if (isNonOmoAgent(currentAgent)) {
if (currentAgent === "build" || isNonOmoAgent(currentAgent)) {
Fix with Cubic

export function isNonOmoAgent(agentName?: string): boolean {
if (!agentName) return false
const lowerName = agentName.toLowerCase()
return lowerName.includes("builder") || lowerName === "plan"
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Mar 23, 2026

Choose a reason for hiding this comment

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

P1: Custom agent: Opencode Compatibility

The built-in OpenCode agent is named build, not builder. Update the condition to check for build so that keyword injection is correctly skipped for the default agent.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/hooks/keyword-detector/ultrawork/source-detector.ts, line 33:

<comment>The built-in OpenCode agent is named `build`, not `builder`. Update the condition to check for `build` so that keyword injection is correctly skipped for the default agent.</comment>

<file context>
@@ -23,6 +23,16 @@ export function isPlannerAgent(agentName?: string): boolean {
+export function isNonOmoAgent(agentName?: string): boolean {
+  if (!agentName) return false
+  const lowerName = agentName.toLowerCase()
+  return lowerName.includes("builder") || lowerName === "plan"
+}
+
</file context>
Suggested change
return lowerName.includes("builder") || lowerName === "plan"
return lowerName === "build" || lowerName === "plan"
Fix with Cubic

@code-yeongyu code-yeongyu merged commit 94c234c into dev Mar 23, 2026
8 checks passed
@code-yeongyu code-yeongyu deleted the fix/issue-2024 branch March 23, 2026 09:39
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.

[Bug]: OpenCode-Builder agent injects search-mode and analyze-mode

1 participant