diff --git a/src/agents/agent-command.live-model-switch.test.ts b/src/agents/agent-command.live-model-switch.test.ts index 56fc4553d8b..b1aaea68860 100644 --- a/src/agents/agent-command.live-model-switch.test.ts +++ b/src/agents/agent-command.live-model-switch.test.ts @@ -30,7 +30,7 @@ vi.mock("./command/attempt-execution.runtime.js", () => ({ sessionFileHasContent: vi.fn(async () => false), })); -vi.mock("./command/delivery.js", () => ({ +vi.mock("./command/delivery.runtime.js", () => ({ deliverAgentCommandResult: (...args: unknown[]) => state.deliverAgentCommandResultMock(...args), })); diff --git a/src/agents/agent-command.ts b/src/agents/agent-command.ts index ea792a9f032..48dfd5bb226 100644 --- a/src/agents/agent-command.ts +++ b/src/agents/agent-command.ts @@ -50,7 +50,6 @@ import { persistSessionEntry as persistSessionEntryBase, prependInternalEventContext, } from "./command/attempt-execution.shared.js"; -import { deliverAgentCommandResult } from "./command/delivery.js"; import { resolveAgentRunContext } from "./command/run-context.js"; import { updateSessionStoreAfterAgentRun } from "./command/session-store.js"; import { resolveSession } from "./command/session.js"; @@ -79,9 +78,11 @@ import { ensureAgentWorkspace } from "./workspace.js"; const log = createSubsystemLogger("agents/agent-command"); type AttemptExecutionRuntime = typeof import("./command/attempt-execution.runtime.js"); +type DeliveryRuntime = typeof import("./command/delivery.runtime.js"); type TranscriptResolveRuntime = typeof import("../config/sessions/transcript-resolve.runtime.js"); let attemptExecutionRuntimePromise: Promise | undefined; +let deliveryRuntimePromise: Promise | undefined; let transcriptResolveRuntimePromise: Promise | undefined; function loadAttemptExecutionRuntime(): Promise { @@ -89,6 +90,11 @@ function loadAttemptExecutionRuntime(): Promise { return attemptExecutionRuntimePromise; } +function loadDeliveryRuntime(): Promise { + deliveryRuntimePromise ??= import("./command/delivery.runtime.js"); + return deliveryRuntimePromise; +} + function loadTranscriptResolveRuntime(): Promise { transcriptResolveRuntimePromise ??= import("../config/sessions/transcript-resolve.runtime.js"); return transcriptResolveRuntimePromise; @@ -557,6 +563,7 @@ async function agentCommandInternal( abortSignal: opts.abortSignal, }); const payloads = result.payloads; + const { deliverAgentCommandResult } = await loadDeliveryRuntime(); return await deliverAgentCommandResult({ cfg, @@ -1031,6 +1038,7 @@ async function agentCommandInternal( } const payloads = result.payloads ?? []; + const { deliverAgentCommandResult } = await loadDeliveryRuntime(); return await deliverAgentCommandResult({ cfg, deps, diff --git a/src/agents/command/delivery.runtime.ts b/src/agents/command/delivery.runtime.ts new file mode 100644 index 00000000000..da5db57315e --- /dev/null +++ b/src/agents/command/delivery.runtime.ts @@ -0,0 +1 @@ +export { deliverAgentCommandResult } from "./delivery.js";