SShortSingh.
Back to feed

Analysis: Claude Code sessions re-send entire context every turn, driving hidden token costs

0
·1 views

A developer analyzed three Claude Code sessions by parsing JSONL transcript files stored locally, revealing how AI coding assistants accumulate significant token costs over time. Because each API call is stateless, the full conversation history is re-transmitted on every turn, meaning a token added early in a session is effectively billed dozens of times before the session ends. Across 5,288 requests in three sessions, the analysis found 1.99 billion cache-read tokens against just 62 million cache-write tokens, a 32-to-1 ratio. Prompt caching discounts reduced estimated costs by around 86% compared to full input pricing, but the developer notes this is a discount on a recurring per-turn charge, not a one-time cost. Four automatic compactions triggered near the one-million-token context limit, each taking over 100 seconds, underscoring that context size is an ongoing expense rather than a sunk cost.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Google Launches Gemini 3.8 Flash: Smarter Reasoning at the Same Price as 3.7

Google released Gemini 3.8 Flash on September 2, 2026, just three weeks after Gemini 3.7 Flash and six weeks after 3.6 Flash. The new model retains identical pricing at $0.75 per million input tokens and $3.75 per million output tokens through December 31, 2026, after which both models rise to $1.50 and $7.50 respectively. Key improvements are internal: 3.8 Flash uses smaller reasoning steps, self-checks its outputs, and runs tools iteratively, resulting in a higher Artificial Analysis Intelligence Index score of 59 versus 56 for 3.7 Flash. However, these enhancements come at the cost of more tokens consumed per task, meaning per-task expenses may increase despite unchanged per-token rates. Google confirmed that Gemini 3.7 Flash remains fully supported with no deprecation date, so developers are not required to migrate immediately.

0
ProgrammingDEV Community ·

Google Launches Gemini 3.8 Flash: Smarter Reasoning but Migration Not Urgent

Google released Gemini 3.8 Flash on September 2, 2026, just three weeks after Gemini 3.7 Flash, positioning it as its most capable Flash model to date. The new model features shorter reasoning steps, iterative tool calls, and self-verification during execution, resulting in modest benchmark improvements over its predecessor. Pricing remains identical at $0.75 per million input tokens and $3.75 per million output tokens through December 31, 2026, with the same one-million-token context window and comparable output speed. However, the improved reasoning can consume more tokens per task, meaning quality gains may come with higher costs depending on workload. Google confirmed that Gemini 3.7 Flash remains fully supported with no deprecation date announced, making an immediate upgrade unnecessary.

0
ProgrammingDEV Community ·

AWS Secrets Manager vs Parameter Store: How to Choose the Right Tool

AWS offers two primary secrets and configuration storage services — Secrets Manager and Systems Manager Parameter Store — both backed by KMS encryption, but suited to different use cases. Secrets Manager is purpose-built for sensitive credentials that require automatic rotation, cross-region replication, and cross-account sharing, at a cost of around $0.40 per secret per month. Parameter Store is a general-purpose hierarchical config store with a free standard tier, making it better suited for application configuration, feature flags, and static secrets that rarely change. The core decision rule is straightforward: if a secret needs to rotate on a schedule, use Secrets Manager; otherwise, Parameter Store is the more cost-effective choice. Choosing the wrong service at the start of a project can lead to expensive rewrites or unnecessary costs, making the upfront decision critical.

0
ProgrammingDEV Community ·

Gemini 2.5 Flash Drops 'Minimal' Thinking Level, Defaults to Medium Not High

Google's Gemini 2.5 Flash introduces three thinking levels — low, medium, and high — which control how much internal reasoning the model performs before responding, directly affecting latency, token output, and cost. Unlike its predecessor Gemini 2.0 Flash, the new model no longer supports the 'minimal' thinking level; any API request using that value will fail at validation before any tokens are generated. The default thinking level is medium, not high — a key difference from Gemini 2.0 Pro, which defaults to high, meaning teams migrating between models may get unexpected behavior if they don't set the parameter explicitly. Thinking tokens, generated during the model's internal reasoning process, are billed as output tokens at $3.75 per million until end of 2026, rising to $7.50 per million from January 2027. Google recommends explicitly setting the thinking level in every API request and storing it in a central config file to avoid unintended cost or behavior changes when defaults shift.

Analysis: Claude Code sessions re-send entire context every turn, driving hidden token costs · ShortSingh