summaryrefslogtreecommitdiffhomepage
path: root/packages/session-orchestrator/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/session-orchestrator/src')
-rw-r--r--packages/session-orchestrator/src/orchestrator.test.ts19
-rw-r--r--packages/session-orchestrator/src/orchestrator.ts13
2 files changed, 22 insertions, 10 deletions
diff --git a/packages/session-orchestrator/src/orchestrator.test.ts b/packages/session-orchestrator/src/orchestrator.test.ts
index 8ff3f5e..654c0c3 100644
--- a/packages/session-orchestrator/src/orchestrator.test.ts
+++ b/packages/session-orchestrator/src/orchestrator.test.ts
@@ -3611,12 +3611,13 @@ function createFakeSystemPromptService(
constructImpl: (
conversationId: string,
cwd: string,
- context?: { readonly model?: string },
+ context?: { readonly model?: string; readonly computerId?: string },
) => Promise<string>,
- getWithMetaImpl: (
- conversationId: string,
- ) => Promise<{ readonly prompt: string | null; readonly cwd: string | null }> = () =>
- Promise.resolve({ prompt: null, cwd: null }),
+ getWithMetaImpl: (conversationId: string) => Promise<{
+ readonly prompt: string | null;
+ readonly cwd: string | null;
+ readonly computerId: string | null;
+ }> = () => Promise.resolve({ prompt: null, cwd: null, computerId: null }),
): SystemPromptService {
return {
construct: constructImpl,
@@ -3663,7 +3664,7 @@ describe("system prompt: regular turn flow", () => {
},
async (conversationId) => {
getCalls.push(conversationId);
- return null;
+ return { prompt: null, cwd: null, computerId: null };
},
),
});
@@ -3714,7 +3715,7 @@ describe("system prompt: regular turn flow", () => {
},
async (conversationId) => {
getWithMetaCalls.push(conversationId);
- return { prompt: "PERSISTED_PROMPT", cwd: "/work/dir" };
+ return { prompt: "PERSISTED_PROMPT", cwd: "/work/dir", computerId: null };
},
),
});
@@ -3762,7 +3763,7 @@ describe("system prompt: regular turn flow", () => {
constructCalls.push({ conversationId, cwd, model: context?.model });
return "RECONSTRUCTED_PROMPT";
},
- async () => ({ prompt: null, cwd: null }),
+ async () => ({ prompt: null, cwd: null, computerId: null }),
),
});
@@ -3815,7 +3816,7 @@ describe("system prompt: regular turn flow", () => {
async (conversationId) => {
getWithMetaCalls.push(conversationId);
// Stored prompt was built against an OLD cwd.
- return { prompt: "STALE_PROMPT", cwd: "/old/dir" };
+ return { prompt: "STALE_PROMPT", cwd: "/old/dir", computerId: null };
},
),
});
diff --git a/packages/session-orchestrator/src/orchestrator.ts b/packages/session-orchestrator/src/orchestrator.ts
index a1401d6..4aa77f7 100644
--- a/packages/session-orchestrator/src/orchestrator.ts
+++ b/packages/session-orchestrator/src/orchestrator.ts
@@ -619,17 +619,26 @@ export function createSessionOrchestrator(
{
...(effectiveModelName !== undefined ? { model: effectiveModelName } : {}),
...(workspaceId !== undefined ? { workspaceId } : {}),
+ ...(effectiveComputerId !== undefined ? { computerId: effectiveComputerId } : {}),
},
);
} else {
const meta = await systemPromptService.getWithMeta(conversationId);
const currentCwd = effectiveCwd ?? process.cwd();
- if (meta.prompt !== null && meta.cwd === currentCwd) {
+ const currentComputerId = effectiveComputerId ?? null;
+ // Invalidate when cwd OR computerId changed (switching computers
+ // must rebuild the prompt against the remote OS/hostname).
+ if (
+ meta.prompt !== null &&
+ meta.cwd === currentCwd &&
+ meta.computerId === currentComputerId
+ ) {
systemPrompt = meta.prompt;
} else {
systemPrompt = await systemPromptService.construct(conversationId, currentCwd, {
...(effectiveModelName !== undefined ? { model: effectiveModelName } : {}),
...(workspaceId !== undefined ? { workspaceId } : {}),
+ ...(effectiveComputerId !== undefined ? { computerId: effectiveComputerId } : {}),
});
}
}
@@ -1122,9 +1131,11 @@ export function createCompactionService(
if (systemPromptService !== undefined) {
const cwd = (await deps.conversationStore.getEffectiveCwd(conversationId)) ?? process.cwd();
const workspaceId = await deps.conversationStore.getWorkspaceId(conversationId);
+ const computerId = await deps.conversationStore.getEffectiveComputer(conversationId);
const constructed = await systemPromptService.construct(conversationId, cwd, {
...(opts?.modelName !== undefined ? { model: opts.modelName } : {}),
workspaceId,
+ ...(computerId !== null ? { computerId } : {}),
});
compactionSystemPrompt = `${constructed}\n\n${COMPACTION_SYSTEM_PROMPT}`;
} else {