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
This commit is contained in:
Mario Zechner 2025-08-09 20:10:15 +02:00
parent 1887e33339
commit 9544a8edf9
7 changed files with 392 additions and 3 deletions

View file

@ -61,6 +61,7 @@ export class TuiRenderer implements AgentEventReceiver {
private lastOutputTokens = 0;
private lastCacheReadTokens = 0;
private lastCacheWriteTokens = 0;
private toolCallCount = 0;
private tokenStatusComponent: TextComponent | null = null;
constructor() {
@ -200,6 +201,8 @@ export class TuiRenderer implements AgentEventReceiver {
}
case "tool_call":
this.toolCallCount++;
this.updateTokenDisplay();
this.chatContainer.addChild(new TextComponent(chalk.yellow(`[tool] ${event.name}(${event.args})`)));
break;
@ -300,6 +303,11 @@ export class TuiRenderer implements AgentEventReceiver {
tokenText += chalk.dim(` (${cacheText.join(" ")})`);
}
// Add tool call count
if (this.toolCallCount > 0) {
tokenText += chalk.dim(`${this.toolCallCount}`);
}
this.tokenStatusComponent = new TextComponent(tokenText);
this.tokenContainer.addChild(this.tokenStatusComponent);
}