Skip to content

[Bug]: Anthropic prompt caching shows 0% cache hit rate on Haiku 4.5 #3977

Description

@krakenlgk

Affected component

provider

Severity

S2 - degraded behavior

Current behavior

Summary

Running ZeroClaw v0.5.0 on Raspberry Pi 4 with Anthropic Haiku 4.5 (claude-haiku-4-5-20251001). Anthropic dashboard consistently shows 0% Cache Rate — zero cache reads across all API calls.

Per the wiki (05.1 Built In Providers), ZeroClaw's Anthropic provider should support:

Automatic prompt caching (system prompts >3KB, conversations >4 messages, tools)

Environment

  • ZeroClaw version: v0.5.0 (stable, March 18, 2026)
  • OS: Raspberry Pi OS Bookworm (aarch64)
  • Hardware: Raspberry Pi 4 (8GB)
  • Provider: anthropic
  • Model: claude-haiku-4-5-20251001
  • Channel: Telegram
  • Workspace files total: ~3,279 bytes

Relevant config

default_provider = "anthropic"
default_model = "claude-haiku-4-5-20251001"
max_context_tokens = 8192
max_history_messages = 5
response_cache_enabled = true

Current behavior

  • Cache Rate: 0% on all calls — no cache writes, no cache reads
  • Two messages sent 50 seconds apart show no cache reuse
  • Every call pays full input token price (~10,000 tokens per message)
  • grep -ri "cache_control\|ephemeral" ~/.zeroclaw/ returns nothing

Cost impact

At 50 messages/day on Haiku 4.5:

  • Without caching: ~₹1,275/month ($15/month) — 10K input tokens × $1/MTok × 1,500 calls
  • With caching working (90% cache read): ~₹400-500/month ($5-6/month)
  • Wasted spend: ~₹800/month due to cache not activating

Investigation done

  1. Confirmed workspace files total 3,279 bytes (above the documented 3KB threshold)
  2. Verified response_cache_enabled = true in config (this is ZeroClaw's internal cache, not Anthropic's prompt cache)
  3. No cache_control or ephemeral strings found anywhere in ~/.zeroclaw/
  4. Anthropic dashboard shows only "Uncached Tokens" in the chart — Cache Rate line flat at 0%

Possible root causes

  1. System prompt below Haiku's minimum cacheable token count (2,048 tokens)? Workspace files are ~800-900 tokens. Even with ZeroClaw's internal system prompt + tool schemas, the total might be under the threshold.

  2. Dynamic content invalidating cache prefix? PR feat: refresh stale datetime in cached system prompt #3223 ("refresh stale datetime in cached system prompt") merged in v0.1.9a addresses this for timestamps. Unclear if this fix is included in v0.5.0.

  3. cache_control headers not being sent? The Anthropic API requires cache_control: {"type": "ephemeral"} on content blocks, or the top-level cache_control field. ZeroClaw may not be injecting these for Haiku model IDs.

Questions

  1. Does v0.5.0 include the datetime cache fix from PR feat: refresh stale datetime in cached system prompt #3223?
  2. Is there a minimum system prompt token count for Anthropic caching to activate? If so, is it documented?
  3. Is there a config flag to explicitly enable/verify Anthropic prompt caching (similar to OpenClaw's cacheRetention parameter)?
  4. Can ZeroClaw expose cache_write/cache_read token counts in logs or zeroclaw status output for debugging?

Related issues

Expected behavior

Expected behavior

  • First message: cache write for the system prompt prefix
  • Second message (within 5-minute TTL): cache read showing >0% cache hit rate
  • Subsequent messages within TTL: consistent cache reads, reducing effective input token cost by ~90%

Steps to reproduce

## Steps to Reproduce

1. Configure ZeroClaw v0.5.0 with Anthropic Haiku 4.5
2. Send a message via Telegram (e.g., "Hello")
3. Wait 30-60 seconds
4. Send another message (e.g., "Hey")
5. Check Anthropic console → Rate Limit Use + Caching → filter by `claude-haiku-4-5-20251001`

Impact

Cost impact

At 50 messages/day on Haiku 4.5:

  • Without caching: ~₹1,275/month ($15/month) — 10K input tokens × $1/MTok × 1,500 calls
  • With caching working (90% cache read): ~₹400-500/month ($5-6/month)
  • Wasted spend: ~₹800/month due to cache not activating

Logs / stack traces


ZeroClaw version

v0.5.0

Rust version

No response

Operating system

Raspberry Pi OS Bookworm (aarch64)

Regression?

Unknown

Pre-flight checks

  • I reproduced this on the latest master branch or latest release.
  • I redacted secrets, tokens, and personal data from all submitted content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions