paperclip/packages/adapters/codex-local/src/server
Devin Foley ee9d907d01
fix(codex): do not inject a duplicate --skip-git-repo-check for sandbox runs (#10595)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - A Codex agent runs `codex exec`, and the adapter assembles its
argument vector from the agent's config plus execution-context options
> - For sandbox execution the adapter injects `--skip-git-repo-check`,
because a headless remote workspace has no git trust prompt to answer
> - The adapter also appends the operator's `extraArgs` verbatim, so an
agent that already lists `--skip-git-repo-check` in its config gets the
flag twice on a sandbox run
> - `codex exec` rejects a repeated `--skip-git-repo-check` and exits
with code 2, which the adapter surfaces as `adapter_failed` before any
work runs
> - This pull request skips the sandbox injection when the operator's
args already carry the flag
> - The benefit is that a common, harmless-looking config no longer
crashes every sandbox run

## Linked Issues or Issue Description

**What happened?**

A `codex_local` agent configured with `extraArgs:
["--skip-git-repo-check"]` fails on every sandbox run:

```
error: the argument '--skip-git-repo-check' cannot be used multiple times

Usage: codex exec [OPTIONS] [PROMPT]
```

The adapter reports `stopReason: "adapter_failed"` (Codex exited with
code 2). The flag appears twice in the argv: once injected by the
adapter for sandbox execution, once from the operator's `extraArgs`.

**Steps to reproduce**

1. Configure a `codex_local` agent with `extraArgs:
["--skip-git-repo-check"]` (or the legacy `args` field).
2. Point it at a sandbox environment.
3. Start a run — `codex exec` aborts immediately on the duplicate flag.

**Expected behavior**

The run launches with a single `--skip-git-repo-check`. An operator
listing the flag the adapter already injects should be a no-op, not a
hard failure.

**Paperclip version**

Current `master`.

**Deployment mode**

Any deployment running Codex agents in sandbox environments.

## What Changed

- `buildCodexExecArgs` no longer pushes the sandbox
`--skip-git-repo-check` when the resolved args (`extraArgs`, or the
legacy `args` fallback) already contain it. The operator's copy stands;
the argv carries the flag exactly once. Non-sandbox runs and configs
without the flag are unchanged.

## Verification

- `cd packages/adapters/codex-local && pnpm vitest run
src/server/codex-args.test.ts` — new cases: `extraArgs` already carrying
the flag (single occurrence), the legacy `args` field carrying it
(single occurrence), and the operator's flag preserved when the sandbox
injection is not requested. Existing "adds --skip-git-repo-check when
requested" case unchanged.
- `cd packages/adapters/codex-local && pnpm vitest run` — full package
suite (218 tests).
- `pnpm run typecheck` in the package.

## Risks

- Low. The change only suppresses a duplicate of a single, idempotent
flag; it never removes an operator-supplied argument and never adds one
that was not already going to be present.

## Model Used

Claude Fable 5 (`claude-fable-5`, Anthropic) via Claude Code — extended
thinking, agentic tool use (file edits, vitest/tsc runs). No other
models involved.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
2026-07-31 20:37:51 -07:00
..
acp.test.ts fix(codex-local): resolve GPT-5.6 model metadata at source (#9780) 2026-07-28 16:15:08 -05:00
acp.ts fix(codex-local): resolve GPT-5.6 model metadata at source (#9780) 2026-07-28 16:15:08 -05:00
auth-precedence.test.ts fix(codex): warn when sandbox auth is shadowed (#9259) 2026-07-15 10:02:28 -07:00
auth-precedence.ts fix(codex): warn when sandbox auth is shadowed (#9259) 2026-07-15 10:02:28 -07:00
codex-args.test.ts fix(codex): do not inject a duplicate --skip-git-repo-check for sandbox runs (#10595) 2026-07-31 20:37:51 -07:00
codex-args.ts fix(codex): do not inject a duplicate --skip-git-repo-check for sandbox runs (#10595) 2026-07-31 20:37:51 -07:00
codex-auth-copyback.test.ts fix(runtime): support in-place workspace realization (#10230) 2026-07-25 08:29:26 -05:00
codex-auth-copyback.ts fix(runtime): support in-place workspace realization (#10230) 2026-07-25 08:29:26 -05:00
codex-auth-merge-decision.cjs feat(codex-local): add outbound direction to codex-auth-merge decision predicate (#9787) 2026-07-17 16:18:39 -05:00
codex-auth-merge-extract.sh fix(codex): let sandbox runs use the sandbox image's own Codex login (#10582) 2026-07-31 18:36:36 -07:00
codex-auth-merge-scripts.ts feat(sandbox-runtime): route all inbound staging through client.syncIn (Codex home -> native uploadFiles; delete usesCustomProvision gate) (#10354) 2026-07-28 07:22:18 -07:00
codex-auth-merge.test.ts fix(codex): let sandbox runs use the sandbox image's own Codex login (#10582) 2026-07-31 18:36:36 -07:00
codex-home.test.ts refactor(codex-local): stage an allowlist for sandbox CODEX_HOME sync (#9972) 2026-07-21 19:50:21 -07:00
codex-home.ts refactor(codex-local): stage an allowlist for sandbox CODEX_HOME sync (#9972) 2026-07-21 19:50:21 -07:00
config-schema.ts Make ACP the default engine for local adapters (#9238) 2026-07-08 19:05:03 -07:00
execute.acp-fallback.test.ts Make ACP the default engine for local adapters (#9238) 2026-07-08 19:05:03 -07:00
execute.auth-precedence.test.ts refactor(codex-local): stage an allowlist for sandbox CODEX_HOME sync (#9972) 2026-07-21 19:50:21 -07:00
execute.auth.test.ts fix(codex): let sandbox runs use the sandbox image's own Codex login (#10582) 2026-07-31 18:36:36 -07:00
execute.remote.test.ts fix(runtime): support in-place workspace realization (#10230) 2026-07-25 08:29:26 -05:00
execute.test.ts feat(codex-local): outbound auth copy-back as home-asset restore contribution (#9788) 2026-07-18 09:13:45 -05:00
execute.ts fix(codex): let sandbox runs use the sandbox image's own Codex login (#10582) 2026-07-31 18:36:36 -07:00
index.ts fix(codex): classify mid-turn harness crashes structurally as retriable infra (#10210) 2026-07-24 16:40:47 -05:00
output-inactivity-monitor.integration.test.ts fix(codex): preserve silent active builds (#10153) 2026-07-24 15:27:24 -05:00
output-inactivity-monitor.test.ts fix(codex): preserve silent active builds (#10153) 2026-07-24 15:27:24 -05:00
output-inactivity-monitor.ts fix(codex): preserve silent active builds (#10153) 2026-07-24 15:27:24 -05:00
parse.test.ts fix(codex): classify mid-turn harness crashes structurally as retriable infra (#10210) 2026-07-24 16:40:47 -05:00
parse.ts fix(codex): classify mid-turn harness crashes structurally as retriable infra (#10210) 2026-07-24 16:40:47 -05:00
process-activity-monitor.test.ts fix(codex): preserve silent active builds (#10153) 2026-07-24 15:27:24 -05:00
process-activity-monitor.ts fix(codex): preserve silent active builds (#10153) 2026-07-24 15:27:24 -05:00
quota-spawn-error.test.ts fix(codex): classify refresh auth failures (#9598) 2026-07-14 22:40:38 -07:00
quota.ts fix(codex): classify refresh auth failures (#9598) 2026-07-14 22:40:38 -07:00
runtime-config.test.ts feat(codex-local): env-driven gateway routing via PAPERCLIP_CODEX_PROVIDERS config.toml (#7919) 2026-06-10 21:13:31 -07:00
runtime-config.ts feat(codex-local): env-driven gateway routing via PAPERCLIP_CODEX_PROVIDERS config.toml (#7919) 2026-06-10 21:13:31 -07:00
skills.ts [codex] Add skills CLI and catalog management (#6782) 2026-05-28 07:33:51 -10:00
test.remote.test.ts Make ACP the default engine for local adapters (#9238) 2026-07-08 19:05:03 -07:00
test.ts Make ACP the default engine for local adapters (#9238) 2026-07-08 19:05:03 -07:00