Fix compact summary regex replacement
This commit is contained in:
+1
-1
@@ -238,7 +238,7 @@ def format_compact_summary(summary: str) -> str:
|
||||
content = match.group(1).strip()
|
||||
formatted = re.sub(
|
||||
r'<summary>[\s\S]*?</summary>',
|
||||
f'Summary:\n{content}',
|
||||
lambda _: f'Summary:\n{content}',
|
||||
formatted,
|
||||
)
|
||||
|
||||
|
||||
@@ -112,6 +112,12 @@ class TestFormatCompactSummary(unittest.TestCase):
|
||||
self.assertNotIn('Line 1', formatted)
|
||||
self.assertIn('Final summary', formatted)
|
||||
|
||||
def test_summary_content_keeps_regex_backslashes_literal(self) -> None:
|
||||
raw = r'<summary>Regex examples: \s+ and \1 should stay literal.</summary>'
|
||||
formatted = format_compact_summary(raw)
|
||||
self.assertIn(r'\s+', formatted)
|
||||
self.assertIn(r'\1', formatted)
|
||||
|
||||
|
||||
class TestGetCompactUserSummaryMessage(unittest.TestCase):
|
||||
"""Tests for the post-compact user message builder."""
|
||||
|
||||
Reference in New Issue
Block a user