Part 3: Production

Chapter 18: Cost Management

Agentic systems can be expensive. Every reasoning step, tool call, and generated token costs money. Without attention, costs can spiral.

Understanding the Cost Drivers

Cost Optimisation Strategies

  1. Right-size your model: Not every task needs the most powerful model
  2. Optimise context: Large contexts mean large costs. Keep context lean
  3. Limit iterations: Set reasonable bounds on agent loops
  4. Cache where possible: If the same queries recur, consider caching responses
  5. Monitor and alert: Track cost per conversation. Set budgets and investigate anomalies

The Cost-Quality Trade-off

Cheaper isn't always better. A cheaper model that gives poor answers damages trust.

Key Principle

The goal is optimal cost for acceptable quality. Understand your quality threshold first, then optimise cost to meet it — not the other way around.

☰ Contents