Skip to content

Olmo3 tool parser and tests#26126

Closed
pdasigi wants to merge 167 commits intovllm-project:mainfrom
pdasigi:olmo3_parser
Closed

Olmo3 tool parser and tests#26126
pdasigi wants to merge 167 commits intovllm-project:mainfrom
pdasigi:olmo3_parser

Conversation

@pdasigi
Copy link
Copy Markdown
Contributor

@pdasigi pdasigi commented Oct 2, 2025

Purpose

This PR adds a tool parser for parsing the function calls made by the Olmo 3 model. Support for the model has already been merged (#24534). Olmo 3 outputs function calls in the following format

<function_calls>function1(arg1=value1)\nfunction2(arg2=value2)</function_calls>

This format is similar to the one that the existing Pythonic parser expects except for the presence of xml tags and function calls being delimited by newline characters instead of being represented as a list within brackets.

Test Plan

This PR also includes tests. Existing tests have not been modified or will be impacted.

Test Result

pytest tests/entrypoints/openai/tool_parsers/test_olmo3_tool_parser.py

Output:

========================================================================= test session starts ==========================================================================
platform darwin -- Python 3.11.13, pytest-8.4.2, pluggy-1.6.0
rootdir: /Users/pradeepd/workspace/vllm
configfile: pyproject.toml
plugins: anyio-4.10.0
collected 20 items                                                                                                                                                     

tests/entrypoints/openai/tool_parsers/test_olmo3_tool_parser.py ....................                                                                             [100%]

========================================================================== 20 passed in 1.67s ==========================================================================

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

github-actions bot commented Oct 2, 2025

👋 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.

🚀

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 a tool parser for the Olmo 3 model, which uses a Pythonic function call format wrapped in XML-like tags. The implementation is accompanied by a comprehensive set of tests. My review focuses on the correctness and maintainability of the new parser. I've identified a few issues related to how the XML tags are removed, which could lead to incorrect parsing of tool calls. Additionally, there's significant code duplication from an existing parser, which could pose future maintenance challenges. I've provided suggestions to address these points.



@ToolParserManager.register_module("olmo3")
class Olmo3PythonicToolParser(ToolParser):
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.

high

This class duplicates a significant amount of code from PythonicToolParser. This creates a maintenance burden, as changes in one parser may need to be manually synchronized with the other. To improve maintainability, consider refactoring to share code. One approach is to have Olmo3PythonicToolParser inherit from PythonicToolParser and override specific methods. The differences in helper functions like _get_parameter_value could be handled by making them methods of the class, allowing them to be overridden as well.

Comment on lines +66 to +69
# Remove xml tags.
model_output = (
model_output.replace("<function_calls>", "").replace("</function_calls>", "").strip()
)
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.

high

Using str.replace() to remove the <function_calls> tags is not safe. If the tag strings appear inside a function argument (e.g., as part of a string literal), replace() will incorrectly remove them, corrupting the tool call data. It's safer to use a regular expression to extract only the content between the outermost tags.

Suggested change
# Remove xml tags.
model_output = (
model_output.replace("<function_calls>", "").replace("</function_calls>", "").strip()
)
# Extract content from within <function_calls> tags.
match = re.search(r"<function_calls>(.*?)</function_calls>",
model_output, re.DOTALL)
if match:
model_output = match.group(1).strip()

Comment on lines +132 to +134
if current_text.endswith("</function_calls>"):
current_text = current_text[:current_text.
rfind("</function_calls>")]
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.

high

Using rfind to remove the closing </function_calls> tag is unsafe. If the tag string appears within a function's string argument, rfind could find the wrong occurrence and truncate the text incorrectly. Since this is for streaming and the closing tag is expected at the very end of the complete tool call block, you can safely remove it by slicing from the end of the string.

            if current_text.endswith("</function_calls>"):
                current_text = current_text[:-len("</function_calls>")]

pdasigi and others added 19 commits October 2, 2025 15:16
Signed-off-by: Pradeep Dasigi <pradeepd@allenai.org>
…air (vllm-project#25733)

Signed-off-by: yiting.jiang <yiting.jiang@daocloud.io>
…idden performance regressions (vllm-project#25738)

Signed-off-by: Andrew Sansom <andrew@protopia.ai>
… is enabled (vllm-project#25739)

Signed-off-by: Andrew Sansom <andrew@protopia.ai>
…a stride bug in causal_conv_1d. (vllm-project#25743)

Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com>
Signed-off-by: zxw <1020938856@qq.com>
…vllm-project#25698)

Signed-off-by: Sage Moore <sage@neuralmagic.com>
Co-authored-by: Robert Shaw <114415538+robertgshaw2-redhat@users.noreply.github.com>
Signed-off-by: 许文卿 <xwq391974@alibaba-inc.com>
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
Signed-off-by: Chih-Chieh-Yang <7364402+cyang49@users.noreply.github.com>
Co-authored-by: RishiAstra <40644327+RishiAstra@users.noreply.github.com>
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Signed-off-by: wang.yuqi <noooop@126.com>
Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
…`dbo_prefill_token_threshold`) (vllm-project#25622)

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
@mergify mergify bot added documentation Improvements or additions to documentation ci/build deepseek Related to DeepSeek models llama Related to Llama models multi-modality Related to multi-modality (#4194) new-model Requests to new models performance Performance-related issues qwen Related to Qwen models gpt-oss Related to GPT-OSS models rocm Related to AMD ROCm labels Oct 2, 2025
@mergify mergify bot added v1 tpu Related to Google TPUs kv-connector and removed tpu Related to Google TPUs labels Oct 2, 2025
@pdasigi pdasigi closed this Oct 2, 2025
@github-project-automation github-project-automation bot moved this from To Triage to Done in gpt-oss Issues & Enhancements Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/build deepseek Related to DeepSeek models documentation Improvements or additions to documentation frontend gpt-oss Related to GPT-OSS models kv-connector llama Related to Llama models multi-modality Related to multi-modality (#4194) new-model Requests to new models performance Performance-related issues qwen Related to Qwen models rocm Related to AMD ROCm speculative-decoding structured-output tool-calling v1

Projects

Status: Done
Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.