fix: skip keyword injection for non-OMO agents (fixes #2024)
This commit is contained in:
@@ -746,3 +746,109 @@ describe("keyword-detector agent-specific ultrawork messages", () => {
|
||||
expect(textPart!.text).not.toContain("YOU ARE A PLANNER, NOT AN IMPLEMENTER")
|
||||
})
|
||||
})
|
||||
|
||||
describe("keyword-detector non-OMO agent skipping", () => {
|
||||
let logCalls: Array<{ msg: string; data?: unknown }>
|
||||
let logSpy: ReturnType<typeof spyOn>
|
||||
|
||||
beforeEach(() => {
|
||||
_resetForTesting()
|
||||
logCalls = []
|
||||
logSpy = spyOn(sharedModule, "log").mockImplementation((msg: string, data?: unknown) => {
|
||||
logCalls.push({ msg, data })
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
logSpy?.mockRestore()
|
||||
_resetForTesting()
|
||||
})
|
||||
|
||||
function createMockPluginInput() {
|
||||
return {
|
||||
client: {
|
||||
tui: {
|
||||
showToast: async () => {},
|
||||
},
|
||||
},
|
||||
} as any
|
||||
}
|
||||
|
||||
test("should skip all keyword injection for OpenCode-Builder agent", async () => {
|
||||
// given - keyword-detector hook with Builder agent
|
||||
const collector = new ContextCollector()
|
||||
const hook = createKeywordDetectorHook(createMockPluginInput(), collector)
|
||||
const sessionID = "builder-session"
|
||||
const output = {
|
||||
message: {} as Record<string, unknown>,
|
||||
parts: [{ type: "text", text: "ultrawork search and analyze this code" }],
|
||||
}
|
||||
|
||||
// when - keyword detection runs with OpenCode-Builder agent
|
||||
await hook["chat.message"]({ sessionID, agent: "OpenCode-Builder" }, output)
|
||||
|
||||
// then - no keywords should be injected
|
||||
const textPart = output.parts.find(p => p.type === "text")
|
||||
expect(textPart).toBeDefined()
|
||||
expect(textPart!.text).toBe("ultrawork search and analyze this code")
|
||||
})
|
||||
|
||||
test("should skip all keyword injection for Plan agent", async () => {
|
||||
// given - keyword-detector hook with Plan agent
|
||||
const collector = new ContextCollector()
|
||||
const hook = createKeywordDetectorHook(createMockPluginInput(), collector)
|
||||
const sessionID = "plan-session"
|
||||
const output = {
|
||||
message: {} as Record<string, unknown>,
|
||||
parts: [{ type: "text", text: "search mode analyze mode ultrawork" }],
|
||||
}
|
||||
|
||||
// when - keyword detection runs with Plan agent
|
||||
await hook["chat.message"]({ sessionID, agent: "Plan" }, output)
|
||||
|
||||
// then - no keywords should be injected for non-OMO Plan agent
|
||||
const textPart = output.parts.find(p => p.type === "text")
|
||||
expect(textPart).toBeDefined()
|
||||
expect(textPart!.text).toBe("search mode analyze mode ultrawork")
|
||||
})
|
||||
|
||||
test("should still inject keywords for OMO agents like Sisyphus", async () => {
|
||||
// given - keyword-detector hook with Sisyphus agent
|
||||
const collector = new ContextCollector()
|
||||
const hook = createKeywordDetectorHook(createMockPluginInput(), collector)
|
||||
const sessionID = "sisyphus-session-omo"
|
||||
const output = {
|
||||
message: {} as Record<string, unknown>,
|
||||
parts: [{ type: "text", text: "ultrawork implement this" }],
|
||||
}
|
||||
|
||||
// when - keyword detection runs with Sisyphus (OMO agent)
|
||||
await hook["chat.message"]({ sessionID, agent: "sisyphus" }, output)
|
||||
|
||||
// then - keywords should be injected normally
|
||||
const textPart = output.parts.find(p => p.type === "text")
|
||||
expect(textPart).toBeDefined()
|
||||
expect(textPart!.text).toContain("YOU MUST LEVERAGE ALL AVAILABLE AGENTS")
|
||||
expect(textPart!.text).toContain("implement this")
|
||||
})
|
||||
|
||||
test("should skip keyword injection for agent names containing 'builder'", async () => {
|
||||
// given - keyword-detector hook with a builder-variant agent name
|
||||
const collector = new ContextCollector()
|
||||
const hook = createKeywordDetectorHook(createMockPluginInput(), collector)
|
||||
const sessionID = "custom-builder-session"
|
||||
const output = {
|
||||
message: {} as Record<string, unknown>,
|
||||
parts: [{ type: "text", text: "search this codebase" }],
|
||||
}
|
||||
|
||||
// when - keyword detection runs with a builder-type agent
|
||||
await hook["chat.message"]({ sessionID, agent: "Custom-Builder" }, output)
|
||||
|
||||
// then - search-mode should NOT be injected
|
||||
const textPart = output.parts.find(p => p.type === "text")
|
||||
expect(textPart).toBeDefined()
|
||||
expect(textPart!.text).toBe("search this codebase")
|
||||
expect(textPart!.text).not.toContain("[search-mode]")
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user