Skip to content

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

Description

@kyle-sexton

User story

As an agent delegating a write task through /external-agents:antigravity or /external-agents:codex, I name up front the exact directories the task needs beyond its worktree, so the external agent can finish without a refused write and without broader access than the task needs.

Today a write run is always workspace-only:

  • Antigravity: providers/antigravity.yaml write mode sets allowNonWorkspaceAccess: false, and --add-dir is passed only for review.
  • Codex: providers/codex.yaml write mode passes --sandbox workspace-write only.

Both CLIs already accept extra writable directories: agy --add-dir ("Add a directory to the workspace (repeatable)", agy --help, 1.5.14) and codex exec --add-dir <DIR> ("Additional directories that should be writable alongside the primary workspace", codex exec --help, 0.169.1).

A second, smaller gap, found on agy 1.5.14: in headless print mode agy checks auto-mode availability before silent auth, so it prints --mode auto is not available for this account; continuing in the default mode, then switches to auto anyway. agy's own log (~/.gemini/antigravity-cli/log/cli-*.log) shows printmode.go:903 ... --mode auto is unavailable (rollout flag off), then silent auth succeeded, SetCycleMode called: auto, and auto mode: auto-approving file write. The plugin relays the first line as notice: the CLI warned: --mode auto is not available, so a correct auto-mode run reads like a fallback. This is an agy defect; the plugin only needs to stop presenting it as a fallback.

Acceptance criteria

  • external-agents run <antigravity|codex> --use task --mode write takes a repeatable --add-dir <absolute path>, mapped to each CLI's own flag (agy --add-dir, codex --add-dir). Without the flag, behavior is unchanged: workspace-only.
  • --add-dir is refused (exit 2) for read-only runs and for a path that does not exist, and every added directory is recorded in the job record and printed in external-agents status <job>.
  • The antigravity and codex skills tell the delegating agent to work out, before the run, every directory outside the worktree the task will write, pass exactly those, and pass none when the worktree suffices; the prompt names them too.
  • For Antigravity, a write run whose agy log for that run shows SetCycleMode called: auto after the fallback line is not reported as a fallback; the notice says auto mode was applied. A real fallback (no such line) keeps today's notice.
  • Tests cover both CLIs' argument mapping, the refusals, and both fallback-notice cases.

Affected area / component

plugins/external-agents: providers/antigravity.yaml, providers/codex.yaml, scripts/lib/runner.mjs, scripts/lib/outcome.mjs, skills/antigravity, skills/codex.

Owner decision (user, this session): per-run directories named up front by the delegating agent; worktree-only stays the default; no blanket non-workspace access.

Activity

  1. added
    needs-triage
    on Nov 22, 2026
  2. github-actions commented on Nov 22, 2026

    @github-actions
    Contributor

    Size: Medium
    Complexity: Medium
    Uncertainty: Known
    Flags: none
    Blocked by: none
    Blast radius: the external-agents plugin (antigravity and codex provider files, runner and outcome scripts, two skills, tests); read by agents that delegate write runs.
    Reversible: yes; revert the change. Without --add-dir, runs stay workspace-only.
    Open questions: none
    Understood: add a repeatable --add-dir <absolute path> to write runs for antigravity and codex, with refusals, job-record and status output, and skill guidance. Also stop the antigravity notice from reading as an auto-mode fallback when agy's log shows auto mode was applied. The design and done-when are exact. No duplicate or merged fix found; #18179 touches the antigravity breaker but is a different change.

    Automated triage. A maintainer reviews it.

  3. removed
    needs-triage
    on Nov 22, 2026
  4. melodic-automation-lanes commented on Nov 22, 2026

    @melodic-automation-lanes
    Contributor

    Not admitted to the issue lane: no trusted-human acceptance criteria: a listed human must put the confirmed - [ ] criteria in the body or post them as their own comment, or, on an issue a listed human filed, intake's newest refinement comment must hold them unedited. Admission takes the issue once each of those is met, when intake triages it again (.github/actions/resolve-config/admission-rules.json).

  5. kyle-sexton commented on Nov 22, 2026

    @kyle-sexton
    MemberAuthor

    Owner decision (this session): hard fence by default for Antigravity write runs.

    In auto mode, agy can ask to run a command outside its terminal sandbox, and its own safety check then lets "safe, reversible" commands run with full disk and network access (sandbox docs). The per-run --add-dir list fences only the sandbox, so it does not bound those commands. agy's log for a run today shows two such requests (a test script and shellcheck).

    Added acceptance criteria:

    • By default, a write run is fenced: --mode accept-edits with per-run settings enableTerminalSandbox: true, toolPermission: "proceed-in-sandbox" and allowNonWorkspaceAccess: false. Workspace edits and sandboxed commands run without prompting (modes, sandbox CLI configuration), and a request to run outside the sandbox needs a prompt, which a headless run cannot answer, so it is refused and recorded through the existing permission that headless mode cannot prompt for soft-deny rule.
    • external-agents run antigravity --use task --mode write takes an explicit opt-in (for example --unsandboxed auto) that restores today's --mode auto behavior for one run. The job record and status show which fence the run used.
    • The antigravity skill tells the delegating agent to decide before the run, with the directory list, whether the task needs any command outside the sandbox (network access, system services), to opt in only then, and to say so in the prompt.
    • Codex parity: the plugin runs codex exec --sandbox workspace-write and passes neither --approve-for-me ("Route approval requests through automatic review using the workspace-write sandbox", codex exec --help, 0.169.1) nor --dangerously-bypass-approvals-and-sandbox, and providers/codex.yaml already records declined command items. So Codex's default is already fenced. Keep it that way, and offer --approve-for-me only through the same explicit per-run opt-in. Codex otherwise needs only the --add-dir part.
    • Tests cover both fences' argument mapping and the refusal being recorded.
  6. added
    session-owned
    on Nov 22, 2026
  7. kyle-sexton commented on Nov 22, 2026

    @kyle-sexton
    MemberAuthor

    Owner decision (2026-11-22, in session, owner's words: "Sure, go with recommendations."): the Codex parity criterion is amended. Codex keeps its fenced default (codex exec --sandbox workspace-write, no --approve-for-me, no --dangerously-bypass-approvals-and-sandbox) and gets no per-run opt-in for --approve-for-me; it takes only --add-dir. Reason: no task needs Codex approvals today, the fenced default already serves write tasks, and the opt-in would add an escape path nobody uses. This supersedes "offer --approve-for-me only through the same explicit per-run opt-in" in #18213 (comment).

  8. kyle-sexton commented on Nov 22, 2026

    @kyle-sexton
    MemberAuthor

    Live check against real agy 1.5.14 on WSL, merged code from #18240:

    • Default fence: job fence sandbox, per-run settings {"enableTerminalSandbox":true,"toolPermission":"proceed-in-sandbox","allowNonWorkspaceAccess":false}. The workspace write landed; the one outside-sandbox command (curl -sI https://example.com) was auto-denied (a tool required the "command" permission that headless mode cannot prompt for, denied_actions: [{action: command}]) and the run recorded blocked-by-mode, exit 3.
    • --unsandboxed auto: job fence unsandboxed auto; agy's per-run log shows the --mode auto is unavailable warning then SetCycleMode called: auto, and the command reported the mode as applied, not a fallback. The workspace write landed, exit 0.
    • chezmoi status shows no drift on agy's settings.json after both runs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    session-owned

    Fields

    Work status

    confirmed

    Priority

    medium

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions