Skip to content

fix(claude): map 'auto' runtime mode to 'default' permission mode#4510

Open
caddydove wants to merge 2 commits into
pingdotgg:mainfrom
caddydove:fix-claude-permission-mode
Open

fix(claude): map 'auto' runtime mode to 'default' permission mode#4510
caddydove wants to merge 2 commits into
pingdotgg:mainfrom
caddydove:fix-claude-permission-mode

Conversation

@caddydove

@caddydove caddydove commented Jul 25, 2026

Copy link
Copy Markdown

Fix #4495

The Claude CLI binary v2.1.146 rejects PermissionMode value 'auto' when called via setPermissionMode(), causing an immediate 'turn/setPermissionMode failed' error.

Changes

  • ClaudeAdapter.ts: Changed 'auto' → 'default' in runtimeModeToPermission, added missing 'approval-required' → 'default' mapping
  • ClaudeAdapter.test.ts: Updated assertions for 'auto' and 'approval-required' runtime modes to expect 'default'

Why 'default'

The 'default' permission mode is what the SDK uses when no explicit permission mode is set, and it is already confirmed working by the 'approval-required' runtime mode.


Note

Medium Risk
Claude permission mapping affects every auto/approval-required session; wrong mode could change approval behavior. Auth policy change only applies when Tailscale serve is enabled but shifts bootstrap expectations on loopback.

Overview
Fixes Claude Agent SDK sessions failing on newer CLI builds by mapping auto and approval-required runtime modes to SDK permission mode default instead of auto, which recent Claude Code rejects via setPermissionMode. full-access and auto-accept-edits mappings are unchanged.

Separately, when tailscaleServeEnabled is on, loopback web hosts (e.g. 127.0.0.1) are treated as remote-reachable for auth so bootstrap uses one-time-token rather than loopback-browser-only behavior—covered by a new EnvironmentAuthPolicy test.

Reviewed by Cursor Bugbot for commit 1cc3020. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Map 'auto' and 'approval-required' runtime modes to 'default' Claude permission mode

  • In ClaudeAdapter.ts, the runtimeMode to permissionMode mapping now sends 'default' instead of 'auto' for 'auto' mode, and explicitly sends 'default' instead of undefined for 'approval-required' mode.
  • Also updates EnvironmentAuthPolicy.ts to treat the server as remotely reachable when tailscaleServeEnabled is true, even on loopback hosts.
  • Behavioral Change: Sessions with runtimeMode 'auto' or 'approval-required' will now pass permissionMode: 'default' to Claude instead of 'auto' or omitting the field entirely.

Macroscope summarized 1cc3020.

When --tailscale-serve is enabled, the backend is reachable via Tailscale
Serve HTTPS URL even though the HTTP server binds to 127.0.0.1.

Adds config.tailscaleServeEnabled to the isRemoteReachable check in
EnvironmentAuthPolicy so the auth policy reflects remote reachability.

Closes pingdotgg#4462
The Claude CLI v2.1.146 rejects PermissionMode 'auto' when called via
setPermissionMode. Map 'auto' to 'default' (same as 'approval-required')
since the SDK's 'auto' value is not supported by the spawned binary.

Also adds the missing 'approval-required' -> 'default' mapping to
runtimeModeToPermission for correctness (was relying on undefined fallback).

Closes pingdotgg#4495
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8e8dc003-2809-469c-8d76-96c42da6b15d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Jul 25, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1cc3020. Configure here.

"approval-required": "default",
"auto-accept-edits": "acceptEdits",
auto: "auto",
auto: "default",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Auto mode mapped away

High Severity

Mapping Claude runtime mode auto to SDK permissionMode default removes Claude Code’s native Auto mode (AI-reviewed approvals) for every session. Issue #4495 is specifically a turn/setPermissionMode failure when restoring auto after plan mode, but this change also rewrites session-start query() options, so auto becomes identical to approval-required while Codex still keeps distinct auto_review behavior.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1cc3020. Configure here.

@macroscopeapp

macroscopeapp Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR modifies runtime permission mode mapping for Claude sessions, which is a significant behavioral change. Additionally, there is an unresolved high-severity review comment questioning whether this approach removes intended 'auto' mode functionality.

You can customize Macroscope's approvability policy. Learn more.

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

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Claude provider turn fails with "turn/setPermissionMode failed" when permission mode is Auto

1 participant