OC-301i · Module 2

Cost Analysis & Attribution

3 min read

Agent system costs are dominated by LLM API charges. Every prompt token and every completion token costs money. A system that processes 10,000 tasks per day at an average cost of $0.05 per task costs $500 per day — $15,000 per month. Cost optimization starts with understanding where the money goes.

Cost attribution assigns every API call to the agent, task, and workflow that triggered it. This reveals which agents are the most expensive (the one that loads the most context), which tasks cost the most per execution (the ones with the longest outputs), and which workflows have the worst cost-to-value ratio (high cost, low business impact). Without attribution, cost optimization is blind — you cut costs globally and degrade high-value workflows alongside low-value ones.

  1. 1. Instrument Cost Per Call Tag every API call with: agent ID, task ID, workflow ID, prompt token count, completion token count, and cost. Aggregate by agent, by task type, and by workflow.
  2. 2. Identify Cost Concentration Find the top 20% of tasks by cost. These typically account for 80% of total spend. Analyze why they are expensive: large context, long outputs, multiple retries, or unnecessary API calls.
  3. 3. Calculate Cost-to-Value Ratio For each task type, calculate: cost per execution / business value per execution. High cost-to-value ratios are optimization targets. Low cost-to-value ratios are leave-alone — they are delivering value efficiently.