Skip to content

feat: display tool call count and turn duration in MessageBubble - #691

Closed
avoidwork wants to merge 2 commits into
mainfrom
feat/display-tool-call-count-and-turn-duration
Closed

feat: display tool call count and turn duration in MessageBubble#691
avoidwork wants to merge 2 commits into
mainfrom
feat/display-tool-call-count-and-turn-duration

Conversation

@avoidwork

Copy link
Copy Markdown
Owner

Summary

  • Status: completed
  • Summary: Add tool call count and turn duration display to the MessageBubble component in the TUI. Each assistant message bubble now shows how many tools were called during that turn and the elapsed time from start to finish.
  • Details:
    • app.js: Store startTime (epoch ms) alongside time (formatted string) when creating the assistant message. In finalizeStreaming, compute toolCallCount (count on_tool_start events) and turnDurationMs (Date.now() - startTime). Pass these to the messageList update.
    • messageList.js: Store startTime in message data. Pass toolCallCount and turnDurationMs to MessageBubble.
    • messageBubble.js: Accept toolCallCount and turnDurationMs props. Render them as 🔧 N tools · ⏱ X.Xs for assistant messages only.
    • Tests: Added 25 new tests covering addMessage, updateMessage, setMessages, and MessageBubble rendering logic for the new fields.
    • Edge case: No tools called → stats element not rendered.
    • Edge case: Sub-second durations handled correctly (rounds to nearest tenth).
    • Edge case: User/system messages never show stats (role === "assistant" guard).
  • Artifacts: src/tui/app.js, src/tui/messageList.js, src/tui/messageBubble.js, tests/unit/messageListToolStats.test.js
  • Next Steps: none

- Switch from agent.stream() (returns Promise, not async iterable) to
  agent.streamEvents() which is the correct async iterable API
- Fix content extraction: streamEvents v2 chunks are AIMessageChunk
  objects with content at chunk.content, not chunk.kwargs.content
- Count tool calls from tool_call_chunks and tool_calls on message
  chunks since deepagents doesn't emit on_tool_start/end events
- Render tool call display from on_chat_model_end output
- Add events rendering layer to MessageBubble with normalized event
  type labels and deduplicated counts
@avoidwork avoidwork closed this Aug 6, 2026
@avoidwork
avoidwork deleted the feat/display-tool-call-count-and-turn-duration branch August 6, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant