Summary
ClaudeAgentOptions(setting_sources=[]) has no effect because the SDK checks the list with a truthiness test (if self._options.setting_sources:). An empty list is falsy in Python, so --setting-sources is never passed to the CLI, and the CLI falls back to loading all setting sources (user, project, local).
Affected file
claude_agent_sdk/_internal/transport/subprocess_cli.py, line 283:
if self._options.setting_sources: # [] is falsy → branch never executes
cmd.extend(["--setting-sources", ",".join(self._options.setting_sources)])
Expected behavior
setting_sources=[] should pass --setting-sources "" (or equivalent) to the CLI to disable all setting sources, consistent with the type annotation list[SettingSource] | None where None means "use default" and [] means "no sources".
Actual behavior
setting_sources=[] is treated identically to setting_sources=None: the CLI flag is not passed, so all setting sources load (including account-level claude.ai MCP integrations from the user settings).
Workaround
Use a non-empty list that excludes the sources you don't want, e.g. setting_sources=["local"], which is truthy and passes --setting-sources local to the CLI.
Suggested fix
Change the truthiness check to an explicit None check:
if self._options.setting_sources is not None:
cmd.extend(["--setting-sources", ",".join(self._options.setting_sources)])
This distinguishes None ("use CLI default") from [] ("no sources").
🤖 Generated with Claude Code
Summary
ClaudeAgentOptions(setting_sources=[])has no effect because the SDK checks the list with a truthiness test (if self._options.setting_sources:). An empty list is falsy in Python, so--setting-sourcesis never passed to the CLI, and the CLI falls back to loading all setting sources (user, project, local).Affected file
claude_agent_sdk/_internal/transport/subprocess_cli.py, line 283:Expected behavior
setting_sources=[]should pass--setting-sources ""(or equivalent) to the CLI to disable all setting sources, consistent with the type annotationlist[SettingSource] | NonewhereNonemeans "use default" and[]means "no sources".Actual behavior
setting_sources=[]is treated identically tosetting_sources=None: the CLI flag is not passed, so all setting sources load (including account-levelclaude.aiMCP integrations from the user settings).Workaround
Use a non-empty list that excludes the sources you don't want, e.g.
setting_sources=["local"], which is truthy and passes--setting-sources localto the CLI.Suggested fix
Change the truthiness check to an explicit
Nonecheck:This distinguishes
None("use CLI default") from[]("no sources").🤖 Generated with Claude Code