fix(server): gate media parts on /v1/messages/count_tokens like the other non-generating routes
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 76/100
Direzione di ricerca
Inizia in src/server/routes/anthropic.rs da anthropic_count_tokens e confronta il suo ordinamento con anthropic_messages, soprattutto in corrispondenza di anthropic_request_to_chat, media_capability_rejection, media_rejection_response e MAX_TOOLS. Riutilizza il pattern create_app più oneshot in src/server/max_tokens_route_tests.rs, quindi esegui il comando cargo test indicato. Il lavoro è completato quando un URL di immagine su un checkpoint di solo testo viene rifiutato prima del rendering o del recupero, mantenendo la forma di risposta esistente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Rust
- Stelle
- 484
- Fork
- 71
- Merge medio
- 4h 46m
- PR unite (30g)
- 344
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di lablup/mlxcel
-
docs(webpage): add a webpage/site README covering the pnpm/uv/zensical build and deploy contractApertapriority:low status:ready type:docs
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
docs(reports): add an index README for the 308-file TECHNICAL_REPORTS directoryForse già presa @inureyes l’ha presa 11 giorni fa. Apertapriority:low status:ready type:docs
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
priority:low status:ready type:docs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
I maintainer di solito rispondono entro 1 giorno
-
priority:low status:ready type:docs
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
priority:low status:ready type:chore
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di lablup/mlxcel
Issue simili
-
binding:python bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
coollabsio/orbit#72 ·
I maintainer di solito rispondono entro 1 giorno
-
Synth suite fails unless run from the repo root: signal_flow's default machine path is cwd-relativeApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
Nimblesite/osprey#370 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
bug order-flow studies ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
userFRM/egui-charts#2417 ·
I maintainer di solito rispondono entro 1 giorno