Skip to content

Feature/intern s1 parser - #40115

Closed
i-square wants to merge 5 commits into
vllm-project:mainfrom
i-square:feature/intern-s1-parser
Closed

i-square wants to merge 5 commits into
vllm-project:mainfrom
i-square:feature/intern-s1-parser

Conversation

@i-square

@i-square i-square commented Apr 17, 2026 •

Copy link
Copy Markdown

Purpose

Add dedicated intern-s1 reasoning and tool parsers without changing the
existing internlm parser behavior.

This keeps the fix scoped to Intern-S1 and avoids compatibility risk for
existing internlm users and models.

This PR includes:

  • a new intern-s1 reasoning parser that hoists action blocks out of
    <think>...</think> into content for non-streaming responses, so the
    tool parser can extract standard OpenAI tool calls without changing the
    shared serving flow
  • a new intern-s1 tool parser that is more tolerant of the current
    Intern-S1 output shape:
    • allows whitespace/newlines between <|action_start|> and <|plugin|>
    • supports multiple action blocks in non-streaming extraction
    • falls back to plain text when tool JSON is malformed instead of raising
    • adds a safer fallback for the first streamed arguments delta
  • lazy registration for both --reasoning-parser intern-s1 and
    --tool-call-parser intern-s1
  • focused unit tests for the new parsers

The intent is to fix Intern-S1 tool parsing with the smallest possible impact
surface, rather than changing generic InternLM parsing behavior for all users.

Test Plan

Static checks run locally:

git diff --check
python -m compileall \
  vllm/tool_parsers/intern_s1_tool_parser.py \
  vllm/reasoning/intern_s1_reasoning_parser.py \
  tests/tool_parsers/test_intern_s1_tool_parser.py \
  tests/reasoning/test_intern_s1_reasoning_parser.py

Targeted tests added in this PR:

pytest tests/tool_parsers/test_intern_s1_tool_parser.py
pytest tests/reasoning/test_intern_s1_reasoning_parser.py

The new tests cover:

  • intern-s1 parser registration
  • hoisting action blocks from reasoning to content
  • keeping deepseek_r1 behavior when no action block is present
  • non-streaming parsing with spaced special tokens
  • non-streaming parsing with multiple action blocks
  • graceful fallback on malformed JSON
  • fallback behavior for the initial streamed arguments delta

Test Result

Passed locally:

  • git diff --check
  • python -m compileall ... for the new parser and test files
  • python -m pytest tests/tool_parsers/test_intern_s1_tool_parser.py tests/reasoning/test_intern_s1_reasoning_parser.py -q
    • result: 9 passed

Not run locally:

  • ruff

Notes about the local test environment:

  • pytest and tblib were installed into the local test env
  • mistral-common was aligned to 1.11.0 to match the repository's test
    dependency set
  • the new test files were made self-contained so they do not rely on external
    tokenizer downloads or GPU cleanup during teardown

Documentation update:

  • Updated docs/features/tool_calling.md to recommend
    --tool-call-parser intern-s1 --reasoning-parser intern-s1 for Intern-S1
    models instead of reusing the generic internlm parser guidance.
  • Updated docs/features/reasoning_outputs.md to list Intern-S1 as a
    supported reasoning model with tool calling and to show the recommended
    server flags.

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.

@claude claude 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.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify

mergify Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Documentation preview: https://vllm--40115.org.readthedocs.build/en/40115/

@mergify mergify Bot added documentation Improvements or additions to documentation tool-calling labels Apr 17, 2026
@mergify

mergify Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Hi @i-square, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy failing?
mypy is run differently in CI. If the failure is related to this check, please use the following command to run it locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10

@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 support for Intern-S1 and Intern-S1-mini models, adding dedicated reasoning and tool-calling parsers. The implementation includes the InternS1ReasoningParser, which hoists action blocks from reasoning to content, and the InternS1ToolParser for extracting tool calls in both streaming and non-streaming modes. Documentation and tests for these new features are also provided. However, critical bugs were identified in the streaming tool parser implementation: one logic error prematurely blocks the streaming of tool arguments, and another issue involves incorrect list indexing that would lead to IndexError exceptions during execution.

Signed-off-by: i-square <i_square@qq.com>
Signed-off-by: i-square <i_square@qq.com>
Signed-off-by: i-square <i_square@qq.com>
Signed-off-by: i-square <i_square@qq.com>
@i-square
i-square force-pushed the feature/intern-s1-parser branch 2 times, most recently from 1fdeec6 to 998fafb Compare April 17, 2026 09:00
Signed-off-by: i-square <i_square@qq.com>
@i-square

Copy link
Copy Markdown
Author

@aarnphm @chaunceyjiang @sfeng33 gentle ping on this PR. Let me know if you need any additional context or changes to make the review easier. Thanks!

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity within 90 days. It will be automatically closed if no further activity occurs within 30 days. Leave a comment if you feel this pull request should remain open. Thank you!

@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed due to inactivity. Please feel free to reopen if you intend to continue working on it. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation stale Over 90 days of inactivity tool-calling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant