bypassPermissions mode resets to 'default' during long sessions at system boundaries
Bug Description
The permissionMode set to bypassPermissions in settings (global, user-local, and project-local) spontaneously resets to default during long-running sessions, causing unexpected permission prompts for Edit/Write operations.
Environment
- Claude Code version: 2.1.81
- OS: macOS (Darwin 24.5.0)
- Settings:
"defaultMode": "bypassPermissions"configured at all 3 levels (globalsettings.json,settings.local.json, and project.claude/settings.local.json) skipDangerousModePermissionPrompt: true
Steps to Reproduce
- Configure
"defaultMode": "bypassPermissions"in~/.claude/settings.json - Start a long-running session (3+ hours, many tool calls)
- Observe that initially all Edit/Write operations are auto-approved
- After extended use (system boundaries / file-history-snapshots), the mode resets
Evidence from Session Logs
Extracted from session ab5018b6 JSONL logs, tracking permissionMode field across user messages:
L17 12:15 MODE: None → bypassPermissions ← Session starts correctly
L477 17:53 MODE: bypassPermissions → default ← UNEXPECTED RESET
L510 17:58 MODE: default → acceptEdits ← User selects "allow all edits" from prompt
L581 18:17 MODE: acceptEdits → bypassPermissions ← Restores spontaneously
L634 18:29 MODE: bypassPermissions → acceptEdits ← Resets again
Pattern
Every mode reset correlates with a system: {} event followed by a file-history-snapshot:
L474 17:52 assistant: "Tudo concluído..."
L475 17:52 system: {} ← SYSTEM BOUNDARY
L476 file-history-snapshot
L477 17:53 user [default]: ← MODE DROPPED TO DEFAULT
This pattern repeats at every transition point (L508→L510, L632→L634).
Expected Behavior
permissionMode should remain bypassPermissions for the entire session duration, as configured in settings. System boundaries and file-history-snapshots should not affect the permission mode.
Actual Behavior
The mode oscillates between bypassPermissions, default, and acceptEdits within a single session, causing:
- Unexpected permission prompts interrupting autonomous workflows
- User has to repeatedly re-approve edits
- Inconsistent behavior that undermines the bypass setting
Workaround
A PreToolUse hook that forces permissionDecision: "allow" for Edit/Write/MultiEdit tools:
// ~/.claude/settings.json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write|MultiEdit",
"hooks": [
{
"type": "command",
"command": "$HOME/.claude/hooks/auto-approve-edits.sh"
}
]
}
]
}
}
#!/bin/bash
# ~/.claude/hooks/auto-approve-edits.sh
echo '{"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "allow"}}'
exit 0
Impact
- Severity: Medium — disrupts autonomous workflows in
bypassPermissionsmode - Frequency: Occurs in every long session (3+ hours) with many tool calls
- Affected users: Anyone relying on
bypassPermissionsfor unattended/autonomous operation
This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