Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/claude_agent_sdk/_internal/transport/subprocess_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ async def connect(self) -> None:
if self._options.enable_file_checkpointing:
process_env["CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTING"] = "true"

# Enable experimental agent teams if agents are configured, so that the
# SendMessage tool is available to the model for resuming subagents.
if self._options.agents:
process_env["CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS"] = "1"

if self._cwd:
process_env["PWD"] = self._cwd

Expand Down
42 changes: 42 additions & 0 deletions tests/test_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,48 @@ async def _test():

anyio.run(_test)

def test_experimental_agent_teams_flag_injected_for_agents(self):
"""Test that CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS is injected when agents are configured."""

async def _test():
# Configure with agents
options = make_options(agents={"test_agent": {"description": "A test agent"}})

with patch(
"anyio.open_process", new_callable=AsyncMock
) as mock_open_process:
mock_version_process = MagicMock()
mock_version_process.stdout = MagicMock()
mock_version_process.stdout.receive = AsyncMock(
return_value=b"2.0.0 (Claude Code)"
)
mock_version_process.terminate = MagicMock()
mock_version_process.wait = AsyncMock()

mock_process = MagicMock()
mock_process.stdout = MagicMock()
mock_stdin = MagicMock()
mock_stdin.aclose = AsyncMock()
mock_process.stdin = mock_stdin
mock_process.returncode = None

mock_open_process.side_effect = [mock_version_process, mock_process]

transport = SubprocessCLITransport(
prompt="test",
options=options,
)

await transport.connect()

env_passed = mock_open_process.call_args_list[1].kwargs["env"]

# Verify the flag is injected when agents are provided
assert "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS" in env_passed
assert env_passed["CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS"] == "1"

anyio.run(_test)

def test_caller_can_override_entrypoint(self):
"""Test that a caller-supplied CLAUDE_CODE_ENTRYPOINT survives the env merge."""

Expand Down