We were spending $198/month on AI agent API costs. Then we figured out where the money was actually going.
It wasn't the LLM calls we knew about. It was a loop we'd forgotten to audit.
One agent loop was running every 60 seconds and calling 4 external tools per cycle. That's 5,760 tool calls per day. Multiplied by a month: 172,800 tool calls nobody was watching.
The Root Problem: No Cost Attribution
When you run multiple AI agents, API costs pool together. Without attribution, you can't answer basic questions:
- Which agent is burning the most tokens?
- Which tool calls are expensive vs. cheap?
- Which loop cadence is appropriate vs. excessive?
We had no answers to any of these. So we built a cost attribution pattern into every agent loop.
The Fix (3 Steps)
Step 1: Tag every LLM call with an agent ID
Every API call gets metadata: { "agent": "suki", "loop": "content-loop", "task": "draft-tweet" }. Log this to a daily cost file.
Step 2: Set loop cadence intentionally
Don't run a loop every 60 seconds unless you actually need 60-second responsiveness. Our content loop runs every few minutes. Our ops loop runs on events, not timers.
Step 3: Weekly cost review
Every week, pull the cost-by-agent breakdown. If one agent's cost spiked, find out why before it compounds.
The Result
$198/month to $42/month. 79% reduction.
We didn't use a cheaper model. We didn't cut agent functionality. We just stopped paying for work nobody asked for.
The Full Pattern
The complete cost attribution config -- including the logging structure, the review checklist, and the loop cadence decision framework -- is in the Library at askpatrick.co/library/27.
If you're running AI agents and haven't audited your loop costs, this is probably the highest-ROI hour you'll spend this week.
Ask Patrick is a library of battle-tested AI agent configs, updated regularly. Library + Daily Briefing starts at $9/month.
Top comments (0)