From 72da79366486f358adac59aa8ec96d67ec2c9af3 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Fri, 9 Jan 2026 16:20:58 +0530 Subject: [PATCH] skip dynamic imports --- extensions/cli/src/tools/subagent.test.ts | 18 ++++++++++-------- extensions/cli/src/tools/subagent.ts | 6 ++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/extensions/cli/src/tools/subagent.test.ts b/extensions/cli/src/tools/subagent.test.ts index 90a53ac8e..e4f2d61ea 100644 --- a/extensions/cli/src/tools/subagent.test.ts +++ b/extensions/cli/src/tools/subagent.test.ts @@ -1,6 +1,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { services } from "../services/index.js"; +import { serviceContainer } from "../services/ServiceContainer.js"; import { executeSubAgent } from "../subagent/executor.js"; import { getAgentNames, getSubagent } from "../subagent/get-agents.js"; @@ -8,6 +9,11 @@ import { subagentTool } from "./subagent.js"; vi.mock("../subagent/get-agents.js"); vi.mock("../subagent/executor.js"); +vi.mock("../services/ServiceContainer.js", () => ({ + serviceContainer: { + get: vi.fn(), + }, +})); vi.mock("../services/index.js", () => ({ services: { chatHistory: { @@ -22,12 +28,13 @@ describe("subagentTool", () => { beforeEach(() => { vi.clearAllMocks(); + vi.mocked(serviceContainer.get).mockResolvedValue(modelServiceState); }); it("preprocess throws when agent is not found", async () => { vi.mocked(getAgentNames).mockReturnValue(["code-agent"]); - const tool = subagentTool({ modelServiceState } as any); + const tool = await subagentTool(); const args = { description: "Test task", @@ -47,7 +54,7 @@ describe("subagentTool", () => { it("preprocess includes agent model name when agent exists", async () => { vi.mocked(getAgentNames).mockReturnValue(["code-agent"]); - const tool = subagentTool({ modelServiceState } as any); + const tool = await subagentTool(); vi.mocked(getSubagent).mockReturnValue({ model: { name: "test-model" }, @@ -83,12 +90,7 @@ describe("subagentTool", () => { response: "subagent-output", } as any); - const serviceContainer = {} as any; - - const tool = subagentTool({ - modelServiceState, - serviceContainer, - } as any); + const tool = await subagentTool(); const result = await tool.run( { diff --git a/extensions/cli/src/tools/subagent.ts b/extensions/cli/src/tools/subagent.ts index c457440c3..43d2d29eb 100644 --- a/extensions/cli/src/tools/subagent.ts +++ b/extensions/cli/src/tools/subagent.ts @@ -1,5 +1,7 @@ +import { services } from "../services/index.js"; import { serviceContainer } from "../services/ServiceContainer.js"; import { ModelServiceState, SERVICE_NAMES } from "../services/types.js"; +import { executeSubAgent } from "../subagent/executor.js"; import { generateSubagentToolDescription, getSubagent, @@ -69,10 +71,6 @@ export const subagentTool = async (): Promise => { throw new Error(`Unknown agent type: ${subagent_name}`); } - // Dynamically import to avoid circular dependency and passing repeated params - const { executeSubAgent } = await import("../subagent/executor.js"); - const { services } = await import("../services/index.js"); - const chatHistoryService = services.chatHistory; const parentSessionId = chatHistoryService.getSessionId(); if (!parentSessionId) {