openclaw - 💡(How to fix) Fix [Bug]: Anthropic Prompt Cache Invalidation on Startup Context (7x cost increase)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

OpenClaw auto-loads dynamic memory files at startup, breaking Anthropic's prompt cache and causing 7x cost increase

Root Cause

Root cause: Startup context auto-loads MEMORY.md, current_state.json, current_events.md. These files change multiple times per day. Each change = OpenClaw re-injects = Anthropic cache invalidation.

RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

OpenClaw auto-loads dynamic memory files at startup, breaking Anthropic's prompt cache and causing 7x cost increase

Steps to reproduce

  1. Set up OpenClaw with Anthropic Claude API
  2. Use persistent memory files (MEMORY.md, current_state.json, current_events.md)
  3. Start a session and send a message
  4. Check Anthropic console → token usage is 8x higher than expected
  5. Modify any memory file
  6. Send another message → cache hit stays 0%

Expected behavior

Prompt cache should hit 80-90%, keeping per-message cost low (~$0.002-0.01 per short reply)

Actual behavior

Prompt cache hit 0%, every message costs $0.08+ (8x normal). Burn rate: $45/day instead of $6-10/day

OpenClaw version

OpenClaw 2026.5.7 (eeef486)

Operating system

Macos

Install method

Npm openclaw onboard

Model

Claude Haiku + Opus (for synthesis)

Provider / routing chain

Anthropic Claude API

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

CRITICAL - $1,080-1,200/month waste. Makes OpenClaw unusable with Anthropic for persistent memory users.

Additional information

Root cause: Startup context auto-loads MEMORY.md, current_state.json, current_events.md. These files change multiple times per day. Each change = OpenClaw re-injects = Anthropic cache invalidation.

Evidence:

  • May 15 04:51: $52.97
  • May 15 04:54: $52.72 (after 3 exchanges)
  • $0.25 burned in 3 minutes = $0.08 per reply (should be ~$0.003)

Proposed fix: Config option to exclude dynamic files from auto-load: startup: excludePatterns: - memory/MEMORY.md - memory/current_.json - memory/current_.md

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Prompt cache should hit 80-90%, keeping per-message cost low (~$0.002-0.01 per short reply)

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING