# Cost Observability

> Tag every model and tool call with feature/route/user context and stream spend to dashboards in near-real-time — catch cost explosions before the invoice does.

- **Category**: Agentic AI
- **Subcategory**: Governance & Observability
- **Canonical URL**: https://designpattern.fyi/patterns/cost_observability/

---

## Description
**Intent**: Surface per-request, per-user, and per-feature cost and token consumption to operators in near-real-time.
**Context**: Running an agent product means paying for model calls and tool APIs based on which feature triggered them, which model was routed, how long the conversation ran, and how many tool calls the agent made. Operators can't wait for the monthly invoice to discover that one edge-case feature is burning the budget.
**Solution**: Tag every model and tool call with feature, route, anonymized user, and model id. Stream to a telemetry store. Build dashboards sliced by feature, model, tier, and hour. Set alerts on anomalies. Pair with cost-gating for hard limits.



## Use Cases
- Per-feature cost visibility is needed before the billing invoice reveals a problem.
- Telemetry can be tagged with feature, route, model id, and anonymized user.
- Operators will act on dashboards and alerts that surface cost anomalies.






## Trade-offs


### Advantages

- Fast detection of cost regressions — catch the spike same-day, not same-month.

- Provides inputs for capacity planning and pricing strategy.




### Considerations & Drawbacks

- Telemetry pipeline adds infrastructure overhead.

- Per-user attribution has privacy implications that require careful anonymization.







---
**Reference**: [Original Source](https://www.agentpatternscatalog.org/patterns/cost-observability/)

