Repository navigation
Conversation
…e cache detection Application inference profiles with random IDs (e.g., 7g9cumu1wd7v) are not recognized as Claude models by isAnthropicBedrockModel(), disabling prompt caching. This adds an optional modelName parameter that the Bedrock extension populates from the provider config's model list, enabling name-based detection as a fallback when the profile ID doesn't contain 'claude'. Fixes the limitation noted in the source: 'resolving this would require a GetInferenceProfile call, which is too expensive for a per-request check' Instead, we use the already-available model name from the provider config, which is populated during gateway provisioning and typically contains the model name (e.g., 'Claude Sonnet 4.6 via Inference Profile').
Greptile SummaryThis PR adds a
Confidence Score: 4/5Safe to merge as a partial improvement, but prompt caching for random-ID inference profiles will still not be fully enabled due to the unpatched One P1 finding: the PR fixes the
|
Address review: isAnthropicFamilyCacheTtlEligible and resolveAnthropicCacheRetentionFamily now accept optional modelName and forward it to isAnthropicBedrockModel, completing the fix for random-ID inference profiles through the cache retention pipeline.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3539f3832
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…etention Address Codex review: pass model.name to resolveCacheRetention and isCacheTtlEligibleProvider at all runtime call sites in extra-params.ts, attempt.ts, extensions.ts, and attempt.thread-helpers.ts so that random-ID inference profiles are correctly detected as Claude models through the entire cache retention pipeline.
|
CI note: The Main branch recent CI runs also fail with the exact same test:
All 2203 other tests pass. Our changes only touch |
|
Closing this as duplicate or superseded after Codex automated review. This PR is superseded by the merged Bedrock prompt-caching implementation in #69953. Current main no longer relies on a configured display-name fallback for opaque application inference profile ARNs; it resolves the profile through Bedrock Best possible solution: Close this PR as superseded by #69953 and keep the shipped GetInferenceProfile-based implementation. It is more reliable than a display-name fallback because it validates the actual routed Bedrock foundation model before injecting cache points; any remaining cache-ttl-only improvement should be tracked separately. What I checked:
So I’m closing this here and keeping the remaining discussion on the canonical linked item. Codex Review notes: model gpt-5.5, reasoning high; reviewed against 2dba9e6a765a; fix evidence: release v2026.4.24, commit 24266af1ce1b. |
Summary
Application inference profiles with random IDs (e.g.,
7g9cumu1wd7v) are not recognized as Claude models byisAnthropicBedrockModel(), disabling prompt caching. This PR adds model name resolution from provider config as a fallback.Problem
When using Bedrock application inference profiles for cost tracking, the profile ARN contains a random ID like
arn:aws:bedrock:ap-northeast-1:123456:application-inference-profile/7g9cumu1wd7v. The currentisAnthropicBedrockModel()checksprofileId.includes("claude")which fails, causing:createBedrockNoCacheWrapperwraps the stream withcacheRetention: "none"resolveAnthropicCacheRetentionFamilyreturnsundefinedThis was noted in the source as a known limitation:
Solution
Instead of calling the Bedrock API, we use the already-available model name from the provider config. The gateway's
openclaw.jsoncontains the model definition with a display name (e.g.,"Claude Sonnet 4.6 via Inference Profile"), which is accessible via theconfigparameter inwrapStreamFn.Changes:
isAnthropicBedrockModel()gains optionalmodelNameparameter for name-based fallbackresolveModelName()helper looks up display name from provider config (canonical key first, then aliases)baseWrapStreamFnpassesconfigthrough the chain to enable model name resolutionChanges
src/agents/pi-embedded-runner/anthropic-family-cache-semantics.tsmodelNameparamextensions/amazon-bedrock/register.sync.runtime.tsresolveModelName(), pass config through chainsrc/agents/pi-embedded-runner/anthropic-family-cache-semantics.test.tsextensions/amazon-bedrock/index.test.tsAI Assistance
This PR was developed with AI assistance (Claude Code). All changes tested locally — 37 tests pass (27 existing + 14 new). The
pnpm checkhas pre-existing failures in unrelated extensions; our 4 files pass oxlint/oxfmt cleanly.Test plan
isAnthropicBedrockModelwith direct model IDs (existing behavior preserved)wrapStreamFnenables caching when config has Claude model namewrapStreamFndisables caching when no config providedFixes #5290