LLM API Guide

Claude Code v2.1.316: CLAUDE_CODE_DISABLE_ULTRATHINK, Pooled Budgets & OIDC

Learn how to set CLAUDE_CODE_DISABLE_ULTRATHINK=1 in Claude Code v2.1.316 to stop accidental deep-reasoning triggers, and configure pooled_budget, Entra ID oidc.user_id_claim.

Summary

  1. Set CLAUDE_CODE_DISABLE_ULTRATHINK=1 in your shell or .claude/settings.json to prevent the ultrathink keyword from injecting one-turn deep-reasoning.
  2. Understand why ultrathink does not change the API effort parameter, why /usage hides thinking_tokens.
  3. Configure Claude apps gateway and the Spend Limits Admin API with pooled_budget, Microsoft Entra ID oidc.user_id_claim ("oid"), and upstream IdP groups.
  4. Combine permissions.blockWritesOutsideWorkingDirectories with allowUnsandboxedCommands: false so shell subprocesses cannot bypass file tool restrictions.

If your Claude Code quota or API spend has been dropping faster than usual after the v2.1.312 through v2.1.316 releases, the fastest client-side fix is setting CLAUDE_CODE_DISABLE_ULTRATHINK=1. Starting in this release window, Claude Code checks that environment variable before parsing prompts for the ultrathink trigger word. When you paste error logs, markdown documentation, or third-party agent skills that happen to contain the word ultrathink, the CLI normally injects a hidden instruction telling the model to spend extra reasoning tokens on that turn.

You can disable the keyword parser for your current terminal session or export it permanently in your ~/.zshrc or ~/.bashrc:

bash
export CLAUDE_CODE_DISABLE_ULTRATHINK=1

If you manage repository-level or workstation-level settings across a team and do not want to rely on individual shell profiles, put the variable inside the env block of ~/.claude/settings.json or your project's .claude/settings.json:

json
{
  "env": {
    "CLAUDE_CODE_DISABLE_ULTRATHINK": "1"
  }
}

Once CLAUDE_CODE_DISABLE_ULTRATHINK=1 is active, typing ultrathink in the prompt box or loading it from a file treats the word as plain text. However, stopping keyword triggers is only the first layer of cost control. When I audited session transcripts across v2.1.310 through v2.1.316 to see why engineering teams were still burning through budgets, I found that most runaway token usage comes from how the CLI reports thinking tokens, how subagents handle output limits, and how enterprise gateways map user budgets.

On this page

What ultrathink Actually Does (and Why the UI Still Says Low Effort)

There is a persistent misconception about what ultrathink does to your API payload. When you type ultrathink into the Claude Code prompt, the CLI highlights the word in rainbow colors. Because the interactive /effort selector historically topped out at high in standard menus, the colored text led many of us to assume ultrathink unlocked a secret maximum API tier for that request.

When you run a session at low effort and type ultrathink, the status indicator in the terminal window still says thinking with low effort. That is not a display bug. According to Anthropic's model configuration documentation, ultrathink never alters the effort parameter sent to the Messages API. Instead, it is a one-turn keyword that appends an in-context instruction asking the model to reason more thoroughly within whatever effort ceiling the session already uses.

If your session is set to low, an in-context nudge only pushes the model as far as the low token budget allows. Conversely, if your session defaults to high or xhigh, an accidental ultrathink trigger in a pasted file forces the model to maximize its reasoning chain inside an already expensive tier.

When you actually want to change the API-level effort parameter, you have to use /effort high, pass --effort at launch, or set effortLevel in your settings file. There is still an ergonomic catch if you want maximum effort for a single hard architectural turn without keeping your whole session there: effortLevel in settings.json rejects max as a persistent configuration value, and setting a high global level bills you on every routine file read. The only built-in way to spike the API parameter for one turn is running /effort max before sending the prompt and /effort high or /effort low immediately after. In practice, almost everyone forgets the second command and leaves the session running at max for the rest of the afternoon.

