Skip to content

Anthropic Prompt Caching Not Working - Missing cache_control Headers #17537

@Shellton2475

Description

@Shellton2475

Summary

Anthropic prompt caching not working - missing cache_control headers in API requests

Steps to reproduce

  1. Configure OpenClaw with cacheRetention: "long" for Anthropic provider
  2. Send multiple messages to the agent within 1 hour
  3. Check Anthropic API logs at console.anthropic.com/logs
  4. Observe all requests show "Standard" service tier with no cache_creation_input_tokens or cache_read_input_tokens

Expected behavior

First API request: Shows cache_creation_input_tokens (~30k) as cache is created
Subsequent requests (within 1 hour): Show cache_read_input_tokens (~30k) + regular input_tokens (~500)
Result: 90% cost reduction per message after initial request

Actual behavior

All API requests show "Standard" service tier with only input_tokens field (~30k tokens)
No cache_creation_input_tokens or cache_read_input_tokens fields present
Every message costs full token amount (15-20x more expensive than expected)
Rate limits (30k tokens/min) hit after 1-2 messages, making Sonnet 4.5 nearly unusable

Image

OpenClaw version

2026.2.14

Operating system

macOS Sequoia (Darwin 24.6.0) on Apple Silicon

Install method

npm global

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions