Skip to content

Commit 8463c4f

Browse files
committed
fix: sanitize Ask tool answers to prevent markdown formatting issues with leading slashes
1 parent 014b1f2 commit 8463c4f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pr_agent/tools/pr_questions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ def _prepare_pr_answer(self) -> str:
120120
model_answer = self.prediction.strip()
121121
# sanitize the answer so that no line will start with "/"
122122
model_answer_sanitized = model_answer.replace("\n/", "\n /")
123+
if model_answer_sanitized.startswith("/"):
124+
model_answer_sanitized = " " + model_answer_sanitized
125+
if model_answer_sanitized != model_answer:
126+
get_logger().debug(f"Sanitized model answer",
127+
artifact={"model_answer": model_answer, "sanitized_answer": model_answer_sanitized})
128+
123129

124130
answer_str = f"### **Ask**❓\n{self.question_str}\n\n"
125131
answer_str += f"### **Answer:**\n{model_answer_sanitized}\n\n"

0 commit comments

Comments
 (0)