SDK: setting_sources=[] silently ignored due to falsy check

Resolved 💬 3 comments Opened Apr 6, 2026 by joshwilhelmi Closed Apr 10, 2026

Bug

ClaudeAgentOptions.setting_sources = [] is silently ignored. The SDK never passes --setting-sources to the CLI, so all settings sources (user, project, local) load by default.

Root cause

In subprocess_cli.py:283:

if self._options.setting_sources:
    cmd.extend(["--setting-sources", ",".join(self._options.setting_sources)])

Empty list [] is falsy in Python, so the condition fails and the flag is never sent.

Expected behavior

setting_sources=[] should pass --setting-sources "" to the CLI, which parseSettingSourcesFlag("") correctly interprets as "no sources" — disabling user, project, and local settings while keeping policy and flag settings.

Workaround

options = ClaudeAgentOptions(
    setting_sources=[""],  # truthy, join produces "", CLI parses as empty
)

Impact

This breaks any use case where you want SDK-spawned CLI processes to ignore user/project settings. In our case, user-level hooks in ~/.claude/settings.json merged into SDK-spawned CLI subprocesses, causing duplicate hook execution and ghost session creation.

Suggested fix

if self._options.setting_sources is not None:
    cmd.extend(["--setting-sources", ",".join(self._options.setting_sources)])

With setting_sources defaulting to None instead of checking truthiness.

Version

claude-agent-sdk 0.1.56

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