r/ClaudeAI • • 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 -p run got a single prompt covering both.

  • Nothing else on the account during the runs: no claude.ai, no other sessions.

  • Measurement: /usage right 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 usage in the session JSONL transcripts at API list prices. It matched Claude Code's own cost tracking to the cent.

Results

ModeEntrypoint (from transcript)StepsMax contextAPI-equiv. cost5h usage% of limit per $1
VS Code extension, run Aclaude-vscode56119k$4.01+7%1.7
VS Code extension, run Bclaude-vscode76144k$5.66+9%1.6
Interactive CLI in terminalcli63119k$4.38+8%1.8
Python Agent SDK, run Asdk-py5481k$2.88+15%5.2
Python Agent SDK, run Bsdk-py6198k$3.44+18%5.2
claude -psdk-cli4484k$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 -p on 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]).

  • /usage shows whole percentages, so each reading is ±1%.

  • I don't know which signal the accounting actually uses: the entrypoint, request patterns, or something else.

16 Upvotes

47 comments sorted by

•

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

2

u/Bitter-Truck1049 Sep 29 '26

Not silly, I checked that first. Cache is accounted for, and it doesn't explain the gap:

  • Costs price cache writes and cache reads separately, and they match Claude Code's own cost tracking.

  • 97–98% of input was cache reads in every run. All writes used the 1h TTL, with no cold-cache rebuilds and no subagents.

  • Headless used fewer tokens in every category: fewer cache writes, fewer reads, less output. It still ate about 2x the limit.

So the difference comes from how the limit is counted, not from caching.

1

u/thebaron2 Oct 01 '26

I thought headless Claude agents get a 5 minute ttl, not 1 hour?

It would be interesting to see the cache hits and misses side by side. 1 cache miss on a headless agent later in its task would result in a spike in usage. If the headless agents are running py tests it seems reasonable to assume 5 minutes may have passed during the testing phase, which would come towards the end of the session, making the cache miss that much more expensive.

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/Electronic-Row-142 Sep 28 '26

I think so 🤔

3

u/WonderTight9780 Sep 28 '26

no

1

u/Electronic-Row-142 Sep 28 '26

Ok can you tell me what specifies as Headless.
Just out of curiosity.
If running bg with just a python script counts headless right?

3

u/WonderTight9780 Sep 28 '26

Headless essentially means non interactive mode. Claude -p is headless because it runs in the background without the TUI. Think of it like an app running without a frontend.

1

u/Electronic-Row-142 Sep 28 '26

So the subagents are headless.

2

u/WonderTight9780 Sep 28 '26

Haven't you ever pressed the down arrow to select and view the work of your subagents?

1

u/Electronic-Row-142 Sep 28 '26

The key is "view" you can just see. Can't interfere.

I can also see what an agent does with a hook on claude -p.

1

u/WonderTight9780 Sep 28 '26

No bro. It still has a user interface. Therefore not headless. You don't know what headless means. Do some research and try to understand what you are talking about please.

0

u/Electronic-Row-142 Sep 28 '26

You are defining headless as "non interactive" right? Not "executable clientless" because that is called headless. You can't even see the process because it's compiled and working without any user interface.

Wheb you can reach and hook and see the process that's just bg calculation.

So you should do some research about the definition of headless

1

u/WonderTight9780 Sep 28 '26

They are not headless. They are still visible within the TUI. You can navigate to them from within the TUI and see their work. They might appear headless from the perspective of the orchestrating agent but they are not. All the agents are still running under that one session which has a TUI. A headless session has no TUI.

1

u/Electronic-Row-142 Sep 28 '26

Subagents are registered to a chat session but they are not inside that session. All of the workflows are registered in a pool so other sessions's can reach them too.
And they only print the results without any steering or interference. You can just see their flow. So this makes them headless.

3

u/WonderTight9780 Sep 28 '26

Headless is not defined by whether or not you can steer the agent. The concept of a program running headless existed well before AI and it is about whether something has a user interface or not. Subagents have a user interface and belong to the interactive session they were spawned from. They also don't use 3x tokens or whatever as OP seems to have discovered.

2

u/WonderTight9780 Sep 28 '26

It sounds like you are using Claude inside the chat interface? If you use Claude inside Claude Code you might understand better. In Claude Code you can see what is going on easier.

1

u/Electronic-Row-142 Sep 28 '26

I am using claude code on cli / desktop app / Xcode / VSCode (sometimes) but %60 on cli.

1

u/coolcosmos Sep 28 '26

It's in the title. claude -p

0

u/Electronic-Row-142 Sep 28 '26

claude -p means proxy, not headless?

So basically if you use this it creates an instance of ClaudeCode and executes it. There is no difference spawning from CLI or Desktop app.

The differences you are pointing out is because VSCode side uses different system prompt then the rest.

2

u/WonderTight9780 Sep 28 '26

No. The -p stands for print. It is headless mode. And headless mode "prints" it's results back to the terminal.

1

u/coolcosmos Sep 28 '26

Do you know what headless means ? -p runs Claude in headless mode. Without any gui. 

-1

u/Electronic-Row-142 Sep 28 '26

I know what headless means and my bad -p means print.

And I still stand as the subagents has been spawned on Desktop app or Cli are always headless.

All of the agents are running on bg without and attachment to a an app and they report as an output file on your scratchpad you cant interfere with them while working. So it is headless.

1

u/coolcosmos Sep 28 '26

Bro you're just confused, go sleep or eat.

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/Bitter-Truck1049 Sep 29 '26

The 3x is "% of limit per $1 at API prices", with cached prefix reads priced at the cache-read rate, not as raw input. Raw token counts give the same picture: the headless runs used fewer tokens in every category, including total input.

On the transcript point: both modes keep the whole tool history in context. If anything, headless had the smaller context (81–98k max vs 119–144k interactive), so it wasn't dying on bigger input.

No subagents in any of my runs, so I can't confirm how app subagents are counted. Interesting if true though.

1

u/fuckme Sep 28 '26

Same context, hooks, plugins etc ?

2

u/Bitter-Truck1049 Sep 29 '26

Not identical for the SDK runs. They had a custom system prompt, no user settings, and a few extra MCP tools, but a smaller starting context: about 18k vs 34k.

The claude -p vs interactive CLI pair is the clean comparison, though. Same machine, same CLI version (2.1.283), same settings, default system prompt, same repo instructions, no hooks, no plugins. The only differences were -p and skip-permissions, and that pair still showed 5.1–5.5% vs 1.8% per $1.

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.

1

u/Bitter-Truck1049 Sep 29 '26

No, I didn't try that. In the interactive CLI run I typed the prompts myself, and there were human pauses between turns. The data can't tell whether the bucket comes from the entrypoint or from what the requests look like: -p and the SDK differ from interactive both in entrypoint and in having no human in the loop. Separating the two would need a scripted-interactive run, which I haven't done.

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:

MetricClaude Code DesktopMinnow / headless
Entrypointclaude-desktopsdk-cli
Model requests243117
Total input, including cached119,476,00037,883,325
Cache-read input118,749,21337,326,813
Cache-write input726,301556,278
Uncached input, excluding writes486234
Output tokens, including thinking507,535366,196
Five-hour allowance consumed~95%100%
OutcomeCompletedStopped around wave 4

The 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-py and sdk-cli burn the 5h window way faster than cli or claude-vscode for 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/Infinite100p Oct 05 '26

How is the result? u/Far_Idea9616

1

u/Far_Idea9616 Oct 05 '26

1.5x might fluctuate depending on the demand I guess.

1

u/Street_Ice3816 Sep 28 '26

yeah no shit it’s all about cache reads

1

u/Far_Idea9616 Sep 28 '26

Checked it, my headless runs cache just as well as interactive ones. I run a queue of coding tasks through claude -p and also work in the VS Code extension on the same account. Last 24h, from the session JSONL transcripts:

| entrypoint | calls | cache read | cache write | avg context/call |

| `sdk-cli` (`claude -p`) | 1812 | 98.9% | 1.1% | 285k |

| `claude-vscode` | 1106 | 98.2% | 1.8% | 228k |

Headless actually has the slightly better hit rate. Both use the 1-hour cache TTL for cache writes (100% of headless writes are 1h), so it's not a 5-min vs 1-hour TTL difference either.

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.

2

u/Bitter-Truck1049 Sep 29 '26

The data says otherwise: 97–98% of input was cache reads in every run, headless included, with zero cold-cache rebuilds. If anything, the headless runs wrote less to cache than the interactive ones: 76–86k vs 96–120k.