[BUG] Global Claude Code settings override SDK client configuration
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other:
- Claude CLI version: 1.0.35
- Operating System: macOS 15.5
- Terminal: iTerm2
Bug Description
The global Claude Code settings are overriding the configuration options set in the Python SDK client, causing unexpected behavior and significantly higher costs.
Steps to Reproduce
- Set up global Claude Code configuration with:
- Model: Opus
- MCP servers configured
- Create a Python SDK client with specific options:
- Model: Sonnet (as shown in first image)
- No MCP servers intended
- Execute code using the SDK client
Expected Behavior
The SDK client should use only the configuration options explicitly set in the client initialization, ignoring global Claude Code settings.
Actual Behavior
- The SDK client inherits MCP servers from global Claude Code settings (visible in second image)
- Despite setting model to "sonnet" in the SDK client, it actually uses "Opus" from global settings (confirmed by API usage in third image)
Confirmation of the Bug
Further evidence that global settings override SDK settings: After changing the global Claude Code model setting from Opus to Sonnet, the SDK client then started using Sonnet instead of Opus, even though the SDK client code remained unchanged. This definitively proves that the SDK is reading from global Claude Code settings rather than respecting its own configuration.
Impact
This is a critical issue that results in:
- Unexpected high costs: I was charged ~$100 instead of expected ~$20 due to unintended Opus usage
- Configuration confusion: SDK settings are silently ignored
- Unpredictable behavior: The actual model/tools used don't match the configured settings
- Unreliable cost control: Developers cannot predict which model will be used based on their code
Additional Context
The API key shown in the third image was created specifically for testing this issue. This behavior makes it impossible to reliably control costs and model selection when using the SDK in environments where Claude Code is also installed.
I reported on claude-code-sdk-python too.
(It seems like no anthropic staffs taking care of that repository now)
Not only the model, but all the settings.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
I think this can be closed now?
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.