Deep dive · advanced topics · ~30 minInternal talk · July 2026
WIP — draft

Cost & Context.

What agents really cost — and how to spend the context window like the scarce resource it is.

cost context
2
Agenda

Two parts, half an hour

PartTopicNote
01What agents really costsubscriptions, API, Bedrock
02Efficient work with contextmost important part · live demo

All pricing and product claims are date-stamped July 2026 and sourced — see the closing Sources slide.

01

What agents really cost

Tokens, priced. One real session's bill, traced line by line. Then: which plan for which team.

3
Cost · tokens, priced

Three meters, not one

Input

Everything sent with the request — prompt, files, tool results, history. The base meter: cheaper than output, pricier than cached.

Output

Everything the model generates — including thinking tokens. The priciest meter, often 5× input.

Cached input

Repeated context (system prompt, CLAUDE.md, tool schemas) served from cache — up to ~90% cheaper.

output $15 /M input $3 /M cached input ~$0.30 /M ← same million tokens, 50× apart

July 2026 rates, e.g. Sonnet 5: $3/M input · $15/M output (introductory $2/$10 through Aug 31, 2026). Spot-check platform.claude.com/docs/en/pricing before quoting externally.

4
Cost · output dominates

Why output tokens dominate

  • Thinking tokens are output tokens. The effort dial (deck 03) trades quality for real, billed spend — xhigh is not free.
  • Output is typically 5× the price of input per token — a verbose agent that narrates every step pays a premium for it.
  • Latency follows the same meter: output is generated one token at a time; input is processed in parallel. Long output = slow turn.
  • Practical lever: shorter, more decisive answers and tighter thinking budgets cut cost and wait time together.
input — processed in parallel, one pass prompt · files · tool results · history output — generated one token at a time thinking tokens final answer both billed on the same 5× meter… …and each token waits for the last — cost and latency move together

Cost and latency are the same lever here — trimming output tokens helps both at once.

5
Cost · one session's bill

Anatomy of a session's bill

# a real agentic session, traced turn by turn system prompt + tool schemas › cached after turn 1 CLAUDE.md › cached, resent every turn file reads (×12) › input — the biggest line item re-reads of same file (×4) › avoidable — context got dropped thinking + final answer › output — priciest per token
the same trace, as one bill cached prefix file reads ×12 — biggest line item re-reads ×4 thinking + answer avoidable — part 02's subject priciest per token

The single biggest avoidable cost in most sessions is re-reading the same file because context was already lost or cleared badly — part 02's whole subject.

6
Cost · subscriptions today

Pro, Max — and no confirmed "next"

PlanPriceUsage
Pro$20/mo (~$17/mo annual)baseline
Max 5×$100/mo5× Pro's limits
Max 20×$200/mo20× Pro's limits, extended context, priority support
Pro 1× · $20/mo Max 5× 5× Pro's limits · $100/mo Max 20× 20× Pro's limits · $200/mo

No confirmed statement of a new subscription "direction" beyond Pro/Max/Team/Enterprise as of July 2026 — treat any such claim as unconfirmed. Pricing moves periodically; verify at claude.com/pricing before presenting exact numbers.

7
Cost · API pricing, family-wide

API pricing across the model family

ModelInput /MOutput /MNotes
Fable 5$10$50highest-cost self-serve tier
Opus 5$5$25complex agentic coding, enterprise
Sonnet 5$3$15$2/$10 intro through Aug 31, 2026
Haiku 4.5$1$5classification, extraction, routing

Prompt caching: up to ~90% off cached input. Batch API: flat 50% off. Third-party trackers agree here, but spot-check the Anthropic pricing page directly before quoting on stage.

8
Cost · subscription vs API

When a subscription beats API — and vice versa

Subscription wins

Steady daily interactive coding, one person, usage inside the plan's cap. Predictable monthly bill.

API wins

Bursty or programmatic use — CI runs, batch jobs, evals, multi-agent fleets. Pay exactly for what runs.

steady daily use — subscription plan cap predictable flat bill, inside the cap bursty · CI · batch — API $0 $0 pay exactly for what runs — idle days cost nothing