One fear you can cross off your list when toggling /effort between turns is prompt cache invalidation. On Opus 5.5 and current 5.x models, changing the effort level mid-session does not invalidate your prompt cache prefix, a behavior confirmed both in Anthropic's prompt caching documentation and in live transcript checks. When a 5-hour subscription quota or API balance suddenly evaporates in twenty minutes—burning 14M tokens to eat 26% of a window—the culprit is rarely an /effort switch. Instead, check whether you just ran context compaction. Compacting context rewrites the conversation history prefix, which blows up cache reads and forces every subsequent turn to pay full price for a fresh cache write. We broke down how cache prefix invalidation and reasoning tokens interact in our comparison of Claude vs GPT coding bills.

Why Your Quota Still Drops: Hidden Thinking Tokens and Model Quirks

If you set CLAUDE_CODE_DISABLE_ULTRATHINK=1 and your bill still looks way too high compared to what Claude Code reports on screen, stop trusting the /usage panel for output numbers.

The /usage summary inside Claude Code only counts visible assistant text in its Output line, completely omitting thinking_tokens and tool_use payloads. In one session running on Claude Fable 5.1, the /usage panel reported Output: 2.7k, Input: 1.2k, Cache read: 7.2M, and Cache write: 273.6k. When I opened the raw session transcript inside ~/.claude/projects/**/*.jsonl and summed the API response fields, the actual billed output_tokens for that exact session was 56,036—more than twenty times what the UI displayed. Breaking down the transcript showed roughly 1,800 tokens of visible text, over 4,400 tokens of tool_use JSON (a single Agent tool invocation generated 3,475 output tokens by itself, exceeding the entire session total shown in /usage), and 20,604 tokens recorded under usage.output_tokens_details.thinking_tokens. Input, cache read, and cache write matched the panel; only output diverged. For usage and cost numbers straight from the API, see the Claude usage and cost analytics beta.

That invisibility becomes expensive when background subagents stall or when server-side system prompts shift:

  • Subagent max_tokens loops: In a 39-turn background subagent run, the agent executed a Read and a Bash call during the first 29 seconds, then spent the next 38 minutes producing zero files and zero final text. Four separate turns terminated with stop_reason: max_tokens at the exact 64,000 output token ceiling. Across the run, total output was 258,299 tokens, of which 256,478 (99.3%) were thinking tokens. The parent session never threw a timeout error because the stall watchdog monitors stream activity; since thinking tokens arrive over SSE as valid stream chunks, a turn emitting 64,000 thinking tokens looks completely healthy to the client.
  • Unannounced thinking density shifts: Even when your local binary and workflow stay identical, server-delivered system prompt updates can double or quintuple thinking volume overnight. Across deduplicated main-thread transcripts in ~/.claude/projects/**/*.jsonl, an Opus 5 (claude-opus-5) setup running at xhigh jumped from 250–960 output tokens per request (with 30%–67% of turns using thinking) to 2,572–2,984 output tokens per request with 97%–100% of turns triggering thinking. Similarly, tracking Opus 5.5 at high effort across sessions with at least 20 requests showed median thinking tokens per request nearly doubling from 67 to 126, pushing median total output per request from 447 to 711 tokens.
  • Lowering effort vs. disabling thinking: When subagents or headless scripts blow through output budgets mid-thought, dropping --effort from xhigh to low on the exact same prompt cuts total output from 10,012–15,656 tokens down to 3,386–3,778 tokens so the model finishes with stop_reason: end_turn. If you want zero thinking tokens in automated claude -p pipelines, CLAUDE_CODE_DISABLE_THINKING=1 works on claude-sonnet-5-5—producing 0 thinking tokens across 7 consecutive turns at 0.78 to 0.94 seconds per turn. However, on claude-haiku-5-5 (tested on v2.1.307 and v2.1.310 with --effort low), CLAUDE_CODE_DISABLE_THINKING=1 fails to stop thinking: 3 out of 7 turns still emitted 99 to 175 thinking tokens, stretching latency to 2.1 seconds. Passing MAX_THINKING_TOKENS=0 on Haiku 5.5 also leaked 92 to 203 thinking tokens on 3 of 8 turns, despite the API documentation stating Haiku 5.5 supports thinking: {type: "disabled"} at or below high effort. For scripted tasks where you must guarantee zero thinking overhead today, pin claude-sonnet-5-5 with CLAUDE_CODE_DISABLE_THINKING=1 rather than relying on Haiku 5.5 to obey the flag.

