(text: str)
| 583 | |
| 584 | |
| 585 | def _safe_compact_text(text: str) -> str: |
| 586 | normalized = text.replace("\r\n", "\n").replace("\r", "\n") |
| 587 | try: |
| 588 | parsed = json.loads(normalized) |
| 589 | except Exception: |
| 590 | parsed = None |
| 591 | if isinstance(parsed, (dict, list)): |
| 592 | try: |
| 593 | return json.dumps(parsed, ensure_ascii=False, separators=(",", ":")) |
| 594 | except Exception: |
| 595 | pass |
| 596 | |
| 597 | lines = [line.rstrip() for line in normalized.split("\n")] |
| 598 | squashed = "\n".join(lines) |
| 599 | squashed = re.sub(r"\n{3,}", "\n\n", squashed) |
| 600 | return squashed.strip() |
| 601 | |
| 602 | |
| 603 | def _infer_tool_name(messages: list[dict[str, Any]], idx: int, tool_call_id: str) -> str: |
no outgoing calls
no test coverage detected