anthropics / anthropics/claude-agent-sdk-python

[BUG] Global Claude Code settings override SDK client configuration

Abierto
#45 4 comentarios 4 reacciones 1 asignado Reclamado por @ltawfik Ver en GitHub
bug
Lenguaje dominante
Python
Estrellas
8.1k
Forks
1.3k
Merge medio
2 d 31 min
PR fusionados (30 d)
1

Descripción

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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.