Skip to content

Commit 7d7c56a

Browse files
open-design-crew[bot]Cheems
andauthored
fix(daemon): isolate plugin-started Local Codex runs (#6273)
Disable Codex plugins only for externally attributed Open Design Plugin runs so Local Codex cannot recursively enter collect_brief or Cloud login. Preserve normal Local Codex plugin loading and the existing operator-wide override. Validated with the focused runtime args suite, workspace typecheck, guard, and an isolated source smoke that produced a valid artifact without Cloud login. Co-authored-by: Cheems <94773058+itscheems@users.noreply.github.com>
1 parent 4d4a659 commit 7d7c56a

4 files changed

Lines changed: 40 additions & 1 deletion

File tree

apps/daemon/src/runtimes/defs/codex.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,10 @@ export const codexAgentDef = {
228228
const args = resumeSessionId
229229
? ['exec', 'resume', '--json', '--skip-git-repo-check', ...sandboxArgs]
230230
: ['exec', '--json', '--skip-git-repo-check', ...sandboxArgs];
231-
if (process.env.OD_CODEX_DISABLE_PLUGINS === '1') {
231+
if (
232+
runtimeContext.disablePlugins === true
233+
|| process.env.OD_CODEX_DISABLE_PLUGINS === '1'
234+
) {
232235
args.push('--disable', 'plugins');
233236
}
234237
// `-C <cwd>` and `--add-dir <dir>` are CREATE-only flags: `codex exec

apps/daemon/src/runtimes/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ export type RuntimeContext = {
6565
// also persists) and the daemon seeds it with the full transcript.
6666
resumeSessionId?: string | null;
6767
newSessionId?: string;
68+
// Per-run plugin isolation for agent subprocesses. External Plugin entry
69+
// points use this for Local Codex so the child cannot recursively load the
70+
// same Codex Plugin and route itself into another Open Design workflow.
71+
// Operator-wide overrides remain owned by each runtime definition.
72+
disablePlugins?: boolean;
6873
};
6974

7075
// Marker on a RuntimeAgentDef declaring that the adapter's CLI maintains

apps/daemon/src/server.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
} from './prompts/stable-sections.js';
3636
import { emittedRenderableQuestionForm } from './question-form-detect.js';
3737
import { resolveProjectRoot } from './project-root.js';
38+
import { OPEN_DESIGN_PLUGIN_ID } from './mcp-observability.js';
3839
import {
3940
resolveDaemonCliPath,
4041
resolveDaemonPluginPreviewsDir,
@@ -6281,6 +6282,10 @@ export async function startServer({
62816282
promptFilePath: promptFile?.path,
62826283
resumeSessionId: agentResumeCtx.resumeSessionId,
62836284
newSessionId: agentResumeCtx.newSessionId,
6285+
disablePlugins:
6286+
def.id === 'codex'
6287+
&& run.externalPluginAnalytics?.externalPluginId
6288+
=== OPEN_DESIGN_PLUGIN_ID,
62846289
},
62856290
);
62866291
} catch (err) {

apps/daemon/tests/runtimes/registry-and-args.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,32 @@ test('codex args disable plugins when OD_CODEX_DISABLE_PLUGINS is 1', () => {
152152
});
153153
});
154154

155+
test('codex args disable plugins for an externally attributed Local Codex run', () => {
156+
withEnvSnapshot(['OD_CODEX_DISABLE_PLUGINS', 'OD_CODEX_SANDBOX'], () => {
157+
delete process.env.OD_CODEX_DISABLE_PLUGINS;
158+
delete process.env.OD_CODEX_SANDBOX;
159+
160+
withPlatform('darwin', () => {
161+
const args = codex.buildArgs('', [], [], {}, {
162+
cwd: '/tmp/od-project',
163+
disablePlugins: true,
164+
});
165+
166+
assert.deepEqual(args.slice(0, 9), [
167+
'exec',
168+
'--json',
169+
'--skip-git-repo-check',
170+
'--sandbox',
171+
'workspace-write',
172+
'-c',
173+
'sandbox_workspace_write.network_access=true',
174+
'--disable',
175+
'plugins',
176+
]);
177+
});
178+
});
179+
});
180+
155181
test('codex args use workspace-write sandbox on macOS and Linux', () => {
156182
withEnvSnapshot(['OD_CODEX_DISABLE_PLUGINS', 'OD_CODEX_SANDBOX', 'WSL_DISTRO_NAME'], () => {
157183
delete process.env.OD_CODEX_DISABLE_PLUGINS;

0 commit comments

Comments
 (0)