Skip to content

Conversation

@ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Nov 26, 2025

Emit usage-delta events on AI SDK finish-step, allowing the UI to display live token counts as the AI generates multi-step responses.

demo.mp4

Changes

Backend:

  • Add UsageDeltaEvent type emitted on each finish-step
  • StreamManager emits usage after each tool call step completes
  • Forward events through AIServiceAgentSession → IPC

Frontend:

  • StreamingMessageAggregator stores active stream usage per messageId
  • WorkspaceStore exposes liveUsage in WorkspaceUsageState
  • CostsTab, RightSidebar, ChatMetaSidebar consume liveUsage for real-time context window display

Tests:

  • Unit tests for usage-delta handling in StreamingMessageAggregator
  • Integration test for usage-delta events during multi-step streams

Testing

This feature has been tested with OpenAI, Anthropic & Google.


Generated with mux

Emit usage-delta events on AI SDK finish-step, allowing the UI to
display live token counts as the AI generates multi-step responses.

Backend:
- Add UsageDeltaEvent type emitted on each finish-step
- StreamManager tracks and emits usage after each tool call step
- Forward events through AIService → AgentSession → IPC

Frontend:
- StreamingMessageAggregator stores active stream usage per messageId
- WorkspaceStore exposes liveUsage in WorkspaceUsageState
- CostsTab, RightSidebar, ChatMetaSidebar consume liveUsage for
  real-time context window display

Tests:
- Unit tests for usage-delta handling in StreamingMessageAggregator
- Integration test for usage-delta events during multi-step streams
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