Skip to content

Commit ea8a2ba

Browse files
authored
Update render.py
1 parent c38e950 commit ea8a2ba

1 file changed

Lines changed: 2 additions & 26 deletions

File tree

‎python_agent_harness/tui/render.py‎

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from __future__ import annotations
99

10-
import json
1110
import math
1211
import time
1312
from typing import TYPE_CHECKING, Any
@@ -19,7 +18,7 @@
1918
from rich.table import Table
2019
from rich.text import Text
2120

22-
from ..core.models import ImagePart
21+
from ..core.models import ImagePart, display_args
2322
from ..io.diffrender import render_diff
2423
from ..io.text_filter import strip_final_check, strip_reasoning
2524
from ..prompts import _is_mode_reminder_text
@@ -69,18 +68,6 @@ def _head_chars(text: str, n: int) -> str:
6968
return text[:n] + "…"
7069

7170

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-
8471
def _tool_result_preview(content: str) -> str:
8572
"""Preview of a tool result: first N lines, capped at N chars.
8673
@@ -232,18 +219,7 @@ def _build_history_rows(self, full: bool = False) -> list[Any]:
232219
rows.append(Text("reasoning ...", style="dim"))
233220
if m.tool_calls:
234221
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())
247223
label = f"tool: {tc.name}({params})" if params else f"tool: {tc.name}"
248224
rows.append(Text(f"▶ {label}", style="magenta"))
249225
if body.strip():

0 commit comments

Comments
 (0)