Skip to content

The open-source app everyone uses to manage agents at work

refactor: defer adapter launcher imports during workspace snapshots (#16492)

Dotta61831ba7b872
diff --git a/doc/execution-semantics.md b/doc/execution-semantics.md
index 212a0d0663..e2c160a225 100644
--- a/doc/execution-semantics.md
+++ b/doc/execution-semantics.md
@@ -542,7 +542,9 @@ private manifest before handing it to the controller; ordinary snapshot disposal
removes that worker's temporary directory. A failed capture removes its temporary
state before releasing its worker slot. This scheduling boundary does not replace
source authorization, warm-stamp validation, Git identity checks or restore
-conflict detection. Legacy adapter snapshots remain inline.
+conflict detection. Legacy adapter snapshots remain inline. Snapshot-only workers
+do not load the adapter process-launch helpers. The directory merge loads those
+helpers when it resolves its instance-scoped lock root.
### Remote Codex model compatibility
diff --git a/packages/adapter-utils/src/workspace-restore-merge.ts b/packages/adapter-utils/src/workspace-restore-merge.ts
index e35923638a..7e1d2f9a48 100644
--- a/packages/adapter-utils/src/workspace-restore-merge.ts
+++ b/packages/adapter-utils/src/workspace-restore-merge.ts
@@ -5,7 +5,6 @@ import path from "node:path";
import { DatabaseSync } from "node:sqlite";
import { createWorkspaceManifest, WorkspaceManifestMap, workspacePathMatcher, type PathManifest, type WorkspacePaths, type WorkspaceManifestWriter } from "./workspace-manifest.js";
import { shouldExcludePath } from "./exclude-patterns.js";
-import { resolvePaperclipInstanceRootForAdapter } from "./server-utils.js";
import { runSnapshotThread } from "./workspace-snapshot-thread.js";
import type { WorkspaceRestoreDiagnostic } from "./workspace-restore-diagnostics.js";
@@ -493,6 +492,7 @@ function nonEmpty(value: string | undefined): string | null {
* would follow the symlink) before any caller treats it as the lock root.
*/
async function resolveDirectoryMergeLockRoot(env: NodeJS.ProcessEnv = process.env): Promise<string> {
+ const { resolvePaperclipInstanceRootForAdapter } = await import("./server-utils.js");
const instanceRoot = resolvePaperclipInstanceRootForAdapter({
homeDir: nonEmpty(env.PAPERCLIP_HOME) ?? undefined,
instanceId: nonEmpty(env.PAPERCLIP_INSTANCE_ID) ?? undefined,