Hybrid credit-pool models (Cursor's Auto mode — deck 07, Measuring What Works) sit in between: subscription price, usage-aware routing underneath.

9
Cost · Team & Enterprise

Team → Enterprise

  • Team: SSO plus central admin controls for connectors and desktop deployment.
  • Enterprise: $20/seat/month + usage billed at API rates, annual only.
  • Adds on top of Team: SAML 2.0/OIDC SSO with domain capture, SCIM provisioning, fine-grained roles, IP allowlisting, audit logs, custom retention, org/user spend limits.

Verified SSO paths: Okta, Microsoft Entra ID, Google Workspace.

10
Cost · Claude on AWS Bedrock

Why an org reaches for Bedrock

  • Data stays inside AWS infrastructure — not shared with Anthropic or third parties; regional inference profiles cover US/EU/JP/AU residency.
  • Single AWS bill, existing IAM/CloudTrail, and the ability to retire committed AWS spend (Enterprise Discount Program) against Claude usage.
  • Regional (single-region) endpoints carry a 10% pricing premium over global endpoints.
  • Reach for it when: AWS data-boundary requirements, Guardrails/Knowledge Bases, strict regional residency, unified AWS governance.
AWS boundary — one bill, one governance plane your app Claude models on Bedrock IAM · CloudTrail Guardrails · KBs regional profiles: US · EU · JP · AU single-region endpoint: +10% premium not shared with Anthropic or 3rd parties
11
Cost · Cursor's model

Cursor: credit pool + Auto routing

  • Four tiers: Hobby (free), Pro ($20/mo, $20 credit pool), Pro+ ($60/mo), Ultra ($200/mo).
  • Auto mode: Cursor picks the model per request; unlimited on paid plans, doesn't draw from the credit pool.
  • Cursor Router (Teams/Enterprise, launched Jul 22, 2026): a decision layer that picks per-request which model runs — not a new model itself.

Cursor claims up to 60% cost savings vs. running everything on Opus — that number is Cursor's own marketing claim, not independently verified.

12
Cost · takeaway

Which plan or channel — for which team

Team shapeReach for
Solo engineer, daily interactive codingPro or Max, by usage volume
CI, batch jobs, scheduled evalsraw API + batch discount (50% off)
Regulated data / AWS-committed orgClaude on Bedrock (regional endpoint)
Team needing SSO/audit/spend limitsTeam or Enterprise
Wants routing across model vendorsCursor Router or OpenRouter (deck 07)
02

Efficient work with context

The most important part of today. Context is the scarce resource — spend it like one.

13
Context · the scarce resource

Context is scarce — spend it that way

  • Degrades with fill. Quality starts slipping well before the hard token limit — a full window is not a healthy window.
  • Costs on every turn. Most of what's in the window gets resent (and mostly re-billed) each time you send a message.
  • Cache invalidation. Edit anything near the start of the conversation and the prefix cache for everything after it is gone.
1 · degrades as it fills hard limit quality slips first 2 · re-sent (and mostly re-billed) every turn turn 1 turn 2 turn 3 same prefix, again 3 · one upstream edit kills the prefix cache edit cache gone — full price everything after the edit is re-processed from scratch

Three separate failure modes, one fix: be deliberate about what stays in the window.

14
Context · the lifecycle

The context lifecycle of a session

Everything left of "conversation" is fixed overhead, resent and re-billed every turn (cached, but not free). Only the conversation genuinely grows — and it's the part you control least by default.

15
Context · what's resent

What gets resent every turn

# turn N of a real session — before the user has typed anything: system prompt › ~2–3K tokens (cached) built-in tool schemas › ~10–15K tokens (cached — before a single MCP server is added) MCP tool schemas › variable (cached, scales with server/tool count) CLAUDE.md › variable (cached — but size still matters, see next slides) conversation › grows every turn (the part you actually control turn-to-turn)

Caching makes this cheaper, not free — and a cache miss (from any upstream edit) means the full price, every time. Run /context in Claude Code to see your own session's exact breakdown.

16
Context · CLAUDE.md, what belongs

CLAUDE.md: what belongs

  • Constraints the repo can't express: "never touch the payments schema without a migration review."
  • Commands the agent needs every session: exact test runner, lint command, deploy steps.
  • Conventions that aren't derivable from code: naming rules, review process, who owns what.

Test: could this live as a code comment or README instead? If yes, it usually shouldn't be here.

17
Context · CLAUDE.md, what doesn't

CLAUDE.md: what doesn't belong

  • Anything derivable from the code. The agent can read the file; don't pre-digest it for every session, forever.
  • One-off notes. "Fixed the flaky test on Tuesday" belongs in a commit message, not a file resent every turn.
  • Essays. Rationale nobody needs turn-to-turn is a cost with no ongoing return.
CLAUDE.md one added line session A turn 1 turn 2 turn 3 session B turn 1 turn 2 …every future session every line × every turn × every session

Every line in CLAUDE.md is paid for on every turn, of every session, forever. Treat additions like you'd treat a hot-path dependency.

18
Context · measuring changes

Measure the effect — don't guess it

  • Token overhead per session: read it straight off the API usage response — before/after a CLAUDE.md change.
  • Behavioral spot-checks: does the agent still follow the constraint you kept, and stop repeating the one you cut?
  • Before/after evals on a fixed task set: the rigorous version — same tasks, same rubric, two CLAUDE.md variants (full method in deck 07, Measuring What Works).
19
Context · hygiene

/clear vs /compact

/clear

Full reset. Use when the task is genuinely done and the next one is unrelated — don't drag dead context into a fresh task.

/compact

Summarize and continue. Use mid-task when the window is filling but you still need the thread.

task A — done /clear empty fresh start, zero baggage task A — mid-flight /compact room summary + the thread continues

Wrong choice either direction costs you: /clear too early loses context you needed; /compact too rarely drags a bloated window into every remaining turn. And /compact isn't free — the summarization pass itself reads the whole window one more time.

20
Context · subagents as firewalls

Subagents as context firewalls

  • A subagent explores, searches, or reads in its own context window — the parent session never absorbs the raw noise.
  • Only the distilled report comes back. Ten files read in a subagent cost the parent session one summary.
  • Full mechanics: deck 04, Subagents & Prompt Caching.

This is context hygiene applied at the architecture level, not just a discipline you have to remember mid-session.

21
Context · reading selectively

Read selectively

  • Grep or search for the relevant span before reading a whole file.
  • Use line ranges on large files instead of loading them whole.
  • Push broad, exploratory reading into a subagent (previous slide) rather than the main thread.

"Read the whole file just in case" is exactly the re-read pattern that was the biggest avoidable cost line item back in part 01.

22
Context · live demo
Live

Same task, two CLAUDE.md files

  • Left: today's bloated CLAUDE.md. Right: a lean rewrite — same constraints, none of the derivable or one-off content.
  • Identical prompt, run live in both. Compare turns, total tokens, and outcome.

Live Watch the token counters, not just the transcripts — the difference is usually bigger than it feels.

23
Context · fallback

Fallback: recorded run

Placeholder — screenshot or recording of the bloated-vs-lean CLAUDE.md comparison (turn count, token totals, outcome) goes here.

Use only if the live run stalls. Narrate the captured turn/token delta from rehearsal, then move on.

24
Context · recap

Context hygiene: the checklist

  • Measure first: run /context — know what your fixed overhead actually is.
  • Trim CLAUDE.md to what the repo genuinely can't express.
  • Choose /clear or /compact deliberately, not by habit.
  • Push broad exploration into subagents — keep the parent thread distilled.
  • Read selectively; grep before you load a whole file.
  • Then let /doctor audit the lot for you — next slide.

If this deck changes one habit, make it this one — it's the highest-leverage change available to most engineers this week.

25
Context · automate it

/doctor — the checklist, as one command

# /doctor (alias /checkup) — reports first, changes nothing without you CLAUDE.md › dedupe + trim (local vs checked-in; cut what it reads off the code) CLAUDE.md › migrate the rest (→ skills + nested files that load on demand) skills · MCP · plugins › unused vs cost (the schema overhead from slide 15) hooks · install › slow hooks, duplicate installs, PATH, version
  • Same trim rule as slides 16–17: cuts layouts, dependency lists, architecture tours — keeps pitfalls, rationale, conventions that differ from defaults.
  • Reports first, asks before changing anything — including its offer to change permission defaults, which is a different decision from context hygiene.

Run /context before and after: the trim is only worth what the numbers say it's worth.

26
Close · recap

Cost → context

01 cost
02 context
01 Cost

Three meters, not one — and output (thinking included) is the expensive one. Pick the channel by team shape, not by habit.

02 Context

The window degrades as it fills, re-bills every turn, and re-caches badly. Trim CLAUDE.md, clear deliberately, read selectively.

Of the two, context is the one to act on first — it's the highest-leverage habit change available this week.

27
Close · sources

Sources — all claims dated July 2026

Full source list with per-claim citations: deck05-facts.md (internal research doc). One item flagged unverified: any claim of a new announced subscription direction beyond Pro/Max/Team/Enterprise.