fix(ai): strip inline backticks wrapping generated commands

Benchmarking showed qwen2.5-coder commonly wraps its one-liner in a single pair
of backticks (`cmd`), which the triple-fence stripper missed. Strip a matching
leading+trailing backtick pair only, leaving inline command substitution intact.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
leetcrypt
2026-06-09 14:27:56 -07:00
parent a699989088
commit e4149ce502
+5 -1
View File
@@ -335,10 +335,14 @@ ai_build_prompt() {
esac
}
# Strip markdown fences and surrounding blank lines from a raw model response.
# Strip markdown fences, surrounding blank lines, and a single pair of inline
# backticks wrapping the whole line (coder models often emit `cmd`). Only a
# matching leading+trailing pair is removed, so command substitution like
# `date` inside a longer command is left untouched.
ai_clean_response() {
awk '/^[[:space:]]*```/ { next } { print }' \
| sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' \
| sed -E 's/^`(.*)`$/\1/' \
| sed '/^$/d'
}