IntentiAI

High reasoning budget on a call that runs many times

A high reasoning budget on a call that runs many times.

Rule reasoning-budget-in-loopCost audit

Why it costs money

Reasoning or thinking tokens are billed as output tokens, the most expensive kind, even when you never see them. A high effort setting or a large thinking budget can add thousands of them to a single call.

That can be worth it for one hard planning step. In an agent loop the same setting applies to every step, including routine ones such as reading a tool result or picking the next click. As an example, 20 steps with up to 16,000 thinking tokens each is up to 320,000 output tokens for one run, before any visible answer.

Example

Flagged

import Anthropic from "@anthropic-ai/sdk";

const anthropic = new Anthropic();

export async function executePlan(steps: string[]) {
  const results: string[] = [];
  for (const step of steps) {
    const res = await anthropic.messages.create({
      model: "claude-sonnet-4-5",
      max_tokens: 40000,
      thinking: { type: "enabled", budget_tokens: 32000 },
      messages: [{ role: "user", content: step }],
    });
    const text = res.content.find((b) => b.type === "text");
    results.push(text?.type === "text" ? text.text : "");
  }
  return results;
}

Fixed

import Anthropic from "@anthropic-ai/sdk";

const anthropic = new Anthropic();

export async function executePlan(steps: string[]) {
  const results: string[] = [];
  for (const step of steps) {
    const res = await anthropic.messages.create({
      model: "claude-sonnet-4-5",
      max_tokens: 4096,
      thinking: { type: "enabled", budget_tokens: 2048 },
      messages: [{ role: "user", content: step }],
    });
    const text = res.content.find((b) => b.type === "text");
    results.push(text?.type === "text" ? text.text : "");
  }
  return results;
}

How to fix it

Set an explicit, task-sized reasoning budget instead of a dynamic or very large one, and use low effort for routine steps. Reserve high effort for the one or two calls that actually need it, such as the initial plan.

Turn thinking off entirely for calls that only format, extract or pick from a short list. Check the reasoning token counts in the usage field of a few real runs to see where the budget is going.

What the audit detects

  • In files that make LLM calls: thinking_budget set to -1 (dynamic, uncapped), budget_tokens of 10,000 or more written as a keyword or object property, reasoning_effort or reasoningEffort set to "high", ThinkingConfig with -1, include_thoughts=True, or deepthought=True. Commented lines are ignored.
  • It is a warning when any LLM call in the repo runs inside a loop, and informational otherwise.
  • The setting often lives in a provider wrapper while the loop lives in the agent, so the rule does not require them to be in the same file. It does not confirm that the flagged call is the one inside the loop.
High reasoning budget on a call that runs many times: LLM cost rule | IntentiAI