Skip to content

fix(tasks): map plan to read-only for codex cloud runs#3322

Merged
charlesvien merged 4 commits into
mainfrom
fix/codex-cloud-permission-mode
Jul 9, 2026
Merged

fix(tasks): map plan to read-only for codex cloud runs#3322
charlesvien merged 4 commits into
mainfrom
fix/codex-cloud-permission-mode

Conversation

@charlesvien

Copy link
Copy Markdown
Member

Problem

Creating a cloud task run with a GPT model fails with a 400 when the permission mode is Plan:

Invalid choice 'plan' for runtime_adapter 'codex'. Supported values: 'auto', 'read-only', 'full-access'.

Plan is a valid codex preset locally (the app-server adapter synthesizes it), so the picker offers it and the last-used mode restores it, but the cloud API's initial_permission_mode enum for codex doesn't accept it. Anyone whose last-used mode is Plan hits this the moment they pick a GPT model. Reported by Daniel in Slack.

Changes

Clamp initial_permission_mode to the API's per-adapter enum in buildCloudRunRequestBody, the single path every cloud run request goes through (create and resume). Unsupported values degrade to the nearest mode with the same permission ceiling: for codex, plan becomes read-only, bypassPermissions becomes full-access and default/acceptEdits become auto. The claude direction gets the symmetric mapping. Codex-native values pass through unchanged, so this becomes a no-op if the backend later accepts plan for codex.

Until then, a codex cloud task started in Plan runs read-only; switching to Plan mid-session still works since that goes over the ACP bridge, not this enum.

How did you test this?

  • New it.each unit tests covering all adapter/mode combinations in execution-mode.test.ts, plus a posthog-client.test.ts case asserting codex + plan sends read-only in the request body.
  • Ran the full @posthog/agent (1179) and @posthog/api-client (72) suites, turbo typecheck and Biome.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@trunk-io

trunk-io Bot commented Jul 9, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 49a4da1.

@greptile-apps

greptile-apps Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "map plan to read-only for codex cloud ru..." | Re-trigger Greptile

Comment thread packages/api-client/src/posthog-client.ts Outdated
@charlesvien charlesvien added the Stamphog This will request an autostamp by stamphog on small changes label Jul 9, 2026
github-actions[bot]
github-actions Bot previously approved these changes Jul 9, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No showstoppers. The PR correctly maps the "plan" permission mode to "read-only" for codex cloud runs and moves the initial_permission_mode field inside the adapter guard, so it's omitted when no adapter is set. The older bot comment's concern is directly addressed by the current diff, and both the resolver logic and the no-adapter case are covered by new tests.

@charlesvien charlesvien added the Create Release This will trigger a new release label Jul 9, 2026
@github-actions github-actions Bot dismissed their stale review July 9, 2026 21:41

New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Focused, correct fix that maps "plan" to "read-only" for codex cloud runs and gates initial_permission_mode on adapter presence. The resolved greptile concern is fully addressed by the diff, and the new tests cover all key paths.

@charlesvien charlesvien merged commit 0757f01 into main Jul 9, 2026
26 checks passed
@charlesvien charlesvien deleted the fix/codex-cloud-permission-mode branch July 9, 2026 21:49
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Could not verify team-posthog-code membership (GitHub API error). Auto-release is limited to Team PostHog Code members, so this will ship with the next scheduled release instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Create Release This will trigger a new release Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants