Skip to main content
Back to Blog
Deep Dive7 min read

How Budget Alerts Prevent Runaway AI Spend

A four-hour Claude Opus session with repeated context and multiple retries can easily exceed $50. If you stepped away from your terminal and the agent entered a retry loop, you might not know until you check the billing page the next morning. Budget alerts are the mechanism Styrby uses to keep spending visible and controllable before that happens.

How Costs Accumulate

Token costs are linear, but usage patterns are not. A typical session starts cheap: the first prompt sends a small context window and receives a focused response. As the session continues, context grows. By the twentieth turn, the agent is processing hundreds of thousands of tokens per exchange.

The most expensive pattern is the retry loop. The agent generates code, runs tests, tests fail, and the agent tries again. Each retry sends the full context plus the failed attempt plus the error output. Three retries can cost more than the original implementation.

Setting Up Budget Alerts

Styrby supports three budget periods: daily, weekly, and monthly. Each period can have independent thresholds and actions.

# Set a daily budget of $25 with all three alert levels
styrby budget set --period daily --limit 25 \
  --notify-at 80 \
  --slowdown-at 90 \
  --stop-at 100

Or configure via the dashboard with per-agent granularity:

SettingGlobalClaude OnlyCodex Only
Daily limit$50$30$20
Notify at80%80%80%
Slow down at90%90%-
Hard stop at100%100%100%

The Three Alert Actions

1. Notify

A push notification to your phone. The session continues uninterrupted. This is informational: you are approaching your budget but may have good reason to continue.

The notification includes: current spend, budget limit, which agent and project are driving costs, and the projected daily total based on current rate.

2. Slow Down

The CLI adds a 10-second delay between agent responses. This serves two purposes: it gives you time to check your phone and evaluate whether the session is productive, and it naturally reduces the token-per-minute rate.

Slowdown is not a hard restriction. The agent still works. You just have a natural pause to decide whether to continue, adjust the model, or stop the session.

3. Hard Stop

The session pauses. The agent cannot send or receive messages until you explicitly approve continued spending from your phone. The approval dialog shows: total spent today, the budget limit, and options to resume with a temporary increase, resume until end of session, or stop.

Hard stops are disruptive by design. They exist to prevent the scenario where a developer starts a session before lunch, the agent enters a retry loop, and by the time the developer returns, $80 has been spent on failed attempts.

Per-Agent vs. Global Budgets

Global budgets cap total spending across all agents. Per-agent budgets let you allocate differently based on cost profiles. A practical setup:

  • Global daily limit: $50 (hard ceiling)
  • Claude Opus 4: $30/day (expensive model, needs tighter control)
  • Claude Sonnet 4: $15/day (cheaper model, more headroom)
  • Codex: $10/day (used less frequently)

Per-agent budgets are independent of the global budget. If your Claude Opus budget is $30 and your Codex budget is $10, but your global limit is $35, the global limit triggers first when total spend across all agents hits $35.

Choosing the Right Thresholds

Thresholds that are too low create alert fatigue. If your daily budget is $10 and you regularly spend $8-9 on productive work, the 80% notification fires every day and you start ignoring it.

Thresholds that are too high defeat the purpose. A $200 daily budget with a hard stop at 100% means you can spend $200 before any intervention.

A reasonable starting point: set your daily budget to 1.5x your typical daily spend. If you normally spend $15/day, set the budget to $22. The 80% notification fires at $17.60, which is just above your normal range but well before dangerous territory. Review and adjust monthly.

Viewing Budget History

The Styrby dashboard shows a timeline of budget events: when alerts fired, which action was taken, and whether you overrode a hard stop. This history is useful for tuning thresholds and for understanding which projects or agents drive the most cost.

Ready to manage your AI agents from one place?

Styrby gives you cost tracking, remote permissions, and session replay across five agents.