From 0f5b8e921a3c5294730009313659dc50ffc39b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pe=C3=AFo=20Thibault?= Date: Tue, 10 Feb 2026 18:44:41 +0100 Subject: [PATCH] test(call-omo-agent): add disabled_agents validation tests Closes #1716 ## Summary - Added 4 tests for disabled_agents validation in call_omo_agent tool - Tests verify agent rejection when in disabled_agents list - Tests verify case-insensitive matching - Tests verify agents not in disabled list are allowed - Tests verify empty disabled_agents allows all agents --- src/tools/call-omo-agent/tools.test.ts | 102 +++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/tools/call-omo-agent/tools.test.ts diff --git a/src/tools/call-omo-agent/tools.test.ts b/src/tools/call-omo-agent/tools.test.ts new file mode 100644 index 00000000..a560c8be --- /dev/null +++ b/src/tools/call-omo-agent/tools.test.ts @@ -0,0 +1,102 @@ +import { describe, test, expect, mock } from "bun:test" +import type { PluginInput } from "@opencode-ai/plugin" +import type { BackgroundManager } from "../../features/background-agent" +import { createCallOmoAgent } from "./tools" + +describe("createCallOmoAgent", () => { + const mockCtx = { + client: {}, + directory: "/test", + } as unknown as PluginInput + + const mockBackgroundManager = { + launch: mock(() => Promise.resolve({ + id: "test-task-id", + sessionID: null, + description: "Test task", + agent: "test-agent", + status: "pending", + })), + } as unknown as BackgroundManager + + test("should reject agent in disabled_agents list", async () => { + //#given + const toolDef = createCallOmoAgent(mockCtx, mockBackgroundManager, ["explore"]) + const executeFunc = toolDef.execute as Function + + //#when + const result = await executeFunc( + { + description: "Test", + prompt: "Test prompt", + subagent_type: "explore", + run_in_background: true, + }, + { sessionID: "test", messageID: "msg", agent: "test", abort: new AbortController().signal } + ) + + //#then + expect(result).toContain("disabled via disabled_agents") + }) + + test("should reject agent in disabled_agents list with case-insensitive matching", async () => { + //#given + const toolDef = createCallOmoAgent(mockCtx, mockBackgroundManager, ["Explore"]) + const executeFunc = toolDef.execute as Function + + //#when + const result = await executeFunc( + { + description: "Test", + prompt: "Test prompt", + subagent_type: "explore", + run_in_background: true, + }, + { sessionID: "test", messageID: "msg", agent: "test", abort: new AbortController().signal } + ) + + //#then + expect(result).toContain("disabled via disabled_agents") + }) + + test("should allow agent not in disabled_agents list", async () => { + //#given + const toolDef = createCallOmoAgent(mockCtx, mockBackgroundManager, ["librarian"]) + const executeFunc = toolDef.execute as Function + + //#when + const result = await executeFunc( + { + description: "Test", + prompt: "Test prompt", + subagent_type: "explore", + run_in_background: true, + }, + { sessionID: "test", messageID: "msg", agent: "test", abort: new AbortController().signal } + ) + + //#then + // Should not contain disabled error - may fail for other reasons but disabled check should pass + expect(result).not.toContain("disabled via disabled_agents") + }) + + test("should allow all agents when disabled_agents is empty", async () => { + //#given + const toolDef = createCallOmoAgent(mockCtx, mockBackgroundManager, []) + const executeFunc = toolDef.execute as Function + + //#when + const result = await executeFunc( + { + description: "Test", + prompt: "Test prompt", + subagent_type: "explore", + run_in_background: true, + }, + { sessionID: "test", messageID: "msg", agent: "test", abort: new AbortController().signal } + ) + + //#then + expect(result).not.toContain("disabled via disabled_agents") + }) +})