From 952203b6053773aeb307c0593728062353945981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E9=99=88?= Date: Sat, 30 May 2026 22:40:18 +0800 Subject: [PATCH] fix(core): handle bare markdown fences --- .../core/src/agentic/execution/round_executor.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/crates/core/src/agentic/execution/round_executor.rs b/src/crates/core/src/agentic/execution/round_executor.rs index e25228e8d..1072023e3 100644 --- a/src/crates/core/src/agentic/execution/round_executor.rs +++ b/src/crates/core/src/agentic/execution/round_executor.rs @@ -1872,8 +1872,9 @@ fn strip_markdown_fences(content: &str) -> String { return content.to_string(); } - // Find the end of the opening fence line - let fence_end = trimmed.find('\n').unwrap_or(3); + let Some(fence_end) = trimmed.find('\n') else { + return String::new(); + }; // let _lang = &trimmed[3..fence_end].trim(); // language hint, ignored // Check if content ends with ``` @@ -2479,10 +2480,9 @@ mod tests { } #[test] - fn sanitization_strips_markdown_fences_without_tags() { - // Model ignored tag instructions but used markdown fences - let text = "```rust\nfn main() {}\n```"; - assert_eq!(extract_bitfun_contents(text), "fn main() {}"); + fn sanitization_handles_bare_markdown_fence_without_panic() { + let text = "```"; + assert_eq!(extract_bitfun_contents(text), ""); } #[test]