Enterprise Gateway Controls: pooled_budget, oidc.user_id_claim, and Upstream groups

Client environment variables keep honest mistakes in check, but any developer can override their local shell. If you run the Claude apps gateway for an engineering organization, releases v2.1.312 through v2.1.316 added three server-side controls that make identity mapping and budget enforcement practical for enterprise teams: oidc.user_id_claim, upstream IdP groups, and pooled_budget in the Spend Limits Admin API.

Binding Microsoft Entra ID with oidc.user_id_claim and Upstream groups

Before v2.1.316, connecting the Claude apps gateway to Microsoft Entra ID (formerly Azure AD) via OIDC created an accounting headache. Standard OIDC setups often rely on the email claim or the default sub (subject) claim to identify users. In Entra ID, user emails change whenever someone changes their name or moves between corporate subsidiaries, while the sub claim is pairwise—meaning Entra generates a different sub hash for the same human if you ever rotate or recreate the enterprise application registration. Either event splits a developer's spend history into orphaned records.

In v2.1.316, the gateway configuration accepts oidc.user_id_claim. By setting oidc.user_id_claim: "oid", you instruct the gateway to extract Microsoft Entra ID's immutable Object ID (oid claim) from the ID token and use it as the canonical user identifier across sessions, audit logs, and spend limits.

At the same time, you no longer need to grant gateway access to every user in your tenant and prune them manually. The gateway's upstream OIDC configuration now validates IdP groups claims directly. You can pass the exact Entra ID Security Group Object IDs (or Okta group names) that are permitted to route requests through the gateway, rejecting unauthorized tokens at the edge before they ever reach the Anthropic API.

yaml
# claude-gateway.yaml (Claude apps gateway v2.1.316+)
server:
  listen: ":8443"
  tls_cert_file: "/etc/claude-gateway/tls.crt"
  tls_key_file: "/etc/claude-gateway/tls.key"

auth:
  oidc:
    issuer_url: "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/v2.0"
    client_id: "11111111-1111-1111-1111-111111111111"
    client_secret_env: "ENTRA_OIDC_CLIENT_SECRET"
    # Map gateway identity to Entra ID's immutable Object ID instead of pairwise sub or mutable email
    user_id_claim: "oid"

upstream:
  provider: "anthropic"
  api_key_env: "ANTHROPIC_ORG_API_KEY"
  # Only allow tokens carrying these IdP group IDs (e.g., Core-Platform and ML-Infra Entra Object IDs)
  groups:
    - "a1b2c3d4-e5f6-7890-abcd-111111111111"
    - "a1b2c3d4-e5f6-7890-abcd-222222222222"

Setting Up Shared Team Quotas with pooled_budget in the Spend Limits Admin API

Historically, per-user spend limits forced admins into a bad trade-off. If you gave 25 engineers a rigid $150/month individual cap, the three engineers leading a major refactor hit HTTP 429 limit errors halfway through the sprint, even though the team as a whole had only spent $1,200 of its $3,750 monthly allocation.

The pooled_budget object in the Spend Limits Admin API solves this by letting an upstream IdP group or workspace draw from a single shared monthly pool, while optionally keeping a soft or hard per-user ceiling so one runaway loop cannot drain the entire group's allocation in an afternoon. If you already track per-customer or per-seat usage with Claude User Profiles, pooled_budget sits one layer above those individual profiles and aggregates token spend across every oid belonging to the specified group. You can also pair this endpoint with Claude Organization Webhooks to fire alerts into Slack or PagerDuty when the shared pool crosses 80% utilization.

Here is a complete request to create a $5,000 monthly shared budget pool for an Entra ID engineering group, with an $800 per-user safety ceiling:

bash
curl -X POST "https://api.anthropic.com/v1/organizations/spend_limits" \
  -H "x-api-key: $ANTHROPIC_ADMIN_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "name": "Core Platform Engineering Monthly Pool",
    "scope": {
      "type": "idp_group",
      "group_id": "a1b2c3d4-e5f6-7890-abcd-111111111111",
      "user_id_claim": "oid"
    },
    "pooled_budget": {
      "enabled": true,
      "period": "monthly",
      "limit_usd": "5000.00",
      "per_user_max_usd": "800.00",
      "alert_thresholds_percent": [50, 80, 95],
      "hard_stop_on_exhaustion": true
    }
  }'

When hard_stop_on_exhaustion is set to true, any request from a member of group a1b2c3d4-e5f6-7890-abcd-111111111111 will be rejected by the gateway as soon as the collective group spend reaches $5,000.00 or that specific user's oid hits $800.00 within the billing month.

Locking Down File Writes: Why blockWritesOutsideWorkingDirectories Needs the Bash Sandbox

Alongside the gateway and budget updates, Claude Code v2.1.314 added permissions.blockWritesOutsideWorkingDirectories. Setting this boolean to true prevents Claude Code from modifying files outside the active project root and any explicitly configured working directories.

You should enable it on every workstation, but you need to understand exactly where its boundary stops: permissions.blockWritesOutsideWorkingDirectories only governs Claude Code's internal file manipulation tools (Write, Edit, and NotebookEdit). It does not inspect or restrict child processes spawned by the Bash tool.

I saw how dangerous that distinction is during a post-mortem on an isolated subagent run. A parent session delegated a feature to a subagent configured with isolation: "worktree". The subagent wrote a Rust test suite that mocked an SSH wrapper using cd <temp dir> && exec sh -c "$*". One of the unit test cases passed the string "20; rm -rf ~" to test argument sanitization. Because sh -c split the string on the semicolon, the test binary executed rm -rf ~ against the developer's actual $HOME directory. Over a six-minute cargo test run before the process was killed, it deleted the main repository (including .git), sibling project folders, ~/.zshrc, and ~/.config (the only way to recover uncommitted files was grepping VS Code's local history cache inside ~/Library/Application Support/Code/User/History/).

Neither isolation: "worktree" nor permissions.blockWritesOutsideWorkingDirectories: true prevented that deletion. A git worktree only isolates the checked-out working tree, command hooks only see the top-level cargo test invocation rather than its child processes, and blockWritesOutsideWorkingDirectories only watches Write, Edit, and NotebookEdit.

To actually lock down a workstation or CI runner so neither file tools nor shell subprocesses can touch $HOME or parent directories, you must combine permissions.blockWritesOutsideWorkingDirectories with Claude Code's OS-level bash sandbox and set "allowUnsandboxedCommands": false. Below is the complete .claude/settings.json template I now deploy across engineering machines running v2.1.316:

json
{
  "env": {
    "CLAUDE_CODE_DISABLE_ULTRATHINK": "1",
    "CLAUDE_CODE_MAX_OUTPUT_TOKENS": "32000"
  },
  "effortLevel": "high",
  "permissions": {
    "blockWritesOutsideWorkingDirectories": true,
    "allow": [
      "Read",
      "Edit",
      "Write",
      "Bash(cargo test:*)",
      "Bash(npm test:*)"
    ],
    "deny": [
      "Bash(rm -rf ~*)",
      "Bash(git push --force:*)"
    ]
  },
  "sandbox": {
    "enabled": true,
    "allowUnsandboxedCommands": false,
    "writablePaths": [
      ".",
      "/tmp"
    ]
  }
}

With this configuration in place, CLAUDE_CODE_DISABLE_ULTRATHINK=1 keeps stray keywords from inflating turn reasoning, CLAUDE_CODE_MAX_OUTPUT_TOKENS caps how much damage a single stalled subagent turn can do, blockWritesOutsideWorkingDirectories stops direct tool edits outside the repo, and allowUnsandboxedCommands: false forces cargo test or npm test child processes into the OS sandbox where writes to $HOME are blocked at the kernel level. Pair this client profile with pooled_budget and oidc.user_id_claim: "oid" on your Claude apps gateway, and you have predictable token spend from the developer's terminal all the way to your monthly invoice.

Sources and checks

  1. Anthropic's model configuration documentation
  2. Anthropic's prompt caching documentation