Skip to content

Commit d8583ae

Browse files
authored
Turn off the Codex plugin for the connector's Claude turns (#1059)
An orchestrator that had run for three days stopped being able to start any shell command, even `echo hi`: "command line plus environment exceed the OS exec argument limit (E2BIG)". OpenAI's Codex plugin appends three exports to the session's env file on every SessionStart, and each `claude -p --resume` turn is one. Claude Code inlines that file into the single `bash -c` argument of every Bash call. After 375 turns the file was 133.5 KB, past Linux's 128 KiB limit on one argument, so nothing could run. Restarting the connector didn't help, because it resumes the same session and the file belongs to it. Every Claude turn the connector starts, orchestrator and worker, now passes --settings turning that one plugin off. --settings merges over the person's own settings, so their other plugins stay on, and Codex stays on in their own sessions.
1 parent e18cb59 commit d8583ae

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎internal/connector/runner/adapter.go‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,22 @@ func (claudeAdapter) NewSessionID() string { return newUUID() }
162162
// runs the ones it finds safe and stops the rest, with no prompt.
163163
func (claudeAdapter) Guarded() bool { return true }
164164

165+
// claudeTurnSettings turns off, for the connector's turns only, plugins that
166+
// break a session the connector continues for days. OpenAI's Codex plugin
167+
// appends its exports to the session's env file on every SessionStart, and a
168+
// resume is one, so every turn adds a copy. Claude Code inlines that file
169+
// into each Bash command's single `bash -c` argument, and past Linux's 128 KiB
170+
// limit on one argument (MAX_ARG_STRLEN) no command starts, not even `echo`.
171+
// An orchestrator hit that after 375 turns. --settings merges over the
172+
// person's own settings, so their other plugins stay on.
173+
const claudeTurnSettings = `{"enabledPlugins":{"codex@openai-codex":false}}`
174+
165175
func (claudeAdapter) Args(t Turn) []string {
166176
mode := "bypassPermissions"
167177
if t.guarded() {
168178
mode = "auto"
169179
}
170-
args := []string{"-p", "--output-format", "stream-json", "--verbose", "--permission-mode", mode}
180+
args := []string{"-p", "--output-format", "stream-json", "--verbose", "--permission-mode", mode, "--settings", claudeTurnSettings}
171181
if t.Resume != "" {
172182
args = append(args, "--resume", t.Resume)
173183
} else if t.NewID != "" {

‎internal/connector/runner/adapter_test.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ func TestPiStream(t *testing.T) {
113113

114114
func TestATurnsArgumentsNeverCarryThePromptAndAlwaysTurnPromptsOff(t *testing.T) {
115115
spec := Spec{Model: "m", Effort: "high"}
116-
assert.Equal(t, []string{"-p", "--output-format", "stream-json", "--verbose", "--permission-mode", "bypassPermissions", "--session-id", "new", "--model", "m", "--effort", "high"},
116+
assert.Equal(t, []string{"-p", "--output-format", "stream-json", "--verbose", "--permission-mode", "bypassPermissions", "--settings", claudeTurnSettings, "--session-id", "new", "--model", "m", "--effort", "high"},
117117
claudeAdapter{}.Args(Turn{Role: RoleWorker, Spec: spec, NewID: "new"}))
118118
// The orchestrator's own monitor and subagents are the connector's here.
119-
assert.Equal(t, []string{"-p", "--output-format", "stream-json", "--verbose", "--permission-mode", "bypassPermissions", "--resume", "old", "--disallowedTools", "Task,Agent,Monitor"},
119+
assert.Equal(t, []string{"-p", "--output-format", "stream-json", "--verbose", "--permission-mode", "bypassPermissions", "--settings", claudeTurnSettings, "--resume", "old", "--disallowedTools", "Task,Agent,Monitor"},
120120
claudeAdapter{}.Args(Turn{Role: RoleOrchestrator, Resume: "old", NewID: "ignored"}))
121121
assert.Equal(t, []string{"exec", "--json", "--skip-git-repo-check", "--dangerously-bypass-approvals-and-sandbox", "-m", "m", "-c", `model_reasoning_effort="high"`, "-"},
122122
codexAdapter{}.Args(Turn{Spec: spec}))
@@ -130,7 +130,7 @@ func TestATurnsArgumentsNeverCarryThePromptAndAlwaysTurnPromptsOff(t *testing.T)
130130
// Claude Code in its auto mode, Codex in its sandbox with the network on
131131
// and the directories it is given. Pi has none to start under.
132132
guarded := Turn{Role: RoleWorker, NewID: "new", Permissions: PermissionsGuarded}
133-
assert.Equal(t, []string{"-p", "--output-format", "stream-json", "--verbose", "--permission-mode", "auto", "--session-id", "new"}, claudeAdapter{}.Args(guarded))
133+
assert.Equal(t, []string{"-p", "--output-format", "stream-json", "--verbose", "--permission-mode", "auto", "--settings", claudeTurnSettings, "--session-id", "new"}, claudeAdapter{}.Args(guarded))
134134
sandboxed := []string{"-c", `sandbox_mode="workspace-write"`, "-c", "sandbox_workspace_write.network_access=true", "-c", `approval_policy="on-request"`, "-c", `approvals_reviewer="auto_review"`}
135135
assert.Equal(t, slices.Concat([]string{"exec", "--json", "--skip-git-repo-check"}, sandboxed, []string{"-"}), codexAdapter{}.Args(guarded))
136136
guarded.Resume = "old"

0 commit comments

Comments
 (0)