grep $PATTERN $LOGFILE | tr -s ' ' | rev | cut -d' ' -f7 | rev | awk '{s+=$1} END {print s}'
This assumes the response size field comes after the user-agent which is hard to parse due to it's unpredictable structure. It reverses the string in order to cut the 7th last field (where the response size is in my log file format).
Explanation:
# Keep only the lines you care about
grep $PATTERN $LOGFILE
# Concatenate spaces together
tr -s ' '
# Reverse the string so you can count from the end
rev
# Take the 7th field, separated by spaces
cut -d' ' -f7
# Reverse again to get the right way round
rev
# Sum up the lines which now contain the response sizes and print their sum
awk '{s+=$1} END {print s}'