co-mono/todos/done/2025-08-09-14-27-17-display-tool-metrics.md
Mario Zechner 9544a8edf9 Display tool call metrics: Add ⚒ counter to token usage display
- Show tool call count alongside token metrics in TUI and console renderers
- TUI: Display at bottom with format "↑X ↓Y ⚒Z"
- Console: Show metrics after assistant messages complete
- Counter increments on each tool_call event
2025-08-09 20:10:15 +02:00

2 KiB

Display Tool Call Metrics

Status: Done Agent PID: 96631

Original Todo

agent: we should output number of tool calls so far next to input and output and cached tokens. Can use that hammer emoji or whatever.

Description

Add a tool call counter to the token usage display in the agent's TUI and console renderers, showing the number of tool calls made in the current conversation alongside the existing token metrics.

Read analysis.md in full for detailed codebase research and context

Implementation Plan

  • Add tool call counter property to TUI renderer (packages/agent/src/renderers/tui-renderer.ts:60-64)
  • Track tool_call events in TUI renderer's event handler (packages/agent/src/renderers/tui-renderer.ts:250-270)
  • Update TUI token display to show tool calls with ⚒ (packages/agent/src/renderers/tui-renderer.ts:284-305)
  • Add tool call counter to console renderer (packages/agent/src/renderers/console-renderer.ts)
  • Track tool_call events in console renderer (packages/agent/src/renderers/console-renderer.ts:45-130)
  • Display tool metrics after assistant messages in console (packages/agent/src/renderers/console-renderer.ts:124-127)
  • Test console mode: npx tsx packages/agent/src/cli.ts "what files are in /tmp"
    • Success: After response completes, shows metrics line with tool count like "↑123 ↓456 ⚒1" ✓
  • Test multiple tools: npx tsx packages/agent/src/cli.ts "create a file /tmp/test.txt with 'hello' then read it back"
    • Success: Should show ⚒2 (one for write, one for read) ✓
  • Test JSON mode: echo '{"type":"message","content":"list files in /tmp"}' | npx tsx packages/agent/src/cli.ts --json | grep tool_call | wc -l
    • Success: Count matches number of tool_call events in output ✓ (shows 1 tool call)
  • User test: Start interactive TUI npx tsx packages/agent/src/cli.ts, ask it to use multiple tools, verify counter increments live ✓

Notes

Using ⚒ (hammer and pick) symbol for tool calls