Skip to content

fix: disable prompt caching for non-Anthropic Bedrock models#20866

Closed
pierreeurope wants to merge 1 commit intoopenclaw:mainfrom
pierreeurope:fix/bedrock-nova-cachepoint-20815
Closed

fix: disable prompt caching for non-Anthropic Bedrock models#20866
pierreeurope wants to merge 1 commit intoopenclaw:mainfrom
pierreeurope:fix/bedrock-nova-cachepoint-20815

Conversation

@pierreeurope
Copy link
Copy Markdown
Contributor

@pierreeurope pierreeurope commented Feb 19, 2026

When using non-Anthropic models on Bedrock (like Amazon Nova or Mistral), the upstream pi-ai provider injects cachePoint blocks into message content by default. These models don't support the Anthropic-specific cache point extension and reject requests with 'extraneous key [cachePoint] is not permitted'.

This passes cacheRetention: "none" to the pi-ai stream options for non-Anthropic Bedrock models, which prevents cachePoint blocks from being added in the first place. Anthropic models on Bedrock are unaffected and keep their existing caching behavior.

Fixes #20815

Greptile Summary

Fixes Bedrock API errors when using non-Anthropic models (Amazon Nova, Mistral) by disabling prompt caching for them. The pi-ai Bedrock provider injects cachePoint blocks by default, but only Claude models support this Anthropic-specific extension.

The fix adds a detection function to identify Claude model IDs (matching anthropic.claude or anthropic/claude) and wraps the stream function to pass cacheRetention: "none" for all other Bedrock models. This prevents the upstream provider from injecting unsupported cache control metadata that would cause API rejection errors.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix is narrowly scoped, well-documented, and follows existing patterns in the codebase. The detection logic correctly identifies Anthropic models using case-insensitive string matching, and the wrapper correctly chains with existing streamFn wrappers. No tests need updating since this is defensive behavior that prevents errors rather than changing existing functionality.
  • No files require special attention

Last reviewed commit: 2302126

Disable prompt caching for non-Anthropic models (Nova, Mistral, etc.)
on Bedrock by passing cacheRetention: 'none' to the upstream pi-ai
provider. These models reject the cachePoint content block as an
extraneous key.

Fixes openclaw#20815
@steipete
Copy link
Copy Markdown
Contributor

Closing as covered by landed equivalent changes.

Implemented and landed:

  • ca1bcdeac — disable prompt caching for non-Anthropic Bedrock models by forcing cacheRetention: "none" for non-Claude Bedrock model ids.
  • Regression coverage added in src/agents/pi-embedded-runner-extraparams.test.ts for both non-Anthropic Bedrock (forced none) and Anthropic Bedrock (not force-disabled).

This preserves Anthropic Bedrock caching paths while preventing Nova/Mistral cachePoint payload failures.

@steipete steipete closed this Feb 23, 2026
iamjulio pushed a commit to NeuroGym-Dev/openclaw that referenced this pull request Feb 23, 2026
* upstream/main: (1467 commits)
  fix(doctor): use gateway health status for memory search key check (openclaw#22327)
  refactor: harden reset notice + cron delivery target flow
  refactor(exec): simplify env-prefixed wrapper modifier check
  fix(skills): support multiline frontmatter fallback without PyYAML
  fix(skills): make quick_validate work without PyYAML
  fix(exec): bind env-prefixed shell wrappers to full approval text
  fix(browser): derive relay auth token from gateway token in Chrome extension
  Browser relay: accept raw gateway token in extension auth
  fix(gateway): include platform and reason in node command rejection error
  CLI: fix gateway restart health ownership for child listener pids (openclaw#24696)
  docs: detail per-agent prompt caching configuration
  fix(config): tighten bedrock cache-retention type narrowing
  feat(agents): add per-agent stream params overrides for cache tuning (openclaw#17470) (thanks @rrenamed)
  fix(providers): support Bedrock Anthropic cacheRetention defaults/pass-through (openclaw#22303) (thanks @snese)
  fix(providers): disable Bedrock prompt caching for non-Anthropic models (openclaw#20866) (thanks @pierreeurope)
  docs(changelog): note /new and /reset auth-label removal (openclaw#24409)
  fix(reply): omit auth labels in /new and /reset
  docs(changelog): correct kimi issue references
  test(tools): fix kimi web_search mock typing
  feat(media): add moonshot video provider and wiring
  ...

# Conflicts:
#	ui/src/ui/app-render.ts
#	ui/src/ui/controllers/agents.ts
carlosrivera pushed a commit to myascendai/meshiclaw that referenced this pull request Feb 23, 2026
mreedr pushed a commit to mreedr/openclaw-custom that referenced this pull request Feb 24, 2026
plgs2005 pushed a commit to plgs2005/openclaw that referenced this pull request Feb 24, 2026
margulans pushed a commit to margulans/Neiron-AI-assistant that referenced this pull request Feb 25, 2026
brianleach pushed a commit to brianleach/openclaw that referenced this pull request Feb 26, 2026
mylukin pushed a commit to mylukin/openclaw that referenced this pull request Feb 26, 2026
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Bedrock Converse sends Anthropic-specific cachePoint to Amazon Nova models

2 participants