Claude w/ bedrock custom inference profile - no caching #7059

Closed
opened 2026-02-16 18:06:03 -05:00 by yindo · 2 comments
Owner

Originally created by @stevoland on GitHub (Jan 21, 2026).

Originally assigned to: @thdxr on GitHub.

Description

With custom inference profile model.api.id == arn:aws:bedrock:xxx:yyy:application-inference-profile/zzz so the special case for anthropic caching isn't entered: https://github.com/anomalyco/opencode/blob/d6caaee8169ff1abd7012cc1d036f2621703a757/packages/opencode/src/provider/transform.ts#L247-L254

and cached tokens always 0

tokens: {
    input: 19373,
    output: 12,
    reasoning: 0,
    cache: {
      write: 0,
      read: 0,
    },
  },

Propose this change

index f6b7ec8cbc..a0209b8c31 100644
--- a/packages/opencode/src/provider/transform.ts
+++ b/packages/opencode/src/provider/transform.ts
@@ -251,6 +251,8 @@
       model.providerID === "anthropic" ||
       model.api.id.includes("anthropic") ||
       model.api.id.includes("claude") ||
+      model.id.includes("anthropic") ||
+      model.id.includes("claude") ||
       model.api.npm === "@ai-sdk/anthropic"
     ) {
       msgs = applyCaching(msgs, model.providerID)

Which fixes for this config

"amazon-bedrock": {
  "options": {
    "profile": "xxx",
    "region": "yyy",
    "setCacheKey": true
  },
  "models": {
    "claude-sonnet-4.5": {
      "id": "arn:aws:bedrock:yyy:zzz:application-inference-profile/nnn"
    }
  }
},

Unless you have an alternative approach?

Will raise PR in the meantime, thanks!

Plugins

n/a

OpenCode version

1.1.26

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

macOS 26.2

Terminal

ghostty

Originally created by @stevoland on GitHub (Jan 21, 2026). Originally assigned to: @thdxr on GitHub. ### Description With custom inference profile `model.api.id` == `arn:aws:bedrock:xxx:yyy:application-inference-profile/zzz` so the special case for anthropic caching isn't entered: https://github.com/anomalyco/opencode/blob/d6caaee8169ff1abd7012cc1d036f2621703a757/packages/opencode/src/provider/transform.ts#L247-L254 and cached tokens always 0 ``` tokens: { input: 19373, output: 12, reasoning: 0, cache: { write: 0, read: 0, }, }, ``` Propose this change ```diff index f6b7ec8cbc..a0209b8c31 100644 --- a/packages/opencode/src/provider/transform.ts +++ b/packages/opencode/src/provider/transform.ts @@ -251,6 +251,8 @@ model.providerID === "anthropic" || model.api.id.includes("anthropic") || model.api.id.includes("claude") || + model.id.includes("anthropic") || + model.id.includes("claude") || model.api.npm === "@ai-sdk/anthropic" ) { msgs = applyCaching(msgs, model.providerID) ``` Which fixes for this config ``` "amazon-bedrock": { "options": { "profile": "xxx", "region": "yyy", "setCacheKey": true }, "models": { "claude-sonnet-4.5": { "id": "arn:aws:bedrock:yyy:zzz:application-inference-profile/nnn" } } }, ``` Unless you have an alternative approach? Will raise PR in the meantime, thanks! ### Plugins n/a ### OpenCode version 1.1.26 ### Steps to reproduce _No response_ ### Screenshot and/or share link _No response_ ### Operating System macOS 26.2 ### Terminal ghostty
yindo added the bug label 2026-02-16 18:06:03 -05:00
yindo closed this issue 2026-02-16 18:06:03 -05:00
Author
Owner

@alemairebe commented on GitHub (Jan 21, 2026):

see https://github.com/anomalyco/opencode/issues/2746 for a solution

@alemairebe commented on GitHub (Jan 21, 2026): see https://github.com/anomalyco/opencode/issues/2746 for a solution
Author
Owner

@stevoland commented on GitHub (Jan 21, 2026):

@alemairebe thanks but I think I don't think that addresses the issue here. Specifically, missing cachePoint on messages leading to always 0 cache reads.

I may be missing something?

This is my proposal https://github.com/anomalyco/opencode/pull/9838

@stevoland commented on GitHub (Jan 21, 2026): @alemairebe thanks but I think I don't think that addresses the issue here. Specifically, missing `cachePoint` on messages leading to always 0 cache reads. I may be missing something? This is my proposal https://github.com/anomalyco/opencode/pull/9838
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7059