From 55e4258147b232ebb927762495e62d53d00b526c Mon Sep 17 00:00:00 2001 From: Oleksiy Syvokon Date: Thu, 13 Nov 2025 17:09:16 +0200 Subject: [PATCH] agent: Workaround for Sonnet inserting tag (#42634) Release Notes: - N/A --- crates/agent/src/edit_agent/edit_parser.rs | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/crates/agent/src/edit_agent/edit_parser.rs b/crates/agent/src/edit_agent/edit_parser.rs index 425bf93efff115d4daef380e3f82abcdb8c0746f..c1aa61e18d4a450bc1caef939a53f65aed529a82 100644 --- a/crates/agent/src/edit_agent/edit_parser.rs +++ b/crates/agent/src/edit_agent/edit_parser.rs @@ -15,12 +15,14 @@ const SEPARATOR_MARKER: &str = "======="; const REPLACE_MARKER: &str = ">>>>>>> REPLACE"; const SONNET_PARAMETER_INVOKE_1: &str = "\n"; const SONNET_PARAMETER_INVOKE_2: &str = ""; -const END_TAGS: [&str; 5] = [ +const SONNET_PARAMETER_INVOKE_3: &str = ""; +const END_TAGS: [&str; 6] = [ OLD_TEXT_END_TAG, NEW_TEXT_END_TAG, EDITS_END_TAG, - SONNET_PARAMETER_INVOKE_1, // Remove this after switching to streaming tool call + SONNET_PARAMETER_INVOKE_1, // Remove these after switching to streaming tool call SONNET_PARAMETER_INVOKE_2, + SONNET_PARAMETER_INVOKE_3, ]; #[derive(Debug)] @@ -567,21 +569,29 @@ mod tests { parse_random_chunks( indoc! {" some textupdated text + more textupd "}, &mut parser, &mut rng ), - vec![Edit { - old_text: "some text".to_string(), - new_text: "updated text".to_string(), - line_hint: None, - },] + vec![ + Edit { + old_text: "some text".to_string(), + new_text: "updated text".to_string(), + line_hint: None, + }, + Edit { + old_text: "more text".to_string(), + new_text: "upd".to_string(), + line_hint: None, + }, + ] ); assert_eq!( parser.finish(), EditParserMetrics { - tags: 2, - mismatched_tags: 1 + tags: 4, + mismatched_tags: 2 } ); }