Repository navigation
Description
What version of Codex CLI is running?
Reproduced with the installed codex-cli 0.158.0 binary. Source trace checked against 88e9a8329d17bd141e4f3f0e7c78d07a7baa8b23 on main.
What subscription do you have?
The isolated reproduction uses a local mock Responses endpoint with requires_openai_auth = false. It does not require a subscription or make OpenAI API calls.
Which model were you using?
mock-model in the reproduction. The behavior occurs during thread restoration, independently of model output.
What platform is your computer?
Linux 6.17.0-1025-oem x86_64.
What terminal emulator and version are you using (if applicable)?
The isolated reproduction drives codex app-server over stdio, without a terminal emulator. The original symptom was observed in the CLI TUI using the shared daemon.
Codex doctor report
Not collected for this report. The reproduction uses a temporary CODEX_HOME, two isolated app-server processes, and a local mock endpoint. No production configuration or credentials are needed.
What issue are you seeing?
A thread started with the legacy permission fields used by CLI --yolo loses its full-access sandbox after app-server restart and an ID-only cold resume. The approval policy survives, producing never + workspace-write instead of never + danger-full-access.
Observed on the same installed 0.158.0 binary before and after restart:
| Stage | approvalPolicy | sandbox.type | activePermissionProfile |
|---|---|---|---|
| thread/start response | never | dangerFullAccess | null |
| Persisted turn_context | never | danger-full-access | null |
| Cold thread/resume response | never | workspaceWrite | null |
In the original TUI session, this followed:
Reconnected. No input was resent. Review uncertain submissions before retrying; recovered queues remain paused.
The recovered-queue pause is intentional and is not the bug. This report concerns the permission loss. The isolated reproduction confirms sandbox loss; it does not demonstrate a change from never to on-request.
What steps can reproduce the bug?
Use a temporary CODEX_HOME and a local mock Responses server. Do not restart a daemon serving real work.
-
Configure the isolated server with
approval_policy = "on-request",sandbox_mode = "workspace-write", and a mock provider withrequires_openai_auth = false. -
Start
codex app-serverover stdio and sendinitialize, theninitialized. -
Send
thread/startwith a temporary workspace and the legacy YOLO-equivalent fields:{"approvalPolicy":"never","sandbox":"danger-full-access"} -
Submit one
turn/startand let the mock provider return a short completed response. This is necessary to persist a resumable rollout; thread/start alone was insufficient. -
Verify the resulting
turn_contextcontainsapproval_policy = "never",sandbox_policy.type = "danger-full-access", and no active named permission profile. -
Close the first server cleanly. In the reproduction it exited with code 0.
-
Start a second instance of the same binary with the same temporary home and unchanged configuration. Initialize it, then send:
{"method":"thread/resume","params":{"threadId":"<saved-thread-id>","excludeTurns":true}} -
The response now reports
approvalPolicy = "never",sandbox.type = "workspaceWrite", andactivePermissionProfile = null.
No mobile handoff, manual CLI resume without --yolo, mixed client/server versions, or external model request is involved in this reproduction.
What is the expected behavior?
An automatic reconnect of a CLI launched with --yolo should preserve its explicit permission choice for subsequent input, unless the user changes that choice or host policy rejects it. Recovered queues should remain paused as they do today.
Additional information
The installed-binary experiment proves the app-server cold-resume transition. The connection to automatic TUI reconnect is established by the current source path:
startup_orchestration.rsmaps--yoloto the legacy sandbox and approval overrides.reconnect.rsusesPreserveExistingThread;app_server_session.rsconsequently sends only the thread ID.persisted_resume_settings.rsextracts approval settings and an active named profile, but not the legacy sandbox.thread_processor.rsrestores the profile ID when present.- The existing server test
cold_resume_without_active_permission_profile_uses_current_configexplicitly expects fallback to current configuration for legacy permissions. - The TUI can retain picker-selected runtime permissions, but
startup.rsinitializes both runtime permission overrides toNone, including for an explicit YOLO launch.
A focused TUI fix can retain explicit launch permissions using the existing runtime override mechanism, then apply them only to fresh input after reconnect. That would not repair work the daemon already recovered before the client reattached. A broader option is representing explicit YOLO access with a persistable built-in permission profile, subject to compatibility and server-policy review.
Related: #47454 and #29054. This report isolates app-server restart and ID-only resume, rather than mobile continuation or manually resuming without repeating --yolo.
Standalone Node.js reproduction (no dependencies or API credentials)
Save as repro.mjs, then run node repro.mjs /absolute/path/to/codex. It creates a temporary home, uses one loopback mock response, and stops only its two app-server children. The temporary home is retained for inspection.
import { execFileSync, spawn } from 'node:child_process';
import fs from 'node:fs';
import http from 'node:http';
import os from 'node:os';
import path from 'node:path';
import readline from 'node:readline';
if (!process.argv[2]) {
console.error('Usage: node /tmp/codex-yolo-cold-resume-repro.mjs <codex-binary>');
process.exit(2);
}
const codex = path.resolve(process.argv[2]);
fs.accessSync(codex, fs.constants.X_OK);
const codexVersion = execFileSync(codex, ['--version'], { encoding: 'utf8' }).trim();
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'codex-yolo-cold-resume-'));
const cwd = path.join(home, 'workspace');
fs.mkdirSync(cwd);
fs.mkdirSync(path.join(home, 'tmp'));
let mockResponseCount = 0;
const sse = [
{ type: 'response.created', response: { id: 'mock-response' } },
{
type: 'response.output_item.done',
item: {
type: 'message',
role: 'assistant',
id: 'mock-message',
content: [{ type: 'output_text', text: 'mocked' }],
},
},
{
type: 'response.completed',
response: {
id: 'mock-response',
usage: {
input_tokens: 0,
input_tokens_details: null,
output_tokens: 0,
output_tokens_details: null,
total_tokens: 0,
},
},
},
].map((event) => `data: ${JSON.stringify(event)}\n\n`).join('') + 'data: [DONE]\n\n';
const mock = http.createServer((request, response) => {
if (!request.url?.endsWith('/responses')) {
response.writeHead(200, { 'content-type': 'application/json' });
response.end('[]');
return;
}
mockResponseCount += 1;
request.resume();
request.on('end', () => {
response.writeHead(200, { 'content-type': 'text/event-stream', 'cache-control': 'no-cache' });
response.end(sse);
});
});
function launchAppServer() {
const child = spawn(codex, ['app-server', '--listen', 'stdio://'], {
cwd,
env: {
PATH: process.env.PATH,
HOME: home,
CODEX_HOME: home,
CODEX_APP_SERVER_MANAGED_CONFIG_PATH: path.join(home, 'managed_config.toml'),
TMPDIR: path.join(home, 'tmp'),
RUST_LOG: 'error',
},
stdio: ['pipe', 'pipe', 'pipe'],
});
const lines = readline.createInterface({ input: child.stdout });
const pending = new Map();
const notifications = [];
const notificationWaiters = [];
let stderr = '';
let nextId = 1;
child.stderr.on('data', (chunk) => { stderr += chunk.toString(); });
lines.on('line', (line) => {
let message;
try { message = JSON.parse(line); } catch { return; }
if (message.id != null && pending.has(message.id)) {
const waiter = pending.get(message.id);
pending.delete(message.id);
waiter.resolve(message);
return;
}
if (!message.method) return;
notifications.push(message);
const index = notificationWaiters.findIndex((waiter) => waiter.method === message.method);
if (index >= 0) notificationWaiters.splice(index, 1)[0].resolve(message);
});
return {
child,
request(method, params) {
const id = nextId++;
const result = new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
pending.delete(id);
reject(new Error(`timed out waiting for ${method}; stderr=${stderr}`));
}, 20000);
pending.set(id, {
resolve: (message) => { clearTimeout(timeout); resolve(message); },
});
});
child.stdin.write(`${JSON.stringify({ jsonrpc: '2.0', id, method, params })}\n`);
return result;
},
notify(method) {
child.stdin.write(`${JSON.stringify({ jsonrpc: '2.0', method })}\n`);
},
waitForNotification(method) {
const index = notifications.findIndex((message) => message.method === method);
if (index >= 0) return Promise.resolve(notifications.splice(index, 1)[0]);
return new Promise((resolve, reject) => {
const timeout = setTimeout(() => reject(new Error(`timed out waiting for ${method}; stderr=${stderr}`)), 20000);
notificationWaiters.push({
method,
resolve: (message) => { clearTimeout(timeout); resolve(message); },
});
});
},
stop() {
return new Promise((resolve) => {
child.once('exit', (code, signal) => resolve({ code, signal, stderr }));
child.kill('SIGTERM');
});
},
};
}
async function rpc(server, method, params) {
const message = await server.request(method, params);
if (message.error) throw new Error(`${method}: ${JSON.stringify(message.error)}`);
return message.result;
}
async function initialize(server) {
await rpc(server, 'initialize', {
clientInfo: { name: 'isolated-yolo-repro', version: '1' },
capabilities: { experimentalApi: true },
});
server.notify('initialized');
}
function rolloutTurnContext() {
const files = [];
const visit = (directory) => {
if (!fs.existsSync(directory)) return;
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
const entryPath = path.join(directory, entry.name);
if (entry.isDirectory()) visit(entryPath);
else if (entry.name.startsWith('rollout-') && entry.name.endsWith('.jsonl')) files.push(entryPath);
}
};
visit(path.join(home, 'sessions'));
for (const file of files) {
for (const line of fs.readFileSync(file, 'utf8').split('\n')) {
if (!line) continue;
const record = JSON.parse(line);
if (record.type === 'turn_context') {
return {
approvalPolicy: record.payload.approval_policy,
sandboxPolicy: record.payload.sandbox_policy,
permissionProfile: record.payload.permission_profile,
activePermissionProfile: record.payload.active_permission_profile ?? null,
};
}
}
}
throw new Error('no persisted turn_context found');
}
let first;
let second;
(async () => {
await new Promise((resolve) => mock.listen(0, '127.0.0.1', resolve));
const providerUrl = `http://127.0.0.1:${mock.address().port}/v1`;
fs.writeFileSync(path.join(home, 'config.toml'), [
'model = "mock-model"',
'model_provider = "mock"',
'approval_policy = "on-request"',
'sandbox_mode = "workspace-write"',
'',
'[model_providers.mock]',
'name = "loopback mock"',
`base_url = "${providerUrl}"`,
'wire_api = "responses"',
'requires_openai_auth = false',
'',
].join('\n'));
fs.writeFileSync(path.join(home, 'managed_config.toml'), '');
first = launchAppServer();
await initialize(first);
const started = await rpc(first, 'thread/start', {
cwd,
model: 'mock-model',
modelProvider: 'mock',
approvalPolicy: 'never',
sandbox: 'danger-full-access',
});
await first.waitForNotification('thread/started');
await rpc(first, 'turn/start', {
threadId: started.thread.id,
input: [{ type: 'text', text: 'reply with mocked output' }],
});
await first.waitForNotification('turn/completed');
const persistedContext = rolloutTurnContext();
const firstExit = await first.stop();
first = null;
second = launchAppServer();
await initialize(second);
const resumed = await rpc(second, 'thread/resume', {
threadId: started.thread.id,
excludeTurns: true,
});
const secondExit = await second.stop();
second = null;
mock.close();
const summary = {
codexVersion,
appServerExitCodes: [firstExit.code, secondExit.code],
localMockResponses: mockResponseCount,
startResponse: {
approvalPolicy: started.approvalPolicy,
sandboxType: started.sandbox.type,
activePermissionProfile: started.activePermissionProfile ?? null,
},
persistedTurnContext: {
approvalPolicy: persistedContext.approvalPolicy,
sandboxType: persistedContext.sandboxPolicy.type,
permissionProfileType: persistedContext.permissionProfile.type,
activePermissionProfile: persistedContext.activePermissionProfile,
},
coldResumeResponse: {
approvalPolicy: resumed.approvalPolicy,
sandboxType: resumed.sandbox.type,
activePermissionProfile: resumed.activePermissionProfile ?? null,
},
};
if (summary.appServerExitCodes.some((code) => code !== 0)) throw new Error(`unclean exit: ${JSON.stringify(summary)}`);
if (summary.localMockResponses !== 1) throw new Error(`expected one loopback response: ${JSON.stringify(summary)}`);
if (summary.startResponse.sandboxType !== 'dangerFullAccess') throw new Error(`unexpected start settings: ${JSON.stringify(summary)}`);
if (summary.persistedTurnContext.sandboxType !== 'danger-full-access') throw new Error(`unexpected persisted settings: ${JSON.stringify(summary)}`);
if (summary.coldResumeResponse.sandboxType !== 'workspaceWrite') throw new Error(`expected reproduced downgrade: ${JSON.stringify(summary)}`);
console.log(JSON.stringify(summary, null, 2));
})().catch(async (error) => {
if (first?.child && first.child.exitCode == null) await first.stop();
if (second?.child && second.child.exitCode == null) await second.stop();
mock.close();
console.error(error.stack || error);
process.exitCode = 1;
});Verified output on the installed binary:
{
"codexVersion": "codex-cli 0.158.0",
"appServerExitCodes": [
0,
0
],
"localMockResponses": 1,
"startResponse": {
"approvalPolicy": "never",
"sandboxType": "dangerFullAccess",
"activePermissionProfile": null
},
"persistedTurnContext": {
"approvalPolicy": "never",
"sandboxType": "danger-full-access",
"permissionProfileType": "disabled",
"activePermissionProfile": null
},
"coldResumeResponse": {
"approvalPolicy": "never",
"sandboxType": "workspaceWrite",
"activePermissionProfile": null
}
}
Activity
github-actions commentedon Sep 28, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
bvolpato commentedon Sep 28, 2026
The TUI regression also confirms the second half of this path: after a cold reconnect, a fresh
turn/startdrops the explicit launch sandbox. With the pre-fix startup behavior, the regression fails withNullinstead of"dangerFullAccess"; with the proposed fix it passes.I published a signed reference patch. Following the current contribution policy, I have not opened an external PR.
The patch remembers explicit local launch approval/sandbox choices using the existing runtime override mechanism. The regression covers YOLO, each flag independently, later picker changes, and no explicit launch override. Reconnect still sends no permission overrides and does not replay input. This fixes fresh input after TUI reattachment; it does not change work the server already recovered before the client reattached.
Validation against main
88e9a8329d17bd141e4f3f0e7c78d07a7baa8b23, using pinned Rust 1.95.0:just test -p codex-tui: 5,559 passed, 9 failed, 1 timed out, 8 skipped. The failures were in unchanged cursor snapshot and IDE IPC tests.NO_COLOR=1, which stripped expected ANSI sequences, andumask 002, which made temporary directories fail the IDE socket security check. Rerun usedNO_COLORunset,TERM=xterm-256color, andumask 022. No source changes were made for those failures.just clippy -p codex-tui,just fmt, andgit diff --checkpassed. Clippy reported an existing unused import in core.I also reviewed the suggested duplicate #49078. It documents a historical resume incident without a deterministic reproduction. This report adds an isolated 0.158.0 cold-restart reproduction and the TUI regression; the two incidents may share a cause, but I have not established that from the other report's logs.
Mar-IA-no commentedon Sep 30, 2026
Independently reproduced on Linux with Codex CLI 0.159.0, using isolated app-server restart and ID-only
thread/resume(local mock, no API credentials).With default permissions
:workspace:sandbox=danger-full-access: Full Access becomesworkspace-write; approval remainsnever.permissions=:danger-full-access: Full Access survives the same restart/resume.Practical mitigation: select Full Access via
/permissions. We verified that this activates the named profile locally. Automatic TUI reconnect was not tested.grosen-friis commentedon Oct 1, 2026
Additional field evidence from a joint troubleshooting session between Developer Grosen Friis and ChatGPT (GPT-5.6 Sol).
ChatGPT directed the diagnostic process step-by-step. The Developer executed the requested read-only diagnostic commands on the affected Debian host and returned the raw outputs for analysis. The findings below were reconstructed from Codex rollout JSONL files, Codex SQLite state/log databases, Linux /proc and socket information, file timestamps, and
codex doctor --json.This appears to independently confirm the permission-loss mechanism described in this issue, and adds an observation involving two simultaneous CLI sessions sharing the same managed app-server.
Environment
--dangerously-bypass-approvals-and-sandbox0.159.20.159.3codex doctor --jsonsubsequently confirmed:0.159.20.159.3daemon_auto_startenabledin_app_updatesenabledThe two sessions were working on unrelated projects.
Both threads definitely started with Full Access
The rollout history showed that both sessions originally had:
danger-full-accessNetwork access is enabledapproval_policy = neverpermission_profile = disabledTherefore this was not a case where the affected sessions had originally been launched in workspace mode.
Failure timeline
The managed app-server 0.159.3 binary appeared locally immediately before the failure:
Birth: 2026-10-01 00:39:36.217 +0100Change: 2026-10-01 00:39:38.493 +0100The following sequence was then reconstructed (timestamps below are UTC):
23:39:38.857— shared Unix socket created23:39:38.861— new managed app-server logs sandbox/bubblewrap initialization23:39:39.700— CUSTOMER thread changes to:workspace/network=restricted23:39:39.786— PRIVATE thread changes to:workspace/network=restricted23:39:39.860— CUSTOMER thread receives the restricted workspace settings againThe resulting thread settings included:
permission_profile.type = managedactive_permission_profile.id = :workspacenetwork = restrictedapproval_policy = neverImportantly, neither thread was executing an ordinary model turn when this occurred. The permission changes appeared between normal turns.
Both CLI sessions shared the same managed app-server
Linux Unix-socket inspection established that both CLI processes were connected to the same managed app-server:
customer CLI PID 1376724 -> managed app-server PID 1465345private CLI PID 1444857 -> managed app-server PID 1465345The app-server command line was:
codex app-server --listen unix:// --managed-daemonThe long-lived updater/watcher process was:
codex app-server daemon pid-update-loopThe daemon release directories showed this progression:
0.158.0— Sep 280.159.0— Sep 290.159.1— Sep 290.159.2— Sep 300.159.3— Oct 1 at approximately 00:39 local timeAt the time of the failure, the two interactive CLI processes remained version 0.159.2 while the newly activated shared managed app-server was version 0.159.3.
This strongly correlates the permission reset with activation/replacement of the managed app-server.
We have NOT proven that the version mismatch itself is required to trigger the bug; that remains an inference from the observed timing and state.
Functional symptom
After the transition, operations requiring network access failed inside Codex, including DNS-dependent operations, SSH and mail-related operations.
At the same time, DNS and network access continued to work normally on the host when tested directly as the same Linux user.
This initially looked as if Codex was gradually "restricting itself", but examination of the rollout history instead showed a discrete
thread_settings_appliedtransition.Recovery without restarting Codex
We also found a useful workaround.
Restarting the CLI is NOT required.
Inside the affected running session:
/permissionsthen selecting:
Full Accessimmediately generated new thread settings containing:
permission_profile = disabledactive_permission_profile.id = :danger-full-accessAfter this change,
getent hosts google.comimmediately succeeded from the SAME existing Codex session.Therefore
/permissions -> Full Accessappears to be a working field recovery when this occurs.Additional significance
This case adds evidence that a single shared managed app-server lifecycle/update event can alter permissions on multiple already-running, unrelated CLI threads within milliseconds of each other.
The close timing was:
:workspaceThe Developer can provide sanitized rollout excerpts, timestamps,
codex doctoroutput, or run additional diagnostics if useful.Contact: [email protected]
etraut-openai commentedon Oct 1, 2026
Thanks for the report. We have fix in place for this issue, and it will be included in an upcoming release (0.161.0).
kaminsod commentedon Oct 7, 2026
Additional recurring Linux case (2026-10-07, privacy-reduced)
This is another occurrence of the same permission-profile drift, with two details that may help narrow it down: it has recurred roughly 20 times across multiple long-running sessions, and the transition can invalidate active unified-exec work rather than merely restricting the next command.
Environment:
0.160.10.161.07.2.8-arch1-2Before the transition, the active thread context was effectively:
No permissions UI, host configuration, operating-system policy, network configuration, or repository setting was changed. During a later turn in the same thread, the injected context became:
Concrete impact observed in this occurrence:
write_stdin failed: Unknown process id ....socket: operation not permitted.TcpListener::bindwithPermissionDenied/Operation not permitted.error connecting to api.github.com, consistent with the newly restricted network policy..gitwas explicitly read-only and outbound network access was disabled.The host remained available and comparable Claude Code and OpenCode sessions continued operating normally. This has happened across multiple Codex sessions without deliberate permission changes; restarting or resuming is often required, after which full access may return until the next recurrence.
This looks like more than a misleading UI label: the effective sandbox changes and an active tool session can be lost. Useful investigation points would be:
codex doctor.No conversation transcript, task/session identifiers, usernames, repository names, absolute paths, credentials, source code, or private host/network details are included here. Additional narrowly scoped diagnostics can be collected if maintainers specify what is needed.
asamarts commentedon Oct 7, 2026
This issue is not resolved, I am on 0.161.0, and I am repeatedly seeing my codex sessions enter restricted sandbox mode, for no apparent reason, whatsoever - losing access to tools, and seeing the working directory as read-only, etc.
I launch 5-10 sessions/prompts in codex, come up back 20 mins later, most of them are in a broken state where they are unable to proceed due to this (or very similar issue).
This is making codex pretty much unusable at this point. @etraut-openai
etraut-openai commentedon Oct 7, 2026
@asamarts, are you perhaps running an app server daemon that predates 0.161.0? If you run
/status, it will tell you which version your app server is running. Or you can usecodex app-server daemon version. If you use the standalone (curl) installer, the daemon should be updated along with the CLI. If you're using a different install mechanism, you may need to initiate an update using/daemon.If that's not the explanation, we'll need to dig deeper to understand the behavior you're seeing. I'll need additional details to investigate further. The easiest way is to use
/feedbackand post your session ID here.asamarts commentedon Oct 8, 2026
All on 0.161.0 @etraut-openai:
codex --version:codex app-server daemon version:/status:
In my case I don't think there are any restarts happening to trigger this. I just work across multiple sessions and after a while they randomly start losing write access to the directory, access to MCP and other tools. Usually an /exit followed by
codex resumeresolves the issue... but when stacked on top of multiple other issues codex currently has... almost unuseable at this point.