anthropics / anthropics/claude-agent-sdk-python

[BUG] Global Claude Code settings override SDK client configuration

Đang mở
#45 4 bình luận 4 reaction 1 người được giao Được @ltawfik nhận Xem trên GitHub
bug
Ngôn ngữ chính
Python
Star
8.1k
Fork
1.3k
Merge trung bình
2 ngày 31 phút
Pull request đã merge (30 ngày)
1

Mô tả

Image

Image

Image

## 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
1. Set up global Claude Code configuration with:
- Model: Opus
- MCP servers configured
2. Create a Python SDK client with specific options:
- Model: Sonnet (as shown in first image)
- No MCP servers intended
3. 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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.