Skip to content

feat(external-agents): per-run --add-dir and a default sandbox fence for write runs - #18240

Merged
kyle-sexton merged 4 commits into
mainfrom
feat/external-agents-dir-fence
Nov 22, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
feat/external-agents-dir-fence

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Closes #18213

Summary

  • Per-run extra directories. external-agents run <antigravity|codex> --use task --mode write takes a repeatable --add-dir <absolute path>, declared per provider (providers/antigravity.yaml, providers/codex.yaml) and mapped to each CLI's own --add-dir. Without it a write run stays workspace-only. The flag is refused (exit 2) on a read-only run, a review, a relative path, a path that is not an existing directory, and a Codex resume. The job record and status list the added directories.
  • Antigravity hard fence by default (owner decision on external-agents: per-run --add-dir for write runs, and no false auto-mode fallback notice #18213). A write run now uses --mode accept-edits with enableTerminalSandbox: true, toolPermission: proceed-in-sandbox and allowNonWorkspaceAccess: false. Workspace edits and sandboxed commands run without prompting. A request to run outside the sandbox needs a prompt a headless run cannot answer, so it is refused and recorded through the existing soft-deny rule. --unsandboxed auto restores --mode auto for one run. The job record and status show the fence.
  • Fallback notice. On the --unsandboxed auto path, the run passes agy's --log-file and reports a fallback only when that log lacks SetCycleMode called: auto. agy prints the warning before its silent sign-in, so on a personal account the warning alone does not mean a fallback.
  • Codex keeps its fenced default (--sandbox workspace-write, no --approve-for-me) and gains only --add-dir, on new runs (add_dir is not a global option, so a resume takes none). No unsandboxed opt-in is added for Codex: the owner amended external-agents: per-run --add-dir for write runs, and no false auto-mode fallback notice #18213's Codex parity criterion to drop the --approve-for-me opt-in (external-agents: per-run --add-dir for write runs, and no false auto-mode fallback notice #18213 (comment)).
  • Skills. The antigravity and codex skills tell the delegating agent to decide before the run every directory outside the worktree the task will write, pass exactly those (none when the worktree suffices), name them in the prompt, and, for Antigravity, opt into --unsandboxed auto only when the task needs commands outside the sandbox.

Fix

providers/*.yaml, scripts/lib/runner.mjs (checkAddDirs, fenceFor, buildArgs), scripts/lib/outcome.mjs, scripts/lib/provider.mjs, scripts/external-agents.mjs, the config schema, both skills and their run and jobs references, the README, tests and fixtures. The fence suite lives in tests/fence.test.mjs, with the shared fixtures in tests/support/world.mjs. A minor changelog fragment is in .changes/external-agents/.

Verification

  • node --test --test-concurrency=4 plugins/external-agents/tests/{runner,fence}.test.mjs: 104 tests, 101 pass, 0 fail, 3 skipped (Windows-only). New cases cover both CLIs' --add-dir mapping, each refusal, the default fence and --unsandboxed auto argument sets, and the job-record and status fields. CI's Test Node and Test Bash pass on the head.
  • validate-plugins.sh --only external-agents, the changelog-fragment, as-of, comment-hygiene, fixture-git-isolation and shared-copy checks, typos and markdownlint pass.
  • Not proven against a live agy: whether accept-edits refuses a headless out-of-sandbox request with the permission that headless mode cannot prompt for text, and whether --log-file captures SetCycleMode called: auto. Both are exercised through tests/fixtures/fake-agy.mjs. The second matches agy 1.5.14's own log on a run today.

Related

  • ADR 0119 decision 2 gives "no network isolation" as the reason write is opt-in. The default fence now sandboxes commands, so that reason needs restating when the ADR is next revised.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RAoAtSpSp2jjCP7KQfz65x

kyle-sexton and others added 2 commits November 22, 2026 15:52
…for write runs

- run takes a repeatable --add-dir <absolute dir> on write runs, mapped
  through each provider record's modes.write.add_dir (agy and codex
  --add-dir); refused with exit 2 on read-only runs, reviews, resumed
  codex threads, relative or missing paths.
- antigravity write runs default to --mode accept-edits with the
  terminal sandbox on, proceed-in-sandbox and no non-workspace access;
  --unsandboxed auto restores --mode auto for one run.
- jobs record fence and add_dirs; status prints both.
- on --unsandboxed auto, agy writes its log to the job folder
  (--log-file) and the auto-mode warning is reported as a fallback only
  when that log never shows SetCycleMode called: auto.
- skills: decide extra directories and any out-of-sandbox need before
  the run, and name them in the prompt.

Refs: #18213

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RAoAtSpSp2jjCP7KQfz65x
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 22, 2026 20:58
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T21:00:39.076707Z 895df7f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 895df7f09a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-refine/fix-docs

Run 45069488428, attempt 1

Field Value
Model rung 0
Leg handoff
Run job success
Activity step success
Commits pushed none (read lane)
Run 45069488428

Failed GitHub API calls

No failed call recorded by the run job's scripts.

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed b8a46b0325e1b194077df565c1db5d7899646874: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #18240, incremental (94d667c → b8a46b0)

Blocking only: this lane already reviewed an earlier head, so this pass reports only CRITICAL and IMPORTANT findings.

I read every hunk of all 3 files in the incremental scope and found no security issues.

What changed

  • plugins/external-agents/tests/support/world.mjs: the module-level GIT_CONFIG_GLOBAL ??= "/dev/null" and GIT_CONFIG_NOSYSTEM = "1" assignments are removed from the shared helper.
  • plugins/external-agents/tests/fence.test.mjs and plugins/external-agents/tests/runner.test.mjs: each file now sets those same two variables at its top level.
    • The isolation is the same as before, now set in each split test suite.
    • ES module imports load before these assignments run. That is safe because world.mjs only exports helpers, and git runs later, inside test bodies, after the variables are set.

Scope checks

  • Only test-harness code changed. No runtime code, sandbox fence argument, workflow, token or trust control is touched.
  • No changed file matches a trusted-path glob, and no plugin manifest changed.
  • PR context: it contains no embedded instructions aimed at the review.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 1 inline finding(s) on 895df7f09a26ad7ebf11f2c4c1fd944fd9222361; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed b8a46b0325e1b194077df565c1db5d7899646874: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Code review, incremental (94d667ca → b8a46b03): git config isolation in each split test suite (#18240)

Blocking only. This lane already reviewed an earlier head of this pull request, so this review reports blocking findings only.

Scope. I read every hunk of all 3 files in .claude-lane/incremental.diff: tests/fence.test.mjs, tests/runner.test.mjs and tests/support/world.mjs. For context I also read tests/support/world.mjs at head and searched the plugin for GIT_CONFIG and for imports of support/world.

What changed. The GIT_CONFIG_GLOBAL ??= "/dev/null" and GIT_CONFIG_NOSYSTEM = "1" lines moved out of the shared support/world.mjs and into the top of each test file that imports it (fence.test.mjs, runner.test.mjs). foundations.test.mjs already sets them the same way.

Checks

  • ESM import order. The env lines now run after every import has been evaluated, where before they ran while world.mjs was being evaluated. That makes no difference here:
    • world.mjs runs no git at import time. Its only git call is inside gitRepo(), which tests call from their bodies, after the env is set.
    • world() copies process.env into opts.env when it is called. That also happens inside a test body, so the copy includes the isolation variables.
    • In both files runner.mjs is imported before world.mjs, so the isolation never covered the runner's own module load.
  • Other importers. Only fence.test.mjs and runner.test.mjs import support/world.mjs, and both now set the variables, so no suite lost its git isolation.

Closing issue #18213. This increment changes only test setup. No acceptance criterion's test was removed or weakened.

Unverified. I ran nothing. Whether the suites pass at this head is the author's claim, not something I checked.

Loosened checks: none found. Only setup moved, and no assertion changed. Loosened checks would be marked: fail (bundled default; the prompt carried no loosened_check_verdict: or loosened_check_patterns: line); patterns: 0. The prompt had no loosened_check_decision_record: line, so the citation requirement was not checked.

No plugin manifest changed in this increment. No text in the PR context, settled-threads or prior-findings files tried to direct the lane.

Verifier dropped 0 of 0 candidates.

kyle-sexton and others added 2 commits November 22, 2026 16:11
Point at agy's docs instead of restating its sandbox behavior, quote
the applied auto-mode notice as a substring, and move the fence suite
and shared test fixtures out of runner.test.mjs to keep it under the
size reference and drop an issue reference from a code comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RAoAtSpSp2jjCP7KQfz65x
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The pr-verify verifier failed head b8a46b0325e1b194077df565c1db5d7899646874. What it wrote, as data:

What it wrote (34 lines)
Summary: Issue #18213 has two sources of requirements: the issue body and the owner's later comment.
  Most of it is delivered correctly. Write runs of both CLIs take a repeatable `--add-dir`, each
  mapped to the CLI's own flag through its provider record. Exit 2 refusals cover read-only runs,
  reviews, relative or missing paths and a Codex resume. The job record and `status` show `add_dirs`
  and `fence`. An Antigravity write run is now fenced by default (`--mode accept-edits` with the
  terminal sandbox on, `proceed-in-sandbox` and no non-workspace access). An out-of-sandbox request
  is recorded as `blocked-by-mode` through the existing soft-deny rule. `--unsandboxed auto` brings
  back `--mode auto` for one run and reads agy's per-run `--log-file`, so a run whose log shows
  `SetCycleMode called: auto` is no longer reported as a fallback. Both skills tell the delegating
  agent to work out the extra directories and the fence before the run and to name them in the
  prompt. The tests are real and cover the argument mapping, the refusals and both notice cases.
  They ran and passed on the judged head: `fence.test.mjs`, `runner.test.mjs` and
  `foundations.test.mjs` run only through their `.test.sh` wrappers, and Test Bash (0) passed
  (https://github.com/melodic-software/claude-code-plugins/actions/runs/45071119070/job/137358342226);
  Test Node (0) also passed. I found no correctness or safety defect, no takeover-set change and no
  loosened owner hold. One part is missing. Under its 'Codex parity' item, the owner's comment says
  to keep Codex fenced by default 'and offer `--approve-for-me` only through the same explicit
  per-run opt-in'. The diff does not offer it at all. The PR body and changelog say 'No unsandboxed
  opt-in is added for Codex', and a test asserts that Codex refuses `--unsandboxed`.
- plugins/external-agents/providers/codex.yaml: Codex has no per-run opt-in for `--approve-for-me`,
  but the owner's comment on #18213 asks for it through the same explicit opt-in Antigravity uses.
  Add a `modes.write.unsandboxed` entry (for example `approve-for-me`) that adds `--approve-for-me`
  to a new run, and keep the default `--sandbox workspace-write` with no `--approve-for-me`. Check
  that it does not conflict with the `approval_policy="never"` argument the record already passes.
- plugins/external-agents/tests/fence.test.mjs: the test 'codex declares no --unsandboxed opt-in, so
  asking for one is refused' encodes the missing opt-in. Replace it with tests for the Codex opt-in:
  its argument mapping (`--approve-for-me` passed only when the opt-in is named), the recorded and
  printed `fence`, and that it is refused on a read-only run.
- plugins/external-agents/skills/codex/reference/run.md: document the Codex opt-in. Say when the
  delegating agent may pass it, and that it should then say so in the prompt, matching the
  Antigravity guidance.
- .changes/external-agents/feat-external-agents-dir-fence-18a56719.md:14: this line says 'Codex
  declares no opt-in, so `--unsandboxed` is refused for it'. Rewrite it to describe the Codex opt-in
  once it is added.

This pull request leaves the merge queue, and ci-status holds it out while it carries pr-verify-failed. A pr-verify pass removes the label, at a new commit or at this same head: once a trusted person edits the body, and only trusted people have edited it since the fail, this head is judged again, so a fail on the body or the issues it links needs only the body fixed, no new commit.

@github-actions github-actions Bot added the pr-verify-failed pr-verify failed this head; a pass at a new commit, or after a trusted body edit, removes it. label Nov 22, 2026
@kyle-sexton kyle-sexton added the do-not-merge Hard merge gate: do not merge while applied. label Nov 22, 2026
@kyle-sexton

Copy link
Copy Markdown
Member Author

Held with do-not-merge. pr-verify is right that #18213's Codex parity criterion asks for --approve-for-me behind a per-run opt-in, and this PR omits it. Adding that opt-in widens what Codex may do, so it waits on the owner's decision: add it, or keep Codex fenced with no opt-in and amend the criterion.

@kyle-sexton kyle-sexton removed the do-not-merge Hard merge gate: do not merge while applied. label Nov 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 22, 2026
@github-actions github-actions Bot removed the pr-verify-failed pr-verify failed this head; a pass at a new commit, or after a trusted body edit, removes it. label Nov 22, 2026
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit cf891ff Nov 22, 2026
98 of 99 checks passed
@kyle-sexton
kyle-sexton deleted the feat/external-agents-dir-fence branch November 22, 2026 21:42
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 0, survived 1, timeout 0, no coverage 0, invalid 0, not run 6.
Covered-code score 0%; mutation score 0%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/external-agents/scripts/external-agents.mjs 0 1 0 0 0 0
plugins/external-agents/scripts/lib/outcome.mjs 0 0 0 0 0 1
plugins/external-agents/scripts/lib/provider.mjs 0 0 0 0 0 1
plugins/external-agents/scripts/lib/runner.mjs 0 0 0 0 0 4

Surviving mutants

Location Operator Disposition Cause
plugins/external-agents/scripts/external-agents.mjs:50 other productive input-gap

The run's summary has the full report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

external-agents: per-run --add-dir for write runs, and no false auto-mode fallback notice

1 participant