Skip to content

Conversation

cnaples79
Copy link
Contributor

Summary

Adds support for passing custom Claude Code CLI paths through ClaudeAgentOptions, allowing organizations with non-standard installation locations to specify the CLI path explicitly.

Motivation

As noted in #214, organizations may install Claude Code CLI (or wrapped versions) at custom locations and prefer to provide those paths instead of relying on the SDK's default search logic. The transport layer already supported cli_path, but it was never exposed through the public API.

Changes

  1. types.py: Added cli_path: str | Path | None = None parameter to ClaudeAgentOptions dataclass
  2. _internal/client.py: Pass cli_path from configured_options.cli_path to SubprocessCLITransport
  3. client.py: Pass cli_path from options.cli_path to SubprocessCLITransport

Implementation Details

The SubprocessCLITransport constructor already accepted a cli_path parameter (line 40 of subprocess_cli.py), but it was never passed from the client layers. This PR completes the wiring by:

  • Adding the option to the public ClaudeAgentOptions interface
  • Extracting and passing it through both client implementations (InternalClient.process_query and ClaudeSDKClient.connect)

Usage Example

from claude_agent_sdk import query, ClaudeAgentOptions

# Specify custom CLI path
options = ClaudeAgentOptions(
    cli_path="/custom/path/to/claude"
)

result = await query("Hello!", options=options)

Testing

  • No new tests added as this is a straightforward parameter pass-through
  • Existing tests should continue to work (default behavior unchanged)
  • CI will validate the changes don't break existing functionality

Fixes #214

self._transport = SubprocessCLITransport(
prompt=actual_prompt,
options=options,
cli_path=options.cli_path,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this again, I think we could just remove the cli_path arg and rely on options inside the SubprocessCLITransport constructor, couldn't we?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I refactored to rely on options. Let me know what you think.

ashwin-ant
ashwin-ant previously approved these changes Oct 11, 2025
@ashwin-ant
Copy link
Collaborator

@cnaples79 some lint errors, otherwise we can merge!

cnaples79 and others added 3 commits October 12, 2025 22:17
Organizations may install Claude Code CLI at custom locations and
prefer to provide those paths instead of relying on the SDK's
default search logic.

Changes:
- Added cli_path parameter to ClaudeAgentOptions (types.py)
- Passed cli_path from options to SubprocessCLITransport in:
  - _internal/client.py (process_query method)
  - client.py (ClaudeSDKClient.connect method)

The transport layer already supported cli_path, but it was never
exposed through the ClaudeAgentOptions interface. This change
completes the wiring to make custom CLI paths configurable.

Fixes anthropics#214
@ashwin-ant ashwin-ant force-pushed the feat/support-cli-path-option branch from e156e71 to dde5a52 Compare October 13, 2025 05:24
@ashwin-ant ashwin-ant enabled auto-merge (squash) October 13, 2025 06:00
@ashwin-ant ashwin-ant merged commit aebcf9d into anthropics:main Oct 13, 2025
14 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for passing CLI path from ClaudeAgentOptions

3 participants