#17560: fix: Anthropic Prompt Caching Not Working - Missing cache_control Headers
agents
stale
size: XS
Cluster:
Bedrock and Caching Improvements
## Summary
This fix resolves the issue where Anthropic prompt caching was not working even when `cacheRetention` was configured. The problem was that the model config lookup did not handle model aliases (e.g., "sonnet" -> "anthropic/claude-sonnet-4-5") or short keys.
## Changes
- Updated `resolveExtraParams` in `extra-params.ts` to:
1. First try exact match with `provider/modelId`
2. Then try resolving model alias using `parseModelRef`
3. Finally try short key match (just modelId)
- Added debug logging to help identify config lookup issues
## Testing
- TypeScript compilation passes
- Config pruning defaults tests pass
- The fix allows cacheRetention to be properly looked up when users configure with model aliases or short keys
Fixes openclaw/openclaw#17537
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Updated `resolveExtraParams` to handle model aliases and short keys when looking up `cacheRetention` config. Previously only exact `provider/modelId` keys were supported, preventing prompt caching from working when users configured models using aliases like "sonnet" or short keys. The fix adds a fallback chain: exact match → alias resolution via `parseModelRef` → short key match.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The fix is well-structured with a clear fallback chain, properly uses existing `parseModelRef` helper, includes debug logging for troubleshooting, and addresses a specific bug without introducing breaking changes or security concerns
- No files require special attention
<sub>Last reviewed commit: 7432844</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#9905: fix: require provider prefix for models set without alias (#5790)
by petter-b · 2026-02-05
80.0%
#20866: fix: disable prompt caching for non-Anthropic Bedrock models
by pierreeurope · 2026-02-19
79.6%
#22303: fix: extend cacheRetention auto-injection and runtime pass-through ...
by snese · 2026-02-21
79.5%
#14744: fix(context): key MODEL_CACHE by provider/modelId to prevent collis...
by lailoo · 2026-02-12
77.8%
#17604: fix(context): use getAvailable() to prevent cross-provider model ID...
by aldoeliacim · 2026-02-16
77.7%
#19927: fix(agents): replace hardcoded Anthropic model IDs with pattern mat...
by Milofax · 2026-02-18
77.6%
#17462: fix(cache): enable cache retention for Google Vertex AI (#15525)
by rrenamed · 2026-02-15
77.4%
#12195: fix(agents): sync config fallback for lookupContextTokens cold-star...
by mcaxtr · 2026-02-09
76.7%
#11349: fix(agents): do not filter fallback models by models allowlist
by liuxiaopai-ai · 2026-02-07
76.7%
#23286: fix: use configured model in llm-slug-generator instead of hardcoded …
by wsman · 2026-02-22
76.5%