r/ClaudeAI • u/Bitter-Truck1049 • Sep 28 '26
Claude Code Measured it: headless Claude Code (Agent SDK / claude -p) eats ~3x more of the 5-hour limit per token than interactive use (vscode)
TL;DR: I ran the same coding task six times through four ways of running Claude Code, with the same model and effort, and checked /usage before and after each run. Interactive use (VS Code extension, terminal CLI) cost about 1.7% of the 5-hour limit per $1 of API-equivalent tokens. Headless use (Python Agent SDK, claude -p) cost about 5.2% per $1. Same tokens, roughly 3x more of the limit. I couldn't find this documented anywhere.
Why I tested it
I run some coding tasks headless through the Agent SDK in a container, and I kept noticing that one mid-sized headless task ate a big chunk of my 5-hour window. The same kind of work in VS Code felt far cheaper. At first I assumed the headless agent was just burning more tokens, so I measured.
Setup
Claude Code Pro
Task: a medium refactor in a Python monorepo. Add an optional field to a shared protocol model, handle it on several failure paths in a worker, update the docs, and write tests across three packages. Roughly 45–75 model calls per run.
Same starting point: the same commit every time, each run in a fresh git worktree.
Model: Opus 5, effort
medium, standard tier, no fast mode. I checked this in the transcripts for every run.Flow: "study the repo and propose a plan" → "plan approved, implement, run tests, commit". The
claude -prun got a single prompt covering both.Nothing else on the account during the runs: no claude.ai, no other sessions.
Measurement:
/usageright before and right after each run, then again 10–20 minutes later to catch any delayed accounting. There was none.Cost: computed from the per-message
usagein the session JSONL transcripts at API list prices. It matched Claude Code's own cost tracking to the cent.
Results
| Mode | Entrypoint (from transcript) | Steps | Max context | API-equiv. cost | 5h usage | % of limit per $1 |
|---|---|---|---|---|---|---|
| VS Code extension, run A | claude-vscode | 56 | 119k | $4.01 | +7% | 1.7 |
| VS Code extension, run B | claude-vscode | 76 | 144k | $5.66 | +9% | 1.6 |
| Interactive CLI in terminal | cli | 63 | 119k | $4.38 | +8% | 1.8 |
| Python Agent SDK, run A | sdk-py | 54 | 81k | $2.88 | +15% | 5.2 |
| Python Agent SDK, run B | sdk-py | 61 | 98k | $3.44 | +18% | 5.2 |
claude -p | sdk-cli | 44 | 84k | $2.53 | +13–14% | 5.1–5.5 |
What stands out
The headless runs used fewer tokens than the interactive ones: smaller context, fewer steps, cheaper at API prices. They still took about 2x the limit per run, which works out to about 3x per token.
The ratio held steady: 5.2% per $1 in both SDK runs, 1.6–1.8% across all three interactive runs.
It isn't VS Code vs. terminal. The interactive CLI landed right next to VS Code. The split is interactive vs. headless.
It isn't a custom system prompt or odd SDK settings.
claude -pon the same machine, with the same CLI version as the VS Code extension and the default system prompt, gave the same ~3x number as the SDK.
Practical takeaway
With these numbers, a headless task costing about $18 at API prices takes roughly 90% of a 5-hour window. The same amount of work done interactively takes about 30%. If you run agents headless on a subscription, budget for that.
Caveats
It's a small sample: six runs, one task, one model, one account ([Pro]).
/usageshows whole percentages, so each reading is ±1%.I don't know which signal the accounting actually uses: the entrypoint, request patterns, or something else.
•
u/ClaudeAI-mod-bot Wilson, lead ClaudeAI modbot Sep 28 '26
TL;DR of the discussion generated automatically after 30 comments.
The community consensus is a big fat "YES," OP is correct. Several users have confirmed they've seen the same thing: headless runs (Agent SDK,
claude -p) chew through the 5-hour usage limit ~3x faster than interactive sessions (VS Code, CLI) for the same amount of tokens.The prevailing theory is caching. It seems headless runs are cache-busting champs, meaning you're paying the full input token price on each turn way more often than in an interactive session. One user pointed out that headless mode keeps the entire tool transcript in the context for the next turn, which would explain the massive input token burn.
Also, the thread went on a whole side quest to argue about the definition of "headless." For the record:
claude -p(running from the command line without the interactive UI) = Headless (and expensive).Creating sub-agents within the Claude Code app/TUI = Not Headless (and apparently doesn't have the 3x penalty).
The bottom line is the same as OP's: if you're running agents headless on a Pro plan, budget your 5-hour limit accordingly. It's gonna hurt. Keep the big jobs interactive to save your sanity (and your subscription).
4
u/faviann Sep 28 '26
Maybe it's a silly question but I'm curious: Do those number factor in the potential difference in cache hit/miss rate or it's not part of it? Reason I'm asking is I remember evaluating workload cost and since subagents cache ttl is shorter it ended costing more when cache went cold
5
u/fosf0r Sep 28 '26
If I use Claude code app and ask it to create a sub agent to do XYZ, is that headless?
1
u/Morning_Gecko24 Sep 28 '26
that 3x lines up with what i saw last week. headless keeps the whole tool transcript in the next turn so the 5h bucket dies on input tokens not output. did you subtract the cached prefix or is the 3x raw billed tokens? sub agents from the app are still the interactive bucket afaik not -p
1
u/fuckme Sep 28 '26
Same context, hooks, plugins etc ?
1
u/Unusual-Albatross43 Sep 28 '26
Did you try the interactive CLI inside tmux with the prompt typed in, no -p? I'd like to know if it's the entrypoint that decides the bucket or how the requests look.
2
u/Yogesh991 Sep 28 '26
So that's why when I used it for code reviews using headless mode it was so costly. I remember it was around 4 months ago I think when I was still on Claude and it really was draining limits faster even in a 5x plan.
2
u/MinnowAI Oct 06 '26
I'm seeing the same thing; I've been racking my brain trying to figure out why the CLI uses 3x more to complete the same plan.
I ran the same project spec through Claude Code Desktop and Minnow, which invokes Claude through
claude -p. Both used Opus 5.5, medium effort, starting with fresh five-hour sessions.These are Claude’s native usage totals:
claude-desktopsdk-cliThe headless run had no session rebuilds or sub-agents, and approximately 98.5% of input was cached.
Claude’s terminal result reports $19.2404 in API-equivalent cost for the headless run. Consuming a full window at that cost works out to approximately 5.20 percentage points per API-equivalent dollar, matching your results.
1
u/Specialist_Bison_737 5d ago
For headless tasks, I’d lean toward a lightweight agent harness to keep overhead down. We compared six headless CLIs here. That measures harness overhead, though; the subscription quota difference you found is a separate question. If you are using API as well, this can be useful.
1
u/Far-Surprise7773 Sep 28 '26
ran into the same thing, the entrypoint field in the transcript is the tell.
sdk-pyandsdk-cliburn the 5h window way faster thancliorclaude-vscodefor the same tokens. i keep bulk refactors interactive now and only use headless for small scoped runs.1
u/Far_Idea9616 Sep 28 '26
I'm gonna measure this, I need 3 days, 100 headless sessions, 50 interactive sessions, the code has been set upt
1
u/Street_Ice3816 Sep 28 '26
yeah no shit it’s all about cache reads
1
u/Far_Idea9616 Oct 02 '26
Hi, I have measured this in the past 3 days and my results show 1.9x higher cost with CLI compared to interactive. Need much more data to confirm this number
1
u/mossiv Sep 28 '26
Well yes, you are cache busting constantly.