Improve line sampling deduplication and add robust tests for message digest and prompt construction in router logic

This commit is contained in:
2026-06-15 22:05:04 +02:00
parent 13cfd7518b
commit 8616c077cc
2 changed files with 58 additions and 2 deletions

View File

@@ -236,12 +236,14 @@ def _short_line(line: str, limit: int = MESSAGE_DIGEST_SAMPLE_LINE_CHARS) -> str
def _sample_representative_lines(text: str, *, max_lines: int = MESSAGE_DIGEST_MAX_SAMPLE_LINES) -> List[str]:
candidates = []
seen = set()
for line_number, line in enumerate(text.splitlines(), 1):
compact = _short_line(line)
if not compact:
continue
if compact in {item[1] for item in candidates}:
if compact in seen:
continue
seen.add(compact)
candidates.append((line_number, compact))
if len(candidates) <= max_lines:
return [f"L{line_number}: {compact}" for line_number, compact in candidates]