Prompt caching not working: app does not send anthropic-beta header on /anthropic/v1/messages requests
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Bắt đầu bằng cách theo dõi quá trình tạo request của ứng dụng Copilot cho endpoint /anthropic/v1/messages và cách supports_prompt_caching được đọc. Xác nhận rằng các request dành cho các model của custom provider đủ điều kiện có chứa anthropic-beta: prompt-caching-2024-07-31, trong khi các request khác vẫn không thay đổi; xác minh header gửi đi bằng thiết lập ghi log request hoặc proxy hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
The Copilot app correctly uses the /anthropic/v1/messages endpoint when a custom model provider is configured with an Anthropic-compatible base URL. However, it does not send the anthropic-beta: prompt-caching-2024-07-31 header, so prompt caching is never activated — even when cache_control: {type: ephemeral} markers are present in the request.
Evidence (from local hai-desktop proxy logs)
The local hai-desktop proxy forwards requests and adds ?beta=true to the upstream URL only when it sees the anthropic-beta header from the client. Comparing the two callers:
| Client | User-Agent | Upstream target | Caching |
|---|---|---|---|
| Claude Code | claude-cli/2.1.222 |
...llm-proxy/anthropic/v1/messages?beta=true |
✅ works |
| Copilot app | Anthropic/JS 0.94.0 |
...llm-proxy/anthropic/v1/messages |
❌ broken |
Claude Code sends anthropic-beta: prompt-caching-2024-07-31; the Copilot app does not.
Confirmed by live test (same proxy, same model)
With anthropic-beta header (Claude Code / manual curl):
- Request 1:
cache_creation_input_tokens: 1202, cost0.005942 - Request 2:
cache_read_input_tokens: 1202, cost0.000587— 10× cheaper
Without anthropic-beta header (Copilot app):
- Request 1:
cache_creation_input_tokens: 0 - Request 2:
cache_read_input_tokens: 0— no savings
Workaround
I added a local HTTP caching proxy on a separate port that sits in front of hai-desktop to avoid redundant calls. This is a symptom fix, not a solution.
Request
When the Copilot app is configured with a custom provider using an Anthropic-format endpoint, and a model reports supports_prompt_caching: true, the app should send:
anthropic-beta: prompt-caching-2024-07-31
on requests to /anthropic/v1/messages. This is the only missing piece — the endpoint, the model, and the cache_control markers in the request body are all already correct.
- Ngôn ngữ chính
- Không có dữ liệu ngôn ngữ
- Star
- 2.1k
- Fork
- 157
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/app
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
use-agent-os/agent-os#3312 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
-
needs-acceptance wg/data-plane-networking
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
vllm-project/semantic-router#4024 · 1 bình luận ·
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
amponce/archive-movie-browser#165 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100