Repository navigation
[None][fix] Responses: detokenize for the parsers as chat completions does - #21072
Conversation
… does The Responses route never applied the parsers' special-token decoding that chat completions applies (_configure_parser_special_token_decoding): parsers that read special tokens need them kept, and Kimi-K3's also need them without spaces in between. Without it, Kimi-K3 behind /v1/responses gets <|open|>tools<|sep|> as <|open|> tools <|sep|>, its tool parser never matches, and every tool call reaches the client as message text. For the DeepSeek DSML parsers the end-of-sentence token was dropped from the decoded text where chat keeps it. Signed-off-by: JunyiXu-nv <[email protected]>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Configure and verify decoding settings tensorrt_llm/serve/openai_server.py, tests/unittest/llmapi/apps/test_tool_parsers.py |
Non-Harmony Responses API requests configure special-token decoding based on parser settings and tool presence. The mocked route test checks the settings across five configurations. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Merge Risk: 
Minimal · up to d6fd0
-
The Responses decoding change has no identified issue that should block merging after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
/bot run --disable-fail-fast |
|
PR_Github #80800 [ run ] triggered by Bot. Commit: |
|
PR_Github #80800 [ run ] completed with state
|
|
Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements. |
|
/bot run |
|
PR_Github #81560 [ run ] triggered by Bot. Commit: |
|
PR_Github #81560 [ run ] completed with state |
Description
Chat completions sets the detokenizer up for the configured parsers (
_configure_parser_special_token_decoding):skip_special_tokens=False), the tool parser only when the request has tools;spaces_between_special_tokens=False), because K3 writes tag names between special tokens./v1/responsesnever applied it. Its requests were detokenized with the defaults, special tokens dropped and spaced:<|open|>tools<|sep|>arrives as<|open|> tools <|sep|>or loses its tokens. The tool parser never matches, and every tool call reaches the client as message text.deepseek_v32,deepseek_v4,deepseek_v41): their markup is not dropped, so calls still parse. The end-of-sentence token is dropped from the decoded text, where chat keeps it and the parser removes it. Anything that reads the raw text after decoding sees two different texts for the same output, depending on the endpoint.This PR applies the same setup on
/v1/responses, after the request is preprocessed, for non-Harmony models.has_toolscovers tools a client sends in anadditional_toolsinput item too, since those are moved intotoolswhen the request is parsed. The Harmony path is unchanged.Test Coverage
tests/unittest/llmapi/apps/test_tool_parsers.py(CPU, inl0_cpu.yml),TestConfigureParserSpecialTokenDecoding::test_the_responses_route_applies_it: drivesOpenAIServer.openai_responsesup to the engine submission and checks the sampling params it submits:kimi_k3reasoning and tool parsers, with tools: special tokens kept, no spaces;kimi_k3reasoning parser without tools: the same, since the reasoning parser applies to every request;deepseek_v32tool parser with tools: special tokens kept, spacing unchanged;deepseek_v32without tools, and no parser: unchanged.Three of these cases fail on main's code. On a build of current main,
test_tool_parsers.py,test_responses_store_replay.pyandtest_responses_input_preprocess.pypass: 1043 tests, against 1038 on main.PR Checklist
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.🤖 Generated with Claude Code
Dev Engineer Review
For non-Harmony
/v1/responsesrequests, the server now applies parser-specific special-token decoding after request preprocessing. This aligns Responses behavior with chat completions while leaving the Harmony path unchanged. No review findings or severity counts were supplied.QA Engineer Review
The change adds a parameterized Responses-route test in
tests/unittest/llmapi/apps/test_tool_parsers.py. It checks parser-specificskip_special_tokensandspaces_between_special_tokenssettings across Kimi-K3, DeepSeek V3.2, tool-presence, and no-parser cases. The test file is listed intests/integration/test_lists/test-db/l0_cpu.yml. No manual-QA list entry or test execution results were supplied. Coverage verdict: sufficient for the decoding settings covered by the test.Per-File QA Perspective
tensorrt_llm/serve/openai_server.py— Verify that non-Harmony Responses requests pass the configured parser and tool-presence context into decoding setup after preprocessing. Confirm that Harmony requests retain their existing behavior.tests/unittest/llmapi/apps/test_tool_parsers.py— The new parameterized route test verifies generation receives expected special-token settings for Kimi-K3 and DeepSeek V3.2 cases, including requests with and without tools. The file is listed in the CItest-db/l0_cpu.ymllist.