Here's a reduced scenario:
a.sh:
#!/bin/sh
echo "blabla" >&2
echo "blabla" >&2
The output is garbled:
$ ./a.sh 2>&1 | tee a.txt
blabla
�%/�%/�
$ _TAG_REDIR_OUT= ./a.sh 2>&1 | tee a.txt
blabla
blabla
Works when _TAG_REDIR_OUT is unset as above
There might be some double conversion happening due to _TAG_REDIR_OUT=txt and bash tagging stdout