Write a formatted tool result to the trace output.
(out: Any, content: Any)
| 613 | |
| 614 | |
| 615 | def _write_tool_result(out: Any, content: Any) -> None: |
| 616 | """Write a formatted tool result to the trace output.""" |
| 617 | if isinstance(content, list): |
| 618 | parts = [] |
| 619 | for c in content: |
| 620 | if isinstance(c, dict): |
| 621 | parts.append(c.get("text", str(c))[:300]) |
| 622 | else: |
| 623 | parts.append(str(c)[:300]) |
| 624 | content_str = " ".join(parts) |
| 625 | else: |
| 626 | content_str = str(content) |
| 627 | if len(content_str) > 300: |
| 628 | content_str = content_str[:297] + "..." |
| 629 | out.write(f" {_DIM} → {content_str}{_RESET}\n") |
| 630 | out.flush() |
| 631 | |
| 632 | |
| 633 | def _write_tool_call(out: Any, name: str, args: Any, count: int) -> None: |
no test coverage detected