Cost Attribution Errors

Goal Cost Tracking Frequency Common Category Operations Published View source on GitHub ↗

Issue: Costs Cannot Be Accurately Attributed to Users, Agents, or Use Cases

Frequency: Common

Symptoms

  • Cannot determine which user/agent caused costs
  • Chargeback calculations inaccurate
  • Cost centers receive wrong allocations
  • Cannot identify expensive operations
  • Billing disputes unresolvable

Root Cause Multi-tenant agent systems often lack proper cost tagging. When multiple users, agents, or use cases share infrastructure, costs get aggregated without attribution. Without request-level tagging that flows through to billing, organizations cannot implement accurate chargebacks or identify optimization targets.

Example

Shared agent infrastructure:
  
Month-end bill: $15,000

Attribution attempt:
  User A: ??? (no tracking)
  User B: ???
  Agent Type 1: ???
  Agent Type 2: ???
  
Actual breakdown (if tracked):
  User A: $12,000 (power user, expensive queries)
  User B: $800
  Agent Type 1: $2,500
  Agent Type 2: $11,700
  
Problem: User A's department wasn't charged
         Wrong team optimized the wrong agent

Contributing Factors

  • No request-level cost tagging
  • Shared API keys across users/agents
  • Async billing without request correlation
  • Missing metadata in LLM calls
  • Aggregated invoices only
  • No tenant isolation in billing

Eval Recipes

Test Cases

TestInputExpectedFailure Indicator
Multi-user sessionUsers A, B, C make requestsPer-user cost breakdownAggregated only
Agent attributionDifferent agent typesPer-agent costsUndifferentiated
Chargeback accuracyKnown cost distributionMatches actual>5% variance

Metrics

MetricTargetHow to Measure
Attribution coverage100%Requests with cost tags
Chargeback accuracy>98%Attributed vs. actual
Attribution latency<1 hourTime to cost visibility

Mitigation Strategies

Prevention

  1. Request tagging: Add user/agent/tenant ID to every LLM call
  2. Correlation IDs: Flow IDs from request to billing
  3. Per-tenant API keys: Separate keys for billing isolation
  4. Real-time attribution: Calculate costs per-request

Architecture Pattern

Request → [Tag: user_id, agent_id, tenant_id]
              ↓
         LLM Call (tags in metadata)
              ↓
         [Cost calculated with tags]
              ↓
         Attribution DB

Production Signals

Key Metrics

MetricAlert Threshold
attribution.coverage<100%
attribution.untagged_cost>$0
chargeback.variance>5%

Alerts

AlertConditionSeverity
Unattributed CostAny untagged spendP2
Attribution GapCoverage <95%P2
Chargeback MismatchVariance >10%P3

References