Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(codex): never send an approval override on a remote resume (#811)

Gabriel Tavares Barbosaa7c3e3e01b9e
diff --git a/CLAUDE.md b/CLAUDE.md
index b686a7f07..388a18ca5 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -709,6 +709,29 @@ Lifecycle, by intent:
isolated in `server/codex-shared-identity.ts` and behavior-tested. The old Server Edition
"deliberate plain Codex" answer bypassed the launcher entirely, so a reconnect implementation in
the launcher could be perfectly green while every headless pane still fell back to its shell.
+ **No approval override ever rides that remote resume** (issue #811). MEASURED on
+ `codex-cli 0.154.0` against a real thread on a running shared app-server, under a pty:
+ `codex --remote unix:// resume <thread> --ask-for-approval on-request` answers
+ `Error: Permission overrides are not supported when resuming a remote task.` and exits 1 —
+ `on-request` being that build's own default policy and a member of its enum, so this is **not**
+ the missing `untrusted` of #785. The same command with the flag removed resumes and the TUI stays
+ up, and `-c approval_policy=never` is refused identically: the rule is about the OVERRIDE, not
+ about a value or a spelling, so there is no mapping of `manual`/`auto`/`bypassPermissions` that
+ survives this path and nothing to decide. Since `withPermissionMode` appends the flag to every
+ agent launch, every shared-identity Codex node died on its first turn at a bare shell.
+ `nt_run_shared` therefore strips `--ask-for-approval`/`-a` (both the spaced and the `=` form)
+ from the first-launch argv. **The strip is in the LAUNCHER, not in the TypeScript that builds the
+ line, and that placement is the invariant**: every identity-setup failure above it ends in
+ `exec codex "$@"` — plain codex, no `--remote` — where 0.154 still accepts the flag, so
+ suppressing it one layer up would take the permission mode away from exactly the nodes that could
+ not get a managed identity. The `else` branch has always resumed with no caller options at all,
+ so this only makes the first launch agree with the recovery beside it; the cost on an older codex
+ that still accepts the flag on a resume is that the mode is not applied on the managed path, which
+ after the first daemon reset was already true. **There is deliberately no capability gate**: the
+ refusal is a runtime check, absent from `--help`, so `codexCliSupportsRemote`'s shape does not
+ transfer — and it fires AFTER the session lookup, so a throwaway thread id answers "no saved
+ session" with or without the flag. Probing costs a real resumable thread, which is the thing being
+ launched.
- **"Restart agent (resume)"** → deliberately NOT a session lifecycle event: `terminal/
agent-restart.ts` restarts the agent CLI *inside* the pane and leaves the PTY, the tmux session
and its scrollback untouched. It exists for **new-model pickup** — a freshly released model only
diff --git a/src/core/codex-identity-proxy.ts b/src/core/codex-identity-proxy.ts
index 9e380b6fa..2aae87539 100644
--- a/src/core/codex-identity-proxy.ts
+++ b/src/core/codex-identity-proxy.ts
@@ -750,6 +750,58 @@ nt_run_shared() {
nt_first_launch=1
nt_rapid_resets=0
+ # An approval OVERRIDE is refused on a remote resume, whatever its value:
+ #
+ # codex --remote unix:// resume <thread> --ask-for-approval on-request
+ # Error: Permission overrides are not supported when resuming a remote task.
+ #
+ # MEASURED on codex-cli 0.154.0 (macOS 27.0, arm64) against a real thread on a running shared
+ # app-server, under a pty. \`on-request\` is in that build's own enum and is its default policy,
+ # and it dies exactly like \`never\`; the same command with the flag REMOVED resumes and the TUI
+ # stays up; and \`-c approval_policy=never\` is refused identically. So the rule is about the
+ # override, not about a value or a spelling, and there is no mapping of \`manual\`/\`auto\`/
+ # \`bypassPermissions\` that survives this path. nodeterm appends the flag through
+ # \`approvalFlags\` (src/shared/agents/approval-mode.ts), so every shared-identity Codex node
+ # reached this line carrying it and died on its first turn, leaving the pane at a bare shell
+ # (issue #811).
+ #
+ # Stripped HERE rather than in the TypeScript that builds the launch line, because the flag is
+ # still valid on this script's OTHER exit: every identity-setup failure above ends in
+ # \`exec codex "$@"\` — plain codex, no \`--remote\` — where 0.154 accepts it
+ # (\`codex --ask-for-approval never --version\` prints the version). Suppressing it one layer up
+ # would take the permission mode away from exactly the nodes that could not get a managed
+ # identity, against this launcher's own rule that such a node must still be a working node.
+ #
+ # The \`else\` branch below has always resumed with NO caller options, so "a remote resume
+ # carrying no approval flag" is behaviour this launcher already ships — this only makes the first
+ # launch agree with the recovery sitting beside it. On an older codex that still accepts the flag
+ # on a resume the cost is that the mode is not applied on the managed path, which after the first
+ # daemon reset was already true. There is deliberately no capability gate: the refusal is a
+ # runtime check (absent from \`--help\`, so \`codexCliSupportsRemote\`'s shape does not transfer)
+ # and it fires AFTER the session lookup, so a throwaway thread id answers "no saved session"
+ # whether or not the flag is present — probing costs a real resumable thread, which is the thing
+ # we are trying to launch.
+ #
+ # Both spellings and both forms, because a user's \`settings.agentLaunchCommands\` wrapper may
+ # spell the flag itself (\`withPermissionMode\` then suppresses ours and lets theirs through).
+ # Rebuilt by rotating the positional list, which is the only way sh can edit "$@" without an array.
+ nt_drop_next=0
+ nt_left=$#
+ while [ "$nt_left" -gt 0 ]; do
+ nt_arg=$1
+ shift
+ nt_left=$((nt_left - 1))
+ if [ "$nt_drop_next" -eq 1 ]; then
+ nt_drop_next=0
+ continue
+ fi
+ case "$nt_arg" in
+ --ask-for-approval|-a) nt_drop_next=1; continue ;;
+ --ask-for-approval=*|-a=*) continue ;;
+ esac
+ set -- "$@" "$nt_arg"
+ done
+
while :; do
nt_generation_before=$(nt_app_server_generation) || nt_generation_before=''
nt_run_started=$(nt_epoch)
diff --git a/src/core/codex-launcher-sh.test.ts b/src/core/codex-launcher-sh.test.ts
index 8687c0f86..28c2ef208 100644
--- a/src/core/codex-launcher-sh.test.ts
+++ b/src/core/codex-launcher-sh.test.ts
@@ -243,11 +243,13 @@ describe('generated Codex launcher', () => {
expect(fallbacks.map((f) => f.reason)).toContain('hook-endpoint-unavailable')
})
- it('keeps the caller arguments after the thread it resolved', async () => {
+ // The prompt and every other caller option still ride the first launch. The approval override is
+ // the one exception, and it has its own describe block below — this assertion used to carry
+ // `--ask-for-approval never` through to the resume, which is exactly the launch #811 measured
+ // dying at its first turn.
+ it('keeps the caller arguments after the thread it resolved, minus the approval override', async () => {
await callLauncher(['--ask-for-approval', 'never', 'fix the bug'])
- expect(codexArgv()).toEqual([
- '--remote unix:// resume thread-abc --ask-for-approval never fix the bug'
- ])
+ expect(codexArgv()).toEqual(['--remote unix:// resume thread-abc fix the bug'])
})
it('binds a caller-supplied thread on resume instead of starting a new one', async () => {
@@ -293,8 +295,11 @@ describe('generated Codex launcher', () => {
recovering
)
+ // First launch carries the prompt (minus the approval override, #811); the recovery resume
+ // carries nothing at all, which is the pre-existing rule this fix made the first launch agree
+ // with.
expect(codexArgv()).toEqual([
- '--remote unix:// resume thread-abc --ask-for-approval never fix the bug',
+ '--remote unix:// resume thread-abc fix the bug',
'--remote unix:// resume thread-abc'
])
expect(started).toEqual([{ nodeId: 'node-1', cwd: fs.realpathSync(dir) }])
@@ -709,3 +714,63 @@ describe('the pane agent id reaches the record', () => {
expect(fallbacks).toEqual([])
})
})
+
+// Issue #811. `codex-cli 0.154.0` refuses an approval OVERRIDE on a remote resume whatever its
+// value — MEASURED against a real thread on a running shared app-server, under a pty:
+//
+// codex --remote unix:// resume <thread> --ask-for-approval on-request
+// Error: Permission overrides are not supported when resuming a remote task.
+//
+// `on-request` is in that build's own enum and is its default policy, so this is not the missing
+// `untrusted` of #785; the same command with the flag removed resumes and the TUI stays up, and
+// `-c approval_policy=never` is refused identically. nodeterm appends the flag from `approvalFlags`
+// and this launcher forwarded it into the resume, so every shared-identity Codex node died on its
+// first turn and the pane fell back to a bare shell.
+//
+// The cases below run the generated shell for real, because "was the flag removed and everything
+// else kept, on the resume but NOT on the fallback?" is the whole fix and a string assertion on the
+// script cannot answer it.
+describe('the approval override never rides a remote resume (#811)', () => {
+ it('drops `--ask-for-approval <value>` and keeps the rest', async () => {
+ await callLauncher(['--model', 'gpt-5', '--ask-for-approval', 'on-request', 'fix the bug'])
+ expect(codexArgv()).toEqual(['--remote unix:// resume thread-abc --model gpt-5 fix the bug'])
+ })
+
+ it('drops the short spelling and the `=` forms a wrapper may use', async () => {
+ // `withPermissionMode` leaves a command alone when it already spells the flag (#601), so a
+ // user's `settings.agentLaunchCommands` wrapper is how these reach the launcher.
+ await callLauncher(['-a', 'never', 'one'])
+ await callLauncher(['--ask-for-approval=never', 'two'])
+ await callLauncher(['-a=never', 'three'])
+ expect(codexArgv()).toEqual([
+ '--remote unix:// resume thread-abc one',
+ '--remote unix:// resume thread-abc two',
+ '--remote unix:// resume thread-abc three'
+ ])
+ })
+
+ it('drops it from a caller-supplied resume too', async () => {
+ await callLauncher(['resume', 'thread-xyz', '--ask-for-approval', 'never'])
+ expect(bound).toEqual([{ nodeId: 'node-1', threadId: 'thread-xyz' }])
+ expect(codexArgv()).toEqual(['--remote unix:// resume thread-xyz'])
+ })
+
+ it('does not eat a value-less trailing flag\'s neighbour', async () => {
+ await callLauncher(['fix the bug', '--ask-for-approval'])
+ expect(codexArgv()).toEqual(['--remote unix:// resume thread-abc fix the bug'])
+ })
+
+ // The other exit. Every identity-setup failure ends in `exec codex "$@"` — plain codex, no
+ // `--remote` — and 0.154 accepts the flag there (`codex --ask-for-approval never --version`
+ // prints the version). Suppressing it in the TypeScript that builds the launch line would take
+ // the permission mode away from exactly the nodes that could not get a managed identity, against
+ // this launcher's own rule that such a node must still be a working node. This is the assertion
+ // that makes the strip's PLACEMENT load-bearing rather than incidental.
+ it('keeps the flag on the plain-codex fallback', async () => {
+ await callLauncher(['--ask-for-approval', 'never', 'fix the bug'], {
+ NODETERM_HOOK_ENDPOINT: '/nonexistent/hook-endpoint.env'
+ })
+ expect(codexArgv()).toEqual(['--ask-for-approval never fix the bug'])
+ expect(fallbacks.map((f) => f.reason)).toContain('hook-endpoint-unavailable')
+ })
+})