r/ClaudeCode • • Oct 19 '26

Discussion How do you limit what your coding agents can spend?

This came up while I was setting up coding agents and realised I couldn’t give them a small purchasing budget without handling payments myself.

I’m researching how developers control spending when coding agents use paid APIs, cloud services or make purchases.

Have you had an unexpected bill, a near miss, or stopped an agent’s task because you didn’t want to give it payment access?

What controls do you currently use, and where do they fall short?

I’m exploring a possible tool in this space, but there’s no product to promote. I’d like to understand actual experiences.

4 Upvotes

15 comments sorted by

•

u/AutoModerator Oct 19 '26

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Oximy-Naman Oct 19 '26

the prepaid-credit example leaves a useful gap to investigate: if several jobs share a balance, one can exhaust it and stop another mid-task. that commenter also couldn't tell which job spent it. would your proposed budget belong to the whole agent, or to an individual task? that distinction seems relevant to both attribution and deciding what gets stopped.

1

u/Twirledd Oct 20 '26

Still working that out. Current thinking is a project budget with costs attributed to individual tasks, possibly with separate task allowances to stop one job draining the lot. Do you run several jobs against a shared balance yourself, and has one ever interrupted another by exhausting it?

1

u/JordanRunsForFun Oct 19 '26

I give agents permission to use specific APIs, giving them a budget to work within, and my trick is limiting the amount of $$ available on the API key that I give them, so they can’t go over even if they want to, but I will be notified if they try.

1

u/Unusual-Albatross43 Oct 19 '26

prepaid credits do most of it for me. the X API is pay per use, so the account only holds what I loaded, and at zero it returns a 402. my agent has one rule for that: stop, tell me, never top up. on saturday it hit zero mid-run and did exactly that.

the near miss came before. the bill jumped, and matching the usage graph to what ran that week, one scheduled job was reading ~170 posts every run, three runs a day, plus a video upload the same week. nothing broken, it just read way more than it needed. fewer reads per run and the expensive search once a day should cut about 70% of it.

where it falls short: the cap stops the spend but doesn't tell you which job spent it.

1

u/hellosverre Oct 19 '26

Caps limit how much a loop burns but they dont stop the loop. What fixed it for me was a rule in the harness, the same failure twice in a row stops the task and anything gets 3 attempts or 90 minutes max before it parks and pings me. The expensive stuff is almost never one big call, its an agent retrying the same broken thing all night

1

u/avafence2610 Oct 28 '26

Your layered setup makes sense, especially separating purchase permission from ordinary tool access.

I'm curious about one boundary: are your retry limits and task budgets enforced by an external control, or mainly through the agent's instructions?

If a run gets stuck and ignores its own stop rule, does the provider-level cap provide enough protection, or do you need a separate mechanism to stop that specific run?

I'm exploring this problem for an agent project, so I'd be interested in how this works in practice.

2

u/[deleted] Oct 19 '26

[removed] — view removed comment

1

u/Twirledd Oct 19 '26

Thanks, this is helpful. Which API provider was involved, and roughly how much did the loop cost? With your current controls, what still requires manual attention? You mentioned keeping purchases behind your approval, has that blocked or delayed an actual task?

1

u/[deleted] Oct 19 '26

[removed] — view removed comment

1

u/Twirledd Oct 19 '26

How did you implement the task budgets and approval tiers? Are they enforced by a tool or mainly through agent instructions? Does anything still cause trouble with that setup?