Skip to content

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

Closed

Description

@stevoland

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:

if (
model.providerID === "anthropic" ||
model.api.id.includes("anthropic") ||
model.api.id.includes("claude") ||
model.api.npm === "@ai-sdk/anthropic"
) {
msgs = applyCaching(msgs, model.providerID)
}

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

Activity

  1. alemairebe commented on Jan 21, 2026

    @alemairebe

    see #2746 for a solution

  2. stevoland commented on Jan 21, 2026

    @stevoland
    ContributorAuthor

    @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 #9838

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions