Skip to content

fix(tokenizer): convert Anthropic tools to OpenAI schema for /render#1986

Closed
dkhachyan wants to merge 2 commits into
llm-d:mainfrom
dkhachyan:convert-anthropic-tools
Closed

fix(tokenizer): convert Anthropic tools to OpenAI schema for /render#1986
dkhachyan wants to merge 2 commits into
llm-d:mainfrom
dkhachyan:convert-anthropic-tools

Conversation

@dkhachyan

Copy link
Copy Markdown

What type of PR is this?

/kind bug

What this PR does / why we need it:

Follow-up to #1896.

Anthropic Messages requests (/v1/messages) failed tokenization against the
vLLM /render endpoint when the request carried tools. The router forwarded
Anthropic-shaped tool definitions ({name, description, input_schema})
verbatim, but vLLM's OpenAI-compatible /render expects the function schema
({type: "function", function: {name, description, parameters}}), so it
rejected the request with HTTP 400 (Field required: body.tools[0].function).
This broke the token-producer path and, in turn, precise-prefix-cache routing
for Claude Code traffic.

MessagesToRenderChatRequest now maps Anthropic custom tools into the OpenAI
function schema (input_schema -> parameters, nested under function).
Tools that are already OpenAI-shaped (carry a function field) or are not
object-shaped pass through unchanged.

Which issue(s) this PR fixes:

Fixes #1861

@dkhachyan
dkhachyan requested review from a team, liu-cong, sagearc and vMaroon as code owners July 13, 2026 14:05
@github-actions github-actions Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚨 Unsigned commits detected! Please sign your commits.

For instructions on how to set up GPG/SSH signing and verify your commits, please see GitHub Documentation.

@dkhachyan
dkhachyan force-pushed the convert-anthropic-tools branch from 3b8cfc5 to 2bbfaf1 Compare July 13, 2026 14:11

@sagearc sagearc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dkhachyan, please fix your commits sign-off
https://github.com/llm-d/llm-d/blob/main/PR_SIGNOFF.md

Signed-off-by: Denis Khachyan <khachyanda@gmail.com>
@dkhachyan
dkhachyan force-pushed the convert-anthropic-tools branch from 2bbfaf1 to f924bca Compare July 15, 2026 19:01
@dkhachyan dkhachyan closed this Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anthropic /v1/messages not tokenized by the render (vLLM) token-producer backend — precise prefix cache never hits

2 participants