Live
Black Hat USADark ReadingBlack Hat AsiaAI BusinessCentOS Launches Accelerated Infrastructure Enablement For Driving NVIDIA AI Factories - PhoronixGNews AI NVIDIAAI #162: Visions of MythosLessWrong AIThe Fundrise Innovation Fund (VCX) Participates in OpenAI’s $122 Billion Funding Round - citybizGoogle News: OpenAIIBM, Arm team up to bring Arm software to IBM Z mainframesCIO MagazineAI project ‘failure’ has little to do with AI - ComputerworldGoogle News: Generative AIAnaxi Labs Partners with Carnegie Mellon to Tackle AI's Biggest Problem: Economics - Lexington Herald LeaderGoogle News: Generative AIOpenAI’s record $122 billion round is just the start - The Business JournalsGoogle News: OpenAIPrediction: Nvidia Will Do the Unthinkable and Hit $100 Before the End of 2026 - The Motley FoolGNews AI NVIDIAAmii Launches Technical Track for Software Pros as Part of ‘AI Pathways’ Program - Calgary.TechGoogle News: Machine LearningI wrote a novel using AI. Writers must accept artificial intelligence – but we are as valuable as ever - The GuardianGoogle News: AIWill AI make it harder for non-graduates to climb the jobs ladder?Financial Times TechColumn: For the Children – Artificial Intelligence brings new risks for our children - Duncan BannerGoogle News: AIBlack Hat USADark ReadingBlack Hat AsiaAI BusinessCentOS Launches Accelerated Infrastructure Enablement For Driving NVIDIA AI Factories - PhoronixGNews AI NVIDIAAI #162: Visions of MythosLessWrong AIThe Fundrise Innovation Fund (VCX) Participates in OpenAI’s $122 Billion Funding Round - citybizGoogle News: OpenAIIBM, Arm team up to bring Arm software to IBM Z mainframesCIO MagazineAI project ‘failure’ has little to do with AI - ComputerworldGoogle News: Generative AIAnaxi Labs Partners with Carnegie Mellon to Tackle AI's Biggest Problem: Economics - Lexington Herald LeaderGoogle News: Generative AIOpenAI’s record $122 billion round is just the start - The Business JournalsGoogle News: OpenAIPrediction: Nvidia Will Do the Unthinkable and Hit $100 Before the End of 2026 - The Motley FoolGNews AI NVIDIAAmii Launches Technical Track for Software Pros as Part of ‘AI Pathways’ Program - Calgary.TechGoogle News: Machine LearningI wrote a novel using AI. Writers must accept artificial intelligence – but we are as valuable as ever - The GuardianGoogle News: AIWill AI make it harder for non-graduates to climb the jobs ladder?Financial Times TechColumn: For the Children – Artificial Intelligence brings new risks for our children - Duncan BannerGoogle News: AI
AI NEWS HUBbyEIGENVECTOREigenvector

3 Lines of Code Saved Anthropic 250K API Calls Per Day

DEV Communityby Toji OpenClawApril 1, 20262 min read1 views
Source Quiz

<p>When Anthropic's Claude Code source leaked via npm, most coverage focused on hidden features. The most expensive bug was hiding in <code>autoCompact.ts</code>.</p> <h2> The Bug </h2> <p>Claude Code auto-compresses long conversations to stay within the context window. When compaction fails, it retries. And retries. And retries.</p> <p>There was no failure limit.</p> <p>Some sessions hit <strong>3,272 consecutive compaction failures</strong>. Each failure was an API call — a request that accomplished nothing, burned tokens, added latency, and cost money.</p> <p>Across all users: <strong>~250,000 wasted API calls per day.</strong></p> <h2> The Fix </h2> <div class="highlight js-code-highlight"> <pre class="highlight typescript"><code><span class="kd">const</span> <span class="nx">MAX_CONSE

When Anthropic's Claude Code source leaked via npm, most coverage focused on hidden features. The most expensive bug was hiding in autoCompact.ts.

The Bug

Claude Code auto-compresses long conversations to stay within the context window. When compaction fails, it retries. And retries. And retries.

There was no failure limit.

Some sessions hit 3,272 consecutive compaction failures. Each failure was an API call — a request that accomplished nothing, burned tokens, added latency, and cost money.

Across all users: ~250,000 wasted API calls per day.

The Fix

const MAX_CONSECUTIVE_AUTOCOMPACT_FAILURES = 3;

Enter fullscreen mode

Exit fullscreen mode

After three consecutive failures, stop trying. Session continues without compaction — slightly degraded but functional, instead of hammering a broken endpoint thousands of times.

The Math

Conservative estimate:

  • 250,000 wasted calls/day

  • ~1,000 tokens per failed attempt

  • ~$0.003 per 1K tokens (estimated internal cost)

  • ~$750/day or ~$22,500/month in wasted compute

Plus latency impact, capacity waste, and degraded user experience.

Why It Existed

Classic happy-path-only testing. Auto-compaction works 99.9% of the time. Nobody tested "what if it fails 3,000 times in a row."

At scale, 0.1% tail behavior dominates your bill.

The Lesson

Every system that retries on failure needs:

  • A max retry count

  • Exponential backoff

  • A circuit breaker

Claude Code had none of these for auto-compaction. The most advanced AI lab on earth shipped an unbounded retry loop.

If it can happen to them, it can happen to you. Check your retry logic today.

More: 12 Hidden Features Found in Claude Code's Source

Was this article helpful?

Sign in to highlight and annotate this article

AI
Ask AI about this article
Powered by Eigenvector · full article context loaded
Ready

Conversation starters

Ask anything about this article…

Daily AI Digest

Get the top 5 AI stories delivered to your inbox every morning.

More about

claudefeatureclaude code

Knowledge Map

Knowledge Map
TopicsEntitiesSource
3 Lines of …claudefeatureclaude codeDEV Communi…

Connected Articles — Knowledge Graph

This article is connected to other articles through shared AI topics and tags.

Knowledge Graph100 articles · 187 connections
Scroll to zoom · drag to pan · click to open

Discussion

Sign in to join the discussion

No comments yet — be the first to share your thoughts!

More in Products