Preserve CLAUDE_SECURESTORAGE_CONFIG_DIR across agent restore - #9419
Merged
austinywang merged 3 commits intoAug 3, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe launch environment allowlist now preserves ChangesClaude secure storage restoration
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 24 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (24 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
austinywang
deleted the
issue-9412-restored-claude-agents-lose-their-accoun
branch
August 3, 2026 02:17
Merged
4 of 5 tasks
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.
Fixes #9412
Restored Claude agents fell back to the ambient account because
CLAUDE_SECURESTORAGE_CONFIG_DIR, the variable that selects which directory holds.credentials.json, was not insafeEnvironmentKeys.sanitizedValuedrops any key missing from that set, so the value was discarded at capture time and the replayed environment carried nothing.CODEX_HOMEis allowlisted, which is why Codex sessions restored correctly and Claude ones did not.Mechanism
Added
"CLAUDE_SECURESTORAGE_CONFIG_DIR"tosafeEnvironmentKeysinPackages/macOS/CMUXAgentLaunch/Sources/CMUXAgentLaunch/AgentLaunchEnvironmentPolicy.swift, besideCLAUDE_CONFIG_DIR. It falls throughsanitizedValue'sdefaultbranch unmodified, which is right: it is a directory path, not a secret, and cmux has no reason to rewrite it. Principled fix, one line at the actual gate. Residual risk is that the variable is undocumented by Anthropic and could change name; an allowlist entry for an unset variable is inert, so the cost is bounded.Deliberately not adding it to
claudeAuthKeysinCLI/cmux.swift. That list exists to tellResources/bin/cmux-claude-wrappernot to scrub keys it would otherwise strip, and the wrapper'sCLAUDE_AUTH_SELECTION_ENV_KEYSnever touchesCLAUDE_SECURESTORAGE_CONFIG_DIR, so an entry there would be inert. This confirms the open question in the issue.Symphony verification
Regression test:
ClaudeSecureStorageConfigDirectoryPolicyTestsinPackages/macOS/CMUXAgentLaunch/Tests/CMUXAgentLaunchTests/AgentLaunchEnvironmentPolicyTests.swift(two cases: capture viaselectedEnvironment(from:kind:)keeps the path whileANTHROPIC_AUTH_TOKENis still dropped, andsanitizedValuereturns it unchanged).Two commits so CI shows red then green:
cd Packages/macOS/CMUXAgentLaunch && swift test --filter ClaudeSecureStorageConfigDirectoryPolicyTests->Test run with 2 tests in 1 suite failed, both expectations returningnil.cd Packages/macOS/CMUXAgentLaunch && swift test->Test run with 281 tests in 40 suites passed.Package-only change with no Swift app or UI surface, so no tagged reload or e2e workflow run.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Preserves Claude agent account on restore by keeping
CLAUDE_SECURESTORAGE_CONFIG_DIRin the captured and replayed environment.CLAUDE_SECURESTORAGE_CONFIG_DIRinAgentLaunchEnvironmentPolicyso restored agents don’t switch to the default account.ClaudeSecureStorageConfigDirectoryPolicyTestsverifying the path is preserved andANTHROPIC_AUTH_TOKENis still dropped.Written for commit b024fef. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests