From 601e4c4376c5ee0a419a3eb588203571faf86348 Mon Sep 17 00:00:00 2001 From: Aryan Bagade Date: Mon, 8 Dec 2025 14:36:54 -0800 Subject: [PATCH] feat: include CLI path in unsupported version warning (#360) When the SDK detects an unsupported Claude CLI version, the warning message now includes the path to the found CLI binary. --- .../_internal/transport/subprocess_cli.py | 1 + tests/test_transport.py | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/src/claude_agent_sdk/_internal/transport/subprocess_cli.py b/src/claude_agent_sdk/_internal/transport/subprocess_cli.py index c7c74203..1a5ab242 100644 --- a/src/claude_agent_sdk/_internal/transport/subprocess_cli.py +++ b/src/claude_agent_sdk/_internal/transport/subprocess_cli.py @@ -650,6 +650,7 @@ async def _check_claude_version(self) -> None: warning = ( f"Warning: Claude Code version {version} is unsupported in the Agent SDK. " f"Minimum required version is {MINIMUM_CLAUDE_CODE_VERSION}. " + f"Found CLI at: {self._cli_path}. " "Some features may not work correctly." ) logger.warning(warning) diff --git a/tests/test_transport.py b/tests/test_transport.py index fe9b6b22..2044cbb5 100644 --- a/tests/test_transport.py +++ b/tests/test_transport.py @@ -826,3 +826,52 @@ async def do_write(i: int): await process.wait() anyio.run(_test, backend="trio") + + def test_unsupported_version_warning_includes_cli_path(self): + """Test that version warning includes the CLI path for debugging.""" + + async def _test(): + from io import StringIO + + # Create a transport with a specific CLI path + cli_path = "/custom/path/to/claude" + transport = SubprocessCLITransport( + prompt="test", + options=ClaudeAgentOptions(cli_path=cli_path), + ) + + # Mock the version check to simulate an old version + mock_process = MagicMock() + mock_stdout = AsyncMock() + mock_stdout.receive = AsyncMock(return_value=b"1.0.0\n") + mock_process.stdout = mock_stdout + mock_process.terminate = MagicMock() + mock_process.wait = AsyncMock() + + # Capture stderr output + import sys + + captured_stderr = StringIO() + original_stderr = sys.stderr + + try: + sys.stderr = captured_stderr + + with patch("anyio.open_process", return_value=mock_process): + await transport._check_claude_version() + + # Verify warning was printed to stderr + stderr_output = captured_stderr.getvalue() + assert ( + "Warning: Claude Code version 1.0.0 is unsupported" in stderr_output + ) + assert cli_path in stderr_output, ( + f"Expected CLI path '{cli_path}' in warning, " + f"but got: {stderr_output}" + ) + assert "Found CLI at:" in stderr_output + + finally: + sys.stderr = original_stderr + + anyio.run(_test, backend="asyncio")