ClaudeAgentSDK.Transport.StreamingRouter (claude_agent_sdk v0.6.9)
View SourceSelects streaming transport based on required features.
Decision Algorithm
- Check explicit override (
preferred_transport) - Detect control protocol requirements
- Default to CLI-only for performance
Examples
# Simple streaming → CLI-only
iex> select_transport(%Options{})
:streaming_session
# With hooks → Control client
iex> select_transport(%Options{hooks: %{pre_tool_use: [...]}})
:control_client
# Override
iex> select_transport(%Options{preferred_transport: :cli})
:streaming_session
Summary
Functions
Human-readable explanation of transport choice.
Checks if options require control protocol.
Selects transport implementation.
Types
Functions
@spec explain(ClaudeAgentSDK.Options.t()) :: String.t()
Human-readable explanation of transport choice.
Examples
iex> StreamingRouter.explain(%Options{hooks: %{...}})
"""
Transport: control_client
Reason: hooks detected
Features: [:hooks]
Override: none
"""
@spec requires_control_protocol?(ClaudeAgentSDK.Options.t()) :: boolean()
Checks if options require control protocol.
Useful for debugging transport selection.
@spec select_transport(ClaudeAgentSDK.Options.t()) :: transport_choice()
Selects transport implementation.
Returns :streaming_session (CLI-only) or :control_client (full features).
Performance
This is a pure function with no I/O. Typical execution: <0.1ms.