Skip to content

Token usage + cost tracker per universe run #9

@Dhwanil25

Description

@Dhwanil25

Overview

Show users exactly how many tokens were used and what each universe run cost — broken down per agent and per provider.

UI mockup

After a run completes, show in the post-analysis panel:

Run cost breakdown
──────────────────────────────────────────
Researcher   claude-sonnet-4-6   1,240 in / 890 out   $0.017
Analyst      gemini-2.5-flash      980 in / 650 out   $0.001
Coder        gpt-4.1-mini          870 in / 720 out   $0.002
Reviewer     llama-3.3-70b (Groq)  760 in / 540 out   $0.001
Synthesis    claude-sonnet-4-6   3,200 in / 980 out   $0.024
──────────────────────────────────────────
Total                                                  $0.045

Implementation

  • Parse usage field from each provider's streaming response (all major providers return this)
  • Store { inputTokens, outputTokens } per agent in MAAgent
  • Look up price per token from the ALL_MODELS table already in SettingsPage.tsx
  • Display in post-analysis panel and the Analytics page

Relevant files

  • src/lib/multiAgentEngine.ts — capture usage from SSE responses
  • src/components/pages/UniversePage.tsx — display in post-analysis panel
  • src/components/pages/AnalyticsPage.tsx — aggregate cost over time

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions