Skip to content

Missing token tracking in RouterAgent — incomplete cost observability #1138

@MervinPraison

Description

@MervinPraison

Summary

praisonaiagents/agent/router_agent.py:234 contains:

# TODO: Implement token tracking when LLM.get_response() is updated to return token usage

The RouterAgent — which dispatches to other agents — does not track token usage, making it impossible to attribute costs when using routing patterns.

Impact

  • In multi-agent systems with routing, token costs are invisible for the routing decisions
  • Cannot set budgets or alerts on routing overhead
  • Cost attribution is incomplete in production deployments

Suggested Fix

  1. Update LLM.get_response() to return token usage metadata alongside the response
  2. Have RouterAgent aggregate token usage from routing decisions + downstream agents
  3. Expose token metrics via the existing telemetry/trace infrastructure
  4. Add cost tracking to the agent's chat_history or session metadata

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions