Fix Codex resume adopting stale looser approval policy#379
Closed
cursor[bot] wants to merge 1 commit into
Closed
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
Codex permission loosening on thread resume (security / correctness)
When a user tightened Codex approval (e.g. Edit → Default, both
workspace-writesandbox),thread/resumecould echo a stale looser policy (untrusted) with the same sandbox.shouldPreserveRequestedCodexPolicyonly 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 asuntrustedinstead ofon-request.Root cause
shouldPreserveRequestedCodexPolicyinagentChatService.tstreated 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
requestedCodexPolicyon resume, prefer it whenever sandbox or approval policy disagrees with the runtime echo. Freshthread/startpaths still omitrequestedCodexPolicyand 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.).