




















@@ -362,6 +362,13 @@ export async function runCodexAppServerAttempt(
362362 ? resolvedWorkspace
363363 : sandbox.workspaceDir
364364 : resolvedWorkspace;
365+const requestedCwd = params.cwd ? resolveUserPath(params.cwd) : undefined;
366+if (sandbox?.enabled && requestedCwd && requestedCwd !== resolvedWorkspace) {
367+throw new Error(
368+"cwd override is not supported for sandboxed Codex app-server runs; omit cwd or use the agent workspace as cwd",
369+);
370+}
371+const effectiveCwd = sandbox?.enabled ? effectiveWorkspace : (requestedCwd ?? effectiveWorkspace);
365372await ensureCodexWorkspaceDirOnce(effectiveWorkspace);
366373preDynamicStartupStages.mark("effective-workspace");
367374const appServer = resolveCodexAppServerForOpenClawToolPolicy({
@@ -518,6 +525,7 @@ export async function runCodexAppServerAttempt(
518525 params,
519526 resolvedWorkspace,
520527 effectiveWorkspace,
528+ effectiveCwd,
521529 sandboxSessionKey,
522530 sandbox,
523531 nativeToolSurfaceEnabled,
@@ -534,6 +542,7 @@ export async function runCodexAppServerAttempt(
534542 params,
535543 resolvedWorkspace,
536544 effectiveWorkspace,
545+ effectiveCwd,
537546 sandboxSessionKey,
538547 sandbox,
539548 nativeToolSurfaceEnabled,
@@ -597,6 +606,7 @@ export async function runCodexAppServerAttempt(
597606buildHarnessContextEngineRuntimeContext({
598607attempt: buildActiveRunAttemptParams(),
599608workspaceDir: effectiveWorkspace,
609+cwd: effectiveCwd,
600610 agentDir,
601611activeAgentId: sessionAgentId,
602612contextEnginePluginId: activeContextEnginePluginId,
@@ -777,7 +787,7 @@ export async function runCodexAppServerAttempt(
777787});
778788const trajectoryRecorder = createCodexTrajectoryRecorder({
779789attempt: params,
780-cwd: effectiveWorkspace,
790+cwd: effectiveCwd,
781791developerInstructions: buildRenderedCodexDeveloperInstructions(),
782792prompt: codexTurnPromptText,
783793tools: toolBridge.availableSpecs,
@@ -795,7 +805,7 @@ export async function runCodexAppServerAttempt(
795805}
796806};
797807let codexEnvironmentSelection: CodexTurnEnvironmentParams[] | undefined;
798-let codexExecutionCwd = effectiveWorkspace;
808+let codexExecutionCwd = effectiveCwd;
799809let codexSandboxPolicy: CodexSandboxPolicy | undefined;
800810let restartContextEngineCodexThread:
801811| (() => Promise<CodexAppServerThreadLifecycleBinding>)
@@ -859,6 +869,7 @@ export async function runCodexAppServerAttempt(
859869buildAttemptParams: buildActiveRunAttemptParams,
860870 sessionAgentId,
861871 effectiveWorkspace,
872+ effectiveCwd,
862873dynamicTools: toolBridge.specs,
863874developerInstructions: promptBuild.developerInstructions,
864875buildFinalConfigPatch: buildNativeHookRelayFinalConfigPatch,
@@ -902,7 +913,7 @@ export async function runCodexAppServerAttempt(
902913});
903914recordCodexTrajectoryContext(trajectoryRecorder, {
904915attempt: params,
905-cwd: effectiveWorkspace,
916+cwd: effectiveCwd,
906917developerInstructions: promptBuild.developerInstructions,
907918prompt: codexTurnPromptText,
908919tools: toolBridge.availableSpecs,
@@ -1846,6 +1857,7 @@ export async function runCodexAppServerAttempt(
18461857agentId: sessionAgentId,
18471858 notifyUserMessagePersisted,
18481859sessionKey: sandboxSessionKey,
1860+cwd: effectiveCwd,
18491861threadId: thread.threadId,
18501862turnId: activeTurnId,
18511863});
@@ -1970,6 +1982,7 @@ export async function runCodexAppServerAttempt(
19701982 notifyUserMessagePersisted,
19711983 result,
19721984sessionKey: contextSessionKey,
1985+cwd: effectiveCwd,
19731986threadId: thread.threadId,
19741987turnId: activeTurnId,
19751988});
@@ -2010,6 +2023,7 @@ export async function runCodexAppServerAttempt(
20102023runtimeContext: buildHarnessContextEngineRuntimeContextFromUsage({
20112024attempt: buildActiveRunAttemptParams(),
20122025workspaceDir: effectiveWorkspace,
2026+cwd: effectiveCwd,
20132027 agentDir,
20142028activeAgentId: sessionAgentId,
20152029contextEnginePluginId: activeContextEnginePluginId,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。