diff --git a/internal/runtime/executor/aistudio_executor.go b/internal/runtime/executor/aistudio_executor.go index 4558b319..221fb648 100644 --- a/internal/runtime/executor/aistudio_executor.go +++ b/internal/runtime/executor/aistudio_executor.go @@ -384,8 +384,16 @@ func ensureColonSpacedJSON(payload []byte) []byte { for i := 0; i < len(indented); i++ { ch := indented[i] - if ch == '"' && (i == 0 || indented[i-1] != '\\') { - inString = !inString + if ch == '"' { + // A quote is escaped only when preceded by an odd number of consecutive backslashes. + // For example: "\\\"" keeps the quote inside the string, but "\\\\" closes the string. + backslashes := 0 + for j := i - 1; j >= 0 && indented[j] == '\\'; j-- { + backslashes++ + } + if backslashes%2 == 0 { + inString = !inString + } } if !inString {