Skip to content

fix: extend cacheRetention auto-injection and runtime pass-through for amazon-bedrock#22303

Closed
snese wants to merge 2 commits intoopenclaw:mainfrom
snese:fix/bedrock-cache-retention-defaults
Closed

fix: extend cacheRetention auto-injection and runtime pass-through for amazon-bedrock#22303
snese wants to merge 2 commits intoopenclaw:mainfrom
snese:fix/bedrock-cache-retention-defaults

Conversation

@snese
Copy link
Copy Markdown
Contributor

@snese snese commented Feb 21, 2026

Summary

Two changes to make cacheRetention work end-to-end for Anthropic Claude models on the amazon-bedrock provider.

Changes

1. src/config/defaults.ts — config auto-injection

The config auto-injection in applyContextPruningDefaults only sets cacheRetention: "short" for provider === "anthropic", skipping Bedrock Claude models. Extended the provider gate to also match amazon-bedrock models whose ID contains anthropic.claude.

2. src/agents/pi-embedded-runner/extra-params.ts — runtime pass-through

resolveCacheRetention hard-gates on provider !== "anthropic" and returns undefined for all other providers. This means cacheRetention configured in model params is never consumed at runtime for Bedrock models. Extended the gate to also accept amazon-bedrock when cacheRetention is explicitly set in extraParams. No default is applied for Bedrock since pi-ai's own provider already defaults to "short" internally.

Related

Testing

  • AI-assisted (Kiro CLI)
  • Lightly tested against local openclaw instance with amazon-bedrock/us.anthropic.claude-opus-4-6-v1
  • Confirmed cacheRetention is auto-injected and consumed at runtime for Bedrock Claude models
  • Confirmed non-Anthropic Bedrock models are correctly skipped

Greptile Summary

Extends cacheRetention support to Anthropic Claude models running on Amazon Bedrock by adding two complementary changes:

  • Config auto-injection in applyContextPruningDefaults now recognizes Bedrock Claude models (matching amazon-bedrock provider with model IDs containing anthropic.claude) and applies the default cacheRetention: "short" setting
  • Runtime pass-through in resolveCacheRetention now accepts Bedrock when cacheRetention is explicitly configured, allowing the auto-injected or user-specified values to flow through to the streaming API

The changes correctly preserve the existing behavior for direct Anthropic models while extending support to Bedrock's Anthropic Claude variants. The string matching logic handles both region-prefixed (us.anthropic.claude-*) and non-prefixed (anthropic.claude-*) model ID formats.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-scoped, logically sound, and follow the existing patterns in the codebase. The two-part approach (config auto-injection + runtime pass-through) correctly implements the feature. The string matching logic using .toLowerCase().includes("anthropic.claude") appropriately handles all documented Bedrock Claude model ID formats, and the guard condition extraParams?.cacheRetention !== undefined ensures Bedrock only gets cacheRetention when explicitly configured (via auto-injection or user config). The changes preserve backward compatibility with direct Anthropic models and existing cacheRetention behavior.
  • No files require special attention

Last reviewed commit: fb85a4d

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

… models

The config auto-injection in applyContextPruningDefaults only sets
cacheRetention: "short" for provider === "anthropic", skipping
Anthropic Claude models accessed via the amazon-bedrock provider.

Extend the provider gate to also match amazon-bedrock models whose
model ID contains "anthropic.claude".

Refs openclaw#21986
…amazon-bedrock

The runtime resolveCacheRetention hard-gates on provider === "anthropic"
and returns undefined for amazon-bedrock, so cacheRetention set in model
params is never consumed at runtime for Bedrock models.

Extend the gate to also accept amazon-bedrock when cacheRetention is
explicitly configured. No default is applied for Bedrock since pi-ai
own provider already defaults to "short" internally.

Refs openclaw#21986
@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: XS labels Feb 21, 2026
@steipete
Copy link
Copy Markdown
Contributor

Closing as covered by landed equivalent changes.

Implemented and landed:

  • 47bb7ef86 — extend Bedrock Anthropic cacheRetention defaulting + runtime pass-through (applyContextPruningDefaults + resolveCacheRetention).
  • 5e913dd78 — follow-up type-narrowing cleanup in src/config/defaults.ts.

Behavior now matches the intended split:

  • Anthropic Claude on Bedrock receives default cacheRetention: "short" in config defaults.
  • Runtime pass-through accepts explicit Bedrock cache retention settings.
  • Non-Anthropic Bedrock stays excluded from Anthropic cache retention flow.

@steipete steipete closed this Feb 23, 2026
steipete added a commit that referenced this pull request 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.

3 participants