Skip to content

fix kimi k2 tool parser issue#26918

Draft
luojiaxuan wants to merge 8 commits into
vllm-project:mainfrom
luojiaxuan:feat/kimi-k2-parser-gavin
Draft

fix kimi k2 tool parser issue#26918
luojiaxuan wants to merge 8 commits into
vllm-project:mainfrom
luojiaxuan:feat/kimi-k2-parser-gavin

Conversation

@luojiaxuan

@luojiaxuan luojiaxuan commented Oct 15, 2025

Copy link
Copy Markdown

Purpose

Test Plan

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors.

You ask your reviewers to trigger select CI tests on top of fastcheck CI.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

🚀

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces significant changes to the KimiK2ToolParser to improve its robustness in handling tool calls, especially for malformed JSON and non-standard token sequences from the Kimi K2 model. A new normalize_quotes_for_json function is added to handle complex string cleaning, and the logic for both streaming and non-streaming tool call extraction has been heavily modified. While the changes seem to address the core issue, there are several critical and high-severity issues related to code quality and maintainability, such as the use of bare except clauses, local imports, and leftover commented-out code and merge markers. These should be addressed to ensure the code is clean, correct, and maintainable.

Comment thread vllm/entrypoints/openai/tool_parsers/kimi_k2_tool_parser.py
Comment thread vllm/entrypoints/openai/tool_parsers/kimi_k2_tool_parser.py Outdated
Comment thread vllm/entrypoints/openai/tool_parsers/kimi_k2_tool_parser.py Outdated
Comment thread vllm/entrypoints/openai/tool_parsers/kimi_k2_tool_parser.py Outdated
Comment thread vllm/entrypoints/openai/tool_parsers/kimi_k2_tool_parser.py
Comment thread vllm/entrypoints/openai/tool_parsers/kimi_k2_tool_parser.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Comment thread vllm/entrypoints/openai/tool_parsers/kimi_k2_tool_parser.py
luojiaxuan and others added 7 commits October 15, 2025 11:51
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Jiaxuan Luo <jluo50@jhu.edu>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Jiaxuan Luo <jluo50@jhu.edu>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Jiaxuan Luo <jluo50@jhu.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant