fix(server): gate media parts on /v1/messages/count_tokens like the other non-generating routes
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Bắt đầu tại src/server/routes/anthropic.rs ở anthropic_count_tokens và so sánh thứ tự của nó với anthropic_messages, đặc biệt là xung quanh anthropic_request_to_chat, media_capability_rejection, media_rejection_response và MAX_TOOLS. Tái sử dụng pattern create_app cộng với oneshot trong src/server/max_tokens_route_tests.rs, sau đó chạy lệnh cargo test được liệt kê. Hoàn thành có nghĩa là một URL hình ảnh trên checkpoint chỉ có văn bản bị từ chối trước khi render hoặc fetch, với shape phản hồi hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
anthropic_count_tokens (src/server/routes/anthropic.rs:694) calls prepare_chat_request_with_cache at :717 with no media-capability gate in front of it. Rendering is also what resolves media, so that call downloads every image_url payload the translated request carries. An Anthropic image block with source.type: "url" therefore gets fetched and counted on a checkpoint with no image tower, and the route never reaches a model worker, so nothing downstream refuses it either. The sibling handler anthropic_messages (:101) already runs crate::server::media_capability_rejection on translated.chat_request and renders it through media_rejection_response (added by PR #1740), which keeps 400 invalid_request_error for a combined video plus audio refusal and 501 not_supported_error per modality.
Why this is filed separately
A pre-existing gap in #1451's scope, not a regression. PR #1740 (issue #1349) closed the same hole on the three other routes that render without generating: router_front, /apply-template, /chat/completions/input_tokens and /v1/chat/completions/input_tokens. This is the fourth, left out because fixing it changes behavior on a route that PR did not otherwise touch.
Proposed fix
Insert the same media_capability_rejection plus media_rejection_response pair into anthropic_count_tokens immediately after anthropic_request_to_chat, ahead of the existing MAX_TOOLS guard, matching the order anthropic_messages uses. Depends on #1740 landing, since the helper arrives with it.
AnthropicContentBlock(src/server/types/anthropic_request.rs:181) has no video or audio variant, so only the per-modality arm is reachable here today.- Existing tests in
anthropic.rscallmedia_rejection_responsedirectly, not the handler, so a regression test needs an HTTP-level harness: reuse thecreate_appplusoneshotpattern insrc/server/max_tokens_route_tests.rs.
Acceptance criteria
- The gate runs before the render on
/v1/messages/count_tokens. - A text-only checkpoint sent an Anthropic
imageblock gets the refusal/v1/messagesgives, not a token count. - No URL named by the request is fetched before the refusal.
- A test covers it.
Verification
cargo test --workspace --profile test-fast --features metal,accelerate server::routes::anthropic
- Ngôn ngữ chính
- Rust
- Star
- 493
- Fork
- 77
- Merge trung bình
- 6 giờ 12 phút
- Pull request đã merge (30 ngày)
- 364
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc 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 lablup/mlxcel
-
docs(webpage): add a webpage/site README covering the pnpm/uv/zensical build and deploy contractĐang mởpriority:low status:ready type:docs
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
docs(reports): add an index README for the 308-file TECHNICAL_REPORTS directoryCó thể đã có người làm @inureyes đã nhận 15 ngày trước. Đang mởpriority:low status:ready type:docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
docs(surgery): mlxcel-surgery comments still describe shipped work as futureCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởpriority:low status:ready type:docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:low status:ready type:chore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
docs(cli): sync the serve --tp-size family list with generate and mlxcel-serverCó thể đã có người làm @hephaex đã nhận hôm nay. Đang mởpriority:low status:ready type:docs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của lablup/mlxcel
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ci javascript tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
jonathanong/no-mistakes#3258 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add to bmi docsĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
eWaterCycle/bmi-rust#2 ·
-
area: cpu-engines area: fuzzer good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 91/100
hffgzktbcc-blip/ounce-core#402 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
compiler
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
HerringtonDarkholme/hd-lang#1699 ·
Maintainer thường phản hồi trong vòng 1 ngày