CloudCodeTree LogoCloudCodeTree
AI NewsTutorialsAbout
CloudCodeTree Logo
CloudCodeTree
  • AI News
  • Tutorials
  • About
← Back to AI News
Debug Your Loop's Token Spend in /usage — and Cap Subagent Cache Separately

Debug Your Loop's Token Spend in /usage — and Cap Subagent Cache Separately

Chris Harper

2 min read

Aug 28, 2026 · 12:06 UTC

AI
Workflow
Claude Code
Best Practices

TL;DR: Two new Claude Code additions make loop costs observable: /usage now shows tokens per loop iteration, and subagentPromptCacheTtl sets subagent cache lifetime independently from the main session.

Why loops go expensive silently. A /loop task runs in a shared session, so each iteration's tool output, file reads, and scratchpad writes accumulate in the context window. Tokens-per-run creeping upward is the tell — and until recently there was no easy way to see it.

The new /usage Loops breakdown adds a table for each named loop task: run count, total tokens, tokens per run (the average), and last-run time.

  • Flat tokens-per-run → each iteration starts clean; no context bleed
  • Rising tokens-per-run → context is accumulating; trim the scratchpad or add an explicit reset step at the end of each iteration
  • Single outlier run with 10× the tokens → a tool call returned a large payload; consider truncating before it goes back to Claude

The subagentPromptCacheTtl setting pairs with the promptCacheTtl covered here on Aug 26. They work independently: keep the main session warm at 1 hour while short-lived subagents expire at 5 minutes — so a dozen quick subagents don't each hold a 1-hour cache slot you're paying for after they're done.

// .claude/settings.json (API-key or cloud-provider sessions only)
{
  "promptCacheTtl": "1h",
  "subagentPromptCacheTtl": "5m"
}

Limits: Both settings apply only to API-key and cloud-provider (Vertex/Bedrock) sessions — regular claude.ai plan users don't control cache TTL. The /usage Loops table covers named loop tasks; anonymous or inline subagent spawns show in the overall session total only, not as labeled rows.

Sources: Claude Code Changelog — code.claude.com · Claude Code Changelog August 2026 — Gradually · Claude Code Subagents: 2026 Production Playbook — Totalum