diff --git a/src/deepgram/agent/v1/socket_client.py b/src/deepgram/agent/v1/socket_client.py index f76fc9e4..7e337c88 100644 --- a/src/deepgram/agent/v1/socket_client.py +++ b/src/deepgram/agent/v1/socket_client.py @@ -75,7 +75,10 @@ def __init__(self, *, websocket: WebSocketClientProtocol): def _is_binary_message(self, message: typing.Any) -> bool: """Determine if a message is binary data.""" - return isinstance(message, (bytes, bytearray)) + # Use type() directly for consistent performance (avoids isinstance+tuple overhead for simple cases), + # but preserves behavioral correctness for both bytes/bytearray + t = type(message) + return t is bytes or t is bytearray def _handle_binary_message(self, message: bytes) -> typing.Any: """Handle a binary message (returns as-is for audio chunks)."""