Skip to content

Commit aee08e0

Browse files
committed
dashboard: simplify execution log view and highlight tool calls (#74)
1 parent 651fcd9 commit aee08e0

2 files changed

Lines changed: 29 additions & 28 deletions

File tree

src/cyberagent/ui/dashboard.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,40 +167,58 @@ def _render_execution_log(st: Any, execution_log: str | None) -> None:
167167
st.dataframe(rows, width="stretch", hide_index=True)
168168
else:
169169
st.write(rows)
170-
_render_execution_log_details(st, parsed)
171170

172171

173172
def _build_execution_log_rows(entries: list[object]) -> list[dict[str, object]]:
174173
rows: list[dict[str, object]] = []
175174
for index, entry in enumerate(entries, 1):
176175
if isinstance(entry, dict):
177176
step_type = str(entry.get("type", "-"))
177+
tool_name = (
178+
_extract_tool_name(entry) if _is_tool_call_event(step_type) else "-"
179+
)
178180
source = str(entry.get("source", "-"))
179181
summary = _summarize_execution_entry(entry)
180182
else:
181183
step_type = type(entry).__name__
184+
tool_name = "-"
182185
source = "-"
183186
summary = _truncate_text(str(entry), 200)
184187
rows.append(
185188
{
186189
"step": index,
187190
"type": step_type,
191+
"tool": tool_name,
188192
"source": source,
189193
"summary": summary,
190194
}
191195
)
192196
return rows
193197

194198

195-
def _render_execution_log_details(st: Any, entries: list[object]) -> None:
196-
if not hasattr(st, "expander"):
197-
return
198-
for index, entry in enumerate(entries, 1):
199-
with st.expander(f"Step {index} details"):
200-
if hasattr(st, "code"):
201-
st.code(json.dumps(entry, indent=2, ensure_ascii=True, default=str))
202-
else:
203-
st.write(entry)
199+
def _is_tool_call_event(step_type: str) -> bool:
200+
normalized = step_type.strip().lower()
201+
return "toolcall" in normalized or ("tool" in normalized and "call" in normalized)
202+
203+
204+
def _extract_tool_name(entry: dict[str, object]) -> str:
205+
name = entry.get("name")
206+
if isinstance(name, str) and name.strip():
207+
return name.strip()
208+
209+
content = entry.get("content")
210+
if isinstance(content, dict):
211+
content_name = content.get("name")
212+
if isinstance(content_name, str) and content_name.strip():
213+
return content_name.strip()
214+
if isinstance(content, list):
215+
for item in content:
216+
if isinstance(item, dict):
217+
item_name = item.get("name")
218+
if isinstance(item_name, str) and item_name.strip():
219+
return item_name.strip()
220+
221+
return "-"
204222

205223

206224
def _summarize_execution_entry(entry: dict[str, object]) -> str:

tests/cyberagent/test_dashboard_ui.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,7 @@ def _fake_resolve(
392392

393393
def test_render_task_details_shows_status_reasoning(monkeypatch) -> None:
394394
writes: list[object] = []
395-
code_values: list[str] = []
396395
dataframe_data: list[object] = []
397-
expander_labels: list[str] = []
398396

399397
class _TitleCol:
400398
def __enter__(self):
@@ -428,23 +426,9 @@ def markdown(self, _text: str) -> None:
428426
def write(self, text: object) -> None:
429427
writes.append(text)
430428

431-
def code(self, text: str) -> None:
432-
code_values.append(text)
433-
434429
def dataframe(self, data: object, **_kwargs: object) -> None:
435430
dataframe_data.append(data)
436431

437-
class _ExpanderCtx:
438-
def __enter__(self):
439-
return None
440-
441-
def __exit__(self, exc_type, exc, tb):
442-
return False
443-
444-
def expander(self, label: str):
445-
expander_labels.append(label)
446-
return self._ExpanderCtx()
447-
448432
def button(self, _text: str) -> bool:
449433
return False
450434

@@ -483,9 +467,8 @@ def rerun(self) -> None:
483467
rows = dataframe_data[0]
484468
assert isinstance(rows, list)
485469
assert rows[0]["type"] == "ToolCallExecutionEvent"
470+
assert rows[0]["tool"] == "task_search"
486471
assert "task_search" in str(rows[0]["summary"])
487-
assert len(expander_labels) == 1
488-
assert len(code_values) == 1
489472

490473

491474
def test_render_execution_log_fallbacks_to_code_for_invalid_json() -> None:

0 commit comments

Comments
 (0)