Skip to content

Fix Codex resume adopting stale looser approval policy#379

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-f78a
Closed

Fix Codex resume adopting stale looser approval policy#379
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-f78a

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 27, 2026

Bug and impact

Codex permission loosening on thread resume (security / correctness)

When a user tightened Codex approval (e.g. Edit → Default, both workspace-write sandbox), thread/resume could echo a stale looser policy (untrusted) with the same sandbox. shouldPreserveRequestedCodexPolicy only preserved user intent when the requested policy was more permissive (never / untrusted), so the stale runtime value was adopted. Subsequent turns then ran with looser approvals than the user selected.

Concrete trigger: Codex chat in Edit mode → switch permission to Default → send/resume → resume response returns unlessTrusted + workspaceWrite → session persisted as untrusted instead of on-request.

Root cause

shouldPreserveRequestedCodexPolicy in agentChatService.ts treated mismatched approval policies asymmetrically: it preserved ADE-requested policy when the user wanted looser settings, but adopted stale runtime policy when the user wanted stricter settings and sandbox matched.

Fix

When ADE supplies requestedCodexPolicy on resume, prefer it whenever sandbox or approval policy disagrees with the runtime echo. Fresh thread/start paths still omit requestedCodexPolicy and adopt runtime-reported policy.

Validation

  • npm run test -- --run src/main/services/chat/agentChatService.test.ts -t "keeps stricter Codex approval|keeps requested Codex policy|applies fresh Codex thread effective"

Does not overlap open draft PRs (#374 Linear review bypass, orchestration/sync fixes, etc.).

Open in Web View Automation 

ADE   Open in ADE  ·  cursor/critical-correctness-bugs-f78a branch  ·  PR #379

When thread/resume echoed a permissive approval policy with the same
sandbox as the user-selected mode, applyCodexEffectiveThreadState could
overwrite stricter on-request settings with stale untrusted policy.

Prefer ADE-requested policy whenever resume responses disagree.

Co-authored-by: Arul Sharma <arul28@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ade Ignored Ignored May 27, 2026 7:12pm

@arul28 arul28 closed this May 28, 2026
@arul28 arul28 deleted the cursor/critical-correctness-bugs-f78a branch May 28, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants