Skip to content

Commit 5ed30f1

Browse files
committed
fix: omit skills from initialize request when 'all'
'all' and omitted both mean 'no filter' at the wire level, so only send the field when it is an explicit list. Keeps the CLI control schema as a plain string[] (which the zod-to-proto pipeline can represent) while the 'all' sentinel remains at the Python API surface for ergonomics.
1 parent 01f9a46 commit 5ed30f1

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/claude_agent_sdk/_internal/query.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ async def initialize(self) -> dict[str, Any] | None:
164164
request["agents"] = self._agents
165165
if self._exclude_dynamic_sections is not None:
166166
request["excludeDynamicSections"] = self._exclude_dynamic_sections
167-
if self._skills is not None:
167+
# 'all' and omitted are equivalent at the wire level (no filter), so
168+
# only send the field when it's an explicit list.
169+
if isinstance(self._skills, list):
168170
request["skills"] = self._skills
169171

170172
# Use longer timeout for initialize since MCP servers may take time to start

tests/test_query.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,20 @@ def test_initialize_omits_exclude_dynamic_sections_when_unset():
5959
assert "excludeDynamicSections" not in sent
6060

6161

62-
def test_initialize_sends_skills_when_set():
63-
"""Query.initialize() includes skills (list, 'all', or empty) in the control request."""
62+
def test_initialize_sends_skills_list():
63+
"""Query.initialize() includes skills only when it is a list."""
6464
sent = _capture_initialize_request(skills=["pdf", "docx"])
6565
assert sent["skills"] == ["pdf", "docx"]
6666

67-
sent_all = _capture_initialize_request(skills="all")
68-
assert sent_all["skills"] == "all"
69-
7067
sent_empty = _capture_initialize_request(skills=[])
7168
assert sent_empty["skills"] == []
7269

7370

74-
def test_initialize_omits_skills_when_unset():
75-
"""skills is absent from initialize when not configured."""
76-
sent = _capture_initialize_request()
77-
assert "skills" not in sent
71+
def test_initialize_omits_skills_for_none_and_all():
72+
"""'all' and None both omit skills from initialize (no filter at wire level)."""
73+
assert "skills" not in _capture_initialize_request()
74+
assert "skills" not in _capture_initialize_request(skills=None)
75+
assert "skills" not in _capture_initialize_request(skills="all")
7876

7977

8078
def _make_mock_transport(messages, control_requests=None):

0 commit comments

Comments
 (0)