Bug Description
In subprocess_cli.py, the _build_command method uses a truthiness check for setting_sources:
if self._options.setting_sources: # line 283
cmd.extend(["--setting-sources", ",".join(self._options.setting_sources)])
Since [] is falsy in Python, passing setting_sources=[] never sends --setting-sources to the CLI subprocess. The intent of setting_sources=[] is "load no setting sources", but it silently does nothing — the CLI falls back to loading all default sources.
Expected Behavior
setting_sources=[] should pass --setting-sources "" to the CLI, disabling all setting sources.
Comparison with tools handling
This is the same class of bug as #634 (allowed_tools=[]), which was fixed. The tools field correctly uses an is not None check:
if self._options.tools is not None: # Correct: distinguishes None from []
tools = self._options.tools
if isinstance(tools, list):
if len(tools) == 0:
cmd.extend(["--tools", ""])
But setting_sources still uses a truthiness check, making an empty list indistinguishable from "not set".
Suggested Fix
if self._options.setting_sources is not None:
if len(self._options.setting_sources) == 0:
cmd.extend(["--setting-sources", ""])
else:
cmd.extend(["--setting-sources", ",".join(self._options.setting_sources)])
Workaround
Pass setting_sources=[""] (a list containing an empty string) to force the flag through the truthiness check. This produces --setting-sources "" which the CLI interprets as no sources.
Versions
- claude-agent-sdk 0.1.45
- Python 3.14
Bug Description
In
subprocess_cli.py, the_build_commandmethod uses a truthiness check forsetting_sources:Since
[]is falsy in Python, passingsetting_sources=[]never sends--setting-sourcesto the CLI subprocess. The intent ofsetting_sources=[]is "load no setting sources", but it silently does nothing — the CLI falls back to loading all default sources.Expected Behavior
setting_sources=[]should pass--setting-sources ""to the CLI, disabling all setting sources.Comparison with
toolshandlingThis is the same class of bug as #634 (
allowed_tools=[]), which was fixed. Thetoolsfield correctly uses anis not Nonecheck:But
setting_sourcesstill uses a truthiness check, making an empty list indistinguishable from "not set".Suggested Fix
Workaround
Pass
setting_sources=[""](a list containing an empty string) to force the flag through the truthiness check. This produces--setting-sources ""which the CLI interprets as no sources.Versions