diff --git a/agent/anthropic_adapter.py b/agent/anthropic_adapter.py index ea09c11ea..05449e2a7 100644 --- a/agent/anthropic_adapter.py +++ b/agent/anthropic_adapter.py @@ -641,7 +641,9 @@ def _write_claude_code_credentials( existing["claudeAiOauth"] = oauth_data cred_path.parent.mkdir(parents=True, exist_ok=True) - cred_path.write_text(json.dumps(existing, indent=2), encoding="utf-8") + _tmp_cred = cred_path.with_suffix(".tmp") + _tmp_cred.write_text(json.dumps(existing, indent=2), encoding="utf-8") + _tmp_cred.replace(cred_path) # Restrict permissions (credentials file) cred_path.chmod(0o600) except (OSError, IOError) as e: @@ -1598,4 +1600,3 @@ def build_anthropic_kwargs( return kwargs -