diff --git a/src/auto-reply/reply/agent-runner-execution.runtime.ts b/src/auto-reply/reply/agent-runner-execution.runtime.ts new file mode 100644 index 00000000000..9d1f4af3261 --- /dev/null +++ b/src/auto-reply/reply/agent-runner-execution.runtime.ts @@ -0,0 +1 @@ +export { runAgentTurnWithFallback } from "./agent-runner-execution.js"; diff --git a/src/auto-reply/reply/agent-runner-memory.runtime.ts b/src/auto-reply/reply/agent-runner-memory.runtime.ts new file mode 100644 index 00000000000..f49c9847ae5 --- /dev/null +++ b/src/auto-reply/reply/agent-runner-memory.runtime.ts @@ -0,0 +1 @@ +export { runMemoryFlushIfNeeded } from "./agent-runner-memory.js"; diff --git a/src/auto-reply/reply/agent-runner.ts b/src/auto-reply/reply/agent-runner.ts index cabef3edef5..31a7ee710a0 100644 --- a/src/auto-reply/reply/agent-runner.ts +++ b/src/auto-reply/reply/agent-runner.ts @@ -27,7 +27,6 @@ import { import type { OriginatingChannelType, TemplateContext } from "../templating.js"; import { resolveResponseUsageMode, type VerboseLevel } from "../thinking.js"; import type { GetReplyOptions, ReplyPayload } from "../types.js"; -import { runAgentTurnWithFallback } from "./agent-runner-execution.js"; import { createShouldEmitToolOutput, createShouldEmitToolResult, @@ -35,7 +34,6 @@ import { isAudioPayload, signalTypingIfNeeded, } from "./agent-runner-helpers.js"; -import { runMemoryFlushIfNeeded } from "./agent-runner-memory.js"; import { buildReplyPayloads } from "./agent-runner-payloads.js"; import { appendUnscheduledReminderNote, @@ -60,12 +58,28 @@ const BLOCK_REPLY_SEND_TIMEOUT_MS = 15_000; let piEmbeddedQueueRuntimePromise: Promise< typeof import("../../agents/pi-embedded-queue.runtime.js") > | null = null; +let agentRunnerExecutionRuntimePromise: Promise< + typeof import("./agent-runner-execution.runtime.js") +> | null = null; +let agentRunnerMemoryRuntimePromise: Promise< + typeof import("./agent-runner-memory.runtime.js") +> | null = null; function loadPiEmbeddedQueueRuntime() { piEmbeddedQueueRuntimePromise ??= import("../../agents/pi-embedded-queue.runtime.js"); return piEmbeddedQueueRuntimePromise; } +function loadAgentRunnerExecutionRuntime() { + agentRunnerExecutionRuntimePromise ??= import("./agent-runner-execution.runtime.js"); + return agentRunnerExecutionRuntimePromise; +} + +function loadAgentRunnerMemoryRuntime() { + agentRunnerMemoryRuntimePromise ??= import("./agent-runner-memory.runtime.js"); + return agentRunnerMemoryRuntimePromise; +} + export async function runReplyAgent(params: { commandBody: string; followupRun: FollowupRun; @@ -231,6 +245,7 @@ export async function runReplyAgent(params: { await typingSignals.signalRunStart(); + const { runMemoryFlushIfNeeded } = await loadAgentRunnerMemoryRuntime(); activeSessionEntry = await runMemoryFlushIfNeeded({ cfg, followupRun, @@ -359,6 +374,7 @@ export async function runReplyAgent(params: { }); try { const runStartedAt = Date.now(); + const { runAgentTurnWithFallback } = await loadAgentRunnerExecutionRuntime(); const runOutcome = await runAgentTurnWithFallback({ commandBody, followupRun,