The Claude model cannot properly enable the caching function #7903

Open
opened 2026-02-16 18:08:37 -05:00 by yindo · 4 comments
Owner

Originally created by @tisoz on GitHub (Jan 28, 2026).

Originally assigned to: @thdxr on GitHub.

Description

"npm": "@ai-sdk/anthropic",
"name": "test-claude",
"options": {
    "baseURL": "https://code.newcli.com/claude/aws/v1",
    "apiKey": "sk-ant-oat01-Vla5Fe6Fg-G_M2zd4sgDJvvLkz7q_f2dOHDqHBdHcNmdSApijjHB4b-xxx",
    "setCacheKey": true
},

I have configured a third-party model for testing
and through testing . i found problem .
in opencode the claude request not enable metadata.userid


{
    "model": "claude-sonnet-4-5-20250929",
    "max_tokens": 64000,
    "system": [
        {
            "type": "text",
            "text": "xxx",
            "cache_control": {
                "type": "ephemeral"
            }
        }
    ],
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "hi",
                    "cache_control": {
                        "type": "ephemeral"
                    }
                }
            ]
        }
    ],
    "metadata": {
        "user_id": "user_9f76af04f457a811f11a4d4c36986076c434db17d2d71d1abc8ac06bfb344ea3_account__session_3d44c07c-405f-4ae8-b6ec-fa28c5b91c45"
    },
    "tool_choice": {
        "type": "auto"
    },
    "stream": true
}

when i take this params , cache be work .
i noticed one issue
https://github.com/anomalyco/opencode/pull/8138

but it's be closed , so should i can do , can we enable other params to enable cache fetures

Plugins

none

OpenCode version

1.1.40

Steps to reproduce

  1. add a provider in opencode.json
        "test-claude": {
            "npm": "@ai-sdk/anthropic",
            "name": "test-claude",
            "options": {
                "baseURL": "https://code.newcli.com/claude/aws/v1",
                "apiKey": "sk-ant-oat01-Vla5Fe6Fg-xxx",
                "setCacheKey": true
            },
            "models": {
                "claude-sonnet-4-5-20250929": {
                    "name": "claude-sonnet-4-5-20250929",
                    "thinking": true
                }
            }
        }
  1. if you need i will send you private message for the key
  2. test it in claude cli and opencode cli to compare

Screenshot and/or share link

Image

Operating System

WINDOWS 11

Terminal

terminal

Originally created by @tisoz on GitHub (Jan 28, 2026). Originally assigned to: @thdxr on GitHub. ### Description ``` "npm": "@ai-sdk/anthropic", "name": "test-claude", "options": { "baseURL": "https://code.newcli.com/claude/aws/v1", "apiKey": "sk-ant-oat01-Vla5Fe6Fg-G_M2zd4sgDJvvLkz7q_f2dOHDqHBdHcNmdSApijjHB4b-xxx", "setCacheKey": true }, ``` I have configured a third-party model for testing and through testing . i found problem . in opencode the claude request not enable `metadata.userid` ```json { "model": "claude-sonnet-4-5-20250929", "max_tokens": 64000, "system": [ { "type": "text", "text": "xxx", "cache_control": { "type": "ephemeral" } } ], "messages": [ { "role": "user", "content": [ { "type": "text", "text": "hi", "cache_control": { "type": "ephemeral" } } ] } ], "metadata": { "user_id": "user_9f76af04f457a811f11a4d4c36986076c434db17d2d71d1abc8ac06bfb344ea3_account__session_3d44c07c-405f-4ae8-b6ec-fa28c5b91c45" }, "tool_choice": { "type": "auto" }, "stream": true } ``` when i take this params , cache be work . i noticed one issue https://github.com/anomalyco/opencode/pull/8138 but it's be closed , so should i can do , can we enable other params to enable cache fetures ### Plugins none ### OpenCode version 1.1.40 ### Steps to reproduce 1. add a provider in opencode.json ``` "test-claude": { "npm": "@ai-sdk/anthropic", "name": "test-claude", "options": { "baseURL": "https://code.newcli.com/claude/aws/v1", "apiKey": "sk-ant-oat01-Vla5Fe6Fg-xxx", "setCacheKey": true }, "models": { "claude-sonnet-4-5-20250929": { "name": "claude-sonnet-4-5-20250929", "thinking": true } } } ``` 2. if you need i will send you private message for the key 3. test it in claude cli and opencode cli to compare ### Screenshot and/or share link <img width="1226" height="462" alt="Image" src="https://github.com/user-attachments/assets/ebd9f7a3-1889-4536-893f-9a068db7fb36" /> ### Operating System WINDOWS 11 ### Terminal terminal
yindo added the windowsbug labels 2026-02-16 18:08:37 -05:00
Author
Owner

@RicardoMonteiroSimoes commented on GitHub (Jan 29, 2026):

Not sure of the format of anthropic api keys, but your first one seems rather exposing, just a small FYI

@RicardoMonteiroSimoes commented on GitHub (Jan 29, 2026): Not sure of the format of anthropic api keys, but your first one seems rather exposing, just a small FYI
Author
Owner

@tisoz commented on GitHub (Jan 29, 2026):

Not sure of the format of anthropic api keys, but your first one seems rather exposing, just a small FYI不清楚 Anthropic API 密钥的具体格式,但您的第一个密钥似乎有些暴露,只是提醒一下

it's be ok , i already deal it

@tisoz commented on GitHub (Jan 29, 2026): > Not sure of the format of anthropic api keys, but your first one seems rather exposing, just a small FYI不清楚 Anthropic API 密钥的具体格式,但您的第一个密钥似乎有些暴露,只是提醒一下 it's be ok , i already deal it
Author
Owner

@70akaline commented on GitHub (Feb 1, 2026):

could we accelerate this fix pr merge procees?

https://github.com/anomalyco/opencode/pull/11276

@70akaline commented on GitHub (Feb 1, 2026): could we accelerate this fix pr merge procees? https://github.com/anomalyco/opencode/pull/11276
Author
Owner

@tisoz commented on GitHub (Feb 1, 2026):

could we accelerate this fix pr merge procees?

#11276

https://www.npmjs.com/package/opencode-windows-fixed-cache?activeTab=readme

you can use it before the release

@tisoz commented on GitHub (Feb 1, 2026): > could we accelerate this fix pr merge procees? > > [#11276](https://github.com/anomalyco/opencode/pull/11276) https://www.npmjs.com/package/opencode-windows-fixed-cache?activeTab=readme you can use it before the release
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7903