Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion internal/connector/runner/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,22 @@ func (claudeAdapter) NewSessionID() string { return newUUID() }
// runs the ones it finds safe and stops the rest, with no prompt.
func (claudeAdapter) Guarded() bool { return true }

// claudeTurnSettings turns off, for the connector's turns only, plugins that
// break a session the connector continues for days. OpenAI's Codex plugin
// appends its exports to the session's env file on every SessionStart, and a
// resume is one, so every turn adds a copy. Claude Code inlines that file
// into each Bash command's single `bash -c` argument, and past Linux's 128 KiB
// limit on one argument (MAX_ARG_STRLEN) no command starts, not even `echo`.
// An orchestrator hit that after 375 turns. --settings merges over the
// person's own settings, so their other plugins stay on.
const claudeTurnSettings = `{"enabledPlugins":{"codex@openai-codex":false}}`

func (claudeAdapter) Args(t Turn) []string {
mode := "bypassPermissions"
if t.guarded() {
mode = "auto"
}
args := []string{"-p", "--output-format", "stream-json", "--verbose", "--permission-mode", mode}
args := []string{"-p", "--output-format", "stream-json", "--verbose", "--permission-mode", mode, "--settings", claudeTurnSettings}
if t.Resume != "" {
args = append(args, "--resume", t.Resume)
} else if t.NewID != "" {
Expand Down
6 changes: 3 additions & 3 deletions internal/connector/runner/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ func TestPiStream(t *testing.T) {

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