My agent spent $3.64 answering one question I thought was free
GoldBroccoli7073 · reddit · 2026-09-11
A developer asked their agent to find out what people are saying about MCP servers, wired to the X API, and got a $3.64 bill: 300 posts at $0.005 each plus 214 user lookups at $0.010. Every call was individually sensible, but nothing in the responses told the model what it was spending.
The counterintuitive core: reads are billed per resource returned, not per request — maxresults 100 vs 5 is the same single request but a 20x price difference ($0.50 vs $0.025).
Four reusable design principles for any metered API behind a model:
- Put the price in the tool description: the model reads them before every call; stating billing is per-resource and asking for the smallest count shifts default behavior significantly.
- Give it a free way to size the problem: X's counts endpoint returns match counts without touching the read budget — a free "what would this cost" tool beats one that's 10% cheaper.
- Batch instead of loop, never paginate yourself: one lookup takes 100 ids; an agent walking pages via nexttoken is writing itself a blank cheque.
- Hard clamps in config: resolve every caller value against a default and squeeze into [min, max] from env vars the model never sees; omitted fields fall back to default 10, not the max.
The split is deliberate: descriptions make the model want the cheap thing; config makes the expensive thing impossible. Still unsolved: no per-session spend ceiling in the server, so a determined model can keep paginating — provider-side budget controls are the only real backstop.
More from coding & agent
- OpenAI ships GPT-Live prompting guide: copying your old prompts won't hit SOTA — craigsdennis · 2026-09-11
- Meta's Auto-RecSys runs autonomous research on industry-scale recommenders — omarsar0 · 2026-09-11
- Hamel Husain: The Revenge of the Data Scientist — AI Evals are the real job — HamelHusain · 2026-09-11
- One prompt builds a browser Rollercoaster Tycoon clone: "We are so EARLY" — _philschmid · 2026-09-11
- How to feed Claude Code local meeting notes without shipping transcripts to the cloud — Tight_Claim8869 · 2026-09-11
- Every Builds Personal Benchmarks for Each Employee — Finds a Smaller Model Beats the Big Ones — every · 2026-09-11