|
7 | 7 |
|
8 | 8 | from __future__ import annotations |
9 | 9 |
|
10 | | -import json |
11 | 10 | import math |
12 | 11 | import time |
13 | 12 | from typing import TYPE_CHECKING, Any |
|
19 | 18 | from rich.table import Table |
20 | 19 | from rich.text import Text |
21 | 20 |
|
22 | | -from ..core.models import ImagePart |
| 21 | +from ..core.models import ImagePart, display_args |
23 | 22 | from ..io.diffrender import render_diff |
24 | 23 | from ..io.text_filter import strip_final_check, strip_reasoning |
25 | 24 | from ..prompts import _is_mode_reminder_text |
@@ -69,18 +68,6 @@ def _head_chars(text: str, n: int) -> str: |
69 | 68 | return text[:n] + "…" |
70 | 69 |
|
71 | 70 |
|
72 | | -def _arg_repr(value: Any, limit: int = 100) -> str: |
73 | | - """repr() of a tool-call argument, truncated to LIMIT chars total. |
74 | | -
|
75 | | - Long values (a long Bash command, a big JSON payload) are cut with |
76 | | - an ellipsis instead of being dropped from the label entirely. |
77 | | - """ |
78 | | - r = repr(value) |
79 | | - if len(r) <= limit: |
80 | | - return r |
81 | | - return r[: limit - 1] + "…" |
82 | | - |
83 | | - |
84 | 71 | def _tool_result_preview(content: str) -> str: |
85 | 72 | """Preview of a tool result: first N lines, capped at N chars. |
86 | 73 |
|
@@ -232,18 +219,7 @@ def _build_history_rows(self, full: bool = False) -> list[Any]: |
232 | 219 | rows.append(Text("reasoning ...", style="dim")) |
233 | 220 | if m.tool_calls: |
234 | 221 | for tc in m.tool_calls: |
235 | | - args = tc.arguments |
236 | | - if isinstance(args, str): |
237 | | - try: |
238 | | - args = json.loads(args) |
239 | | - except (json.JSONDecodeError, ValueError): |
240 | | - args = {} |
241 | | - if isinstance(args, dict): |
242 | | - params = " ".join( |
243 | | - f"{k}={_arg_repr(v)}" for k, v in args.items() if k != "content" |
244 | | - ) |
245 | | - else: |
246 | | - params = "" |
| 222 | + params = " ".join(f"{k}={v}" for k, v in display_args(tc.arguments).items()) |
247 | 223 | label = f"tool: {tc.name}({params})" if params else f"tool: {tc.name}" |
248 | 224 | rows.append(Text(f"▶ {label}", style="magenta")) |
249 | 225 | if body.strip(): |
|
0 commit comments