Blog
Practical notes on running AI agents without surprise bills or surprise instructions. Code included.
Agent spend
- How to put a hard spending cap on OpenAI and Anthropic API calls from AI agents
Why alerts are not budgets, a small in-process guard and its limits, and enforcing per-agent and per-run caps at a proxy.
- How runaway agent loops burn budget, and how to detect them
Three shapes of loop, why growing context makes them quadratic, and three signals that catch them.
- How to estimate what an OpenAI or Anthropic API call will cost before you send it
Input tokens from prompt size, the max_tokens worst case, cached input, and a pre-flight check that refuses the call that would cross a budget.
MCP security
- MCP tool poisoning explained, with an example and a CI check
What a poisoned tool definition looks like, the variants, and a GitHub Actions job that catches them.
- MCP rug-pull attacks and how to pin tool definitions
Servers can change their tools after you approve them. Pin every definition and make each change go through review.