Skip to content

[https://nvbugs/5944411][fix] Handle anyOf parameter schemas in Qwen3Coder tool parser#12173

Merged
tijyojwad merged 1 commit intoNVIDIA:mainfrom
tijyojwad:fix-anyof-qwen3-parser
Mar 13, 2026
Merged

[https://nvbugs/5944411][fix] Handle anyOf parameter schemas in Qwen3Coder tool parser#12173
tijyojwad merged 1 commit intoNVIDIA:mainfrom
tijyojwad:fix-anyof-qwen3-parser

Conversation

@tijyojwad
Copy link
Collaborator

@tijyojwad tijyojwad commented Mar 12, 2026

Parameters using anyOf (e.g. Optional[int]) have no top-level "type" key, causing _convert_param_value to always default to "string". Treat anyOf schemas as "object" to trigger json.loads, which correctly parses integers, floats, booleans, objects, and arrays.

Made-with: Cursor

Fix cherry picked from vllm-project/vllm#36032

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for OpenAPI-style anyOf schemas in parameter definitions, enabling proper type conversion and handling of union types.
  • Tests

    • Added comprehensive unit tests for anyOf schema parameter parsing, validating type conversion and null value handling.

Description

Test Coverage

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

Parameters using anyOf (e.g. Optional[int]) have no top-level "type"
key, causing _convert_param_value to always default to "string". Treat
anyOf schemas as "object" to trigger json.loads, which correctly parses
integers, floats, booleans, objects, and arrays.

Signed-off-by: Joyjit Daw <1127155+tijyojwad@users.noreply.github.com>
Made-with: Cursor
@tijyojwad tijyojwad requested a review from a team as a code owner March 12, 2026 23:40
@tijyojwad tijyojwad requested a review from syuoni March 12, 2026 23:40
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2026

📝 Walkthrough

Walkthrough

Adds support for OpenAPI-style anyOf parameter schemas in the Qwen3 coder parser by treating anyOf entries as object types instead of defaulting to strings. When parameter config contains "anyOf", the parser now sets the parameter type to "object" to enable proper JSON parsing. Includes comprehensive unit tests validating type coercion and null value handling across multiple anyOf-based parameter types.

Changes

Cohort / File(s) Summary
anyOf Schema Support
tensorrt_llm/serve/tool_parser/qwen3_coder_parser.py
Added conditional logic to detect "anyOf" in parameter configs and set param_type to "object" for proper JSON deserialization of union-type parameters.
anyOf Parameter Parsing Tests
tests/unittest/llmapi/apps/test_tool_parsers.py
Added two new test cases verifying anyOf schema parameter parsing: one testing type coercion (int, float, bool, dict, list, string) and another validating null value handling for anyOf integer/null parameters.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning PR description lacks required sections: title format incomplete, Description and Test Coverage sections empty, checklist items not individually reviewed. Add proper PR title with ticket format [https://nvbugs/5944411][fix] at top, fill Description and Test Coverage sections with details, and individually address each checklist item with clear explanations rather than just checking the final box.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: handling anyOf parameter schemas in the Qwen3Coder tool parser, with proper formatting following the template.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can disable sequence diagrams in the walkthrough.

Disable the reviews.sequence_diagrams setting to disable sequence diagrams in the walkthrough.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/unittest/llmapi/apps/test_tool_parsers.py (1)

1010-1130: Add one literal-like string case for anyOf: [string, null]

Great coverage overall. Consider adding a case where label is true (unquoted) and assert it remains "true" as a string. That will guard against unintended coercion in union-with-null string schemas.

✅ Suggested test addition
     def test_parse_anyof_parameter_type_conversion(self, parser):
@@
         assert params["tags"] == [1, 2, 3]
         assert params["label"] == "hello"
+
+        text_string_literal = ("<tool_call>\n"
+                               "<function=create_record>\n"
+                               "<parameter=name>test</parameter>\n"
+                               "<parameter=label>true</parameter>\n"
+                               "</function>\n"
+                               "</tool_call>")
+        result_string_literal = parser.detect_and_parse(text_string_literal, [tool_def])
+        params_string_literal = json.loads(result_string_literal.calls[0].parameters)
+        assert params_string_literal["label"] == "true"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unittest/llmapi/apps/test_tool_parsers.py` around lines 1010 - 1130,
Update the anyOf string/null coverage by adding a literal-like case for the
"label" field in test_parse_anyof_parameter_type_conversion (or as a new test)
where the input uses an unquoted true token (<parameter=label>true</parameter>);
run parser.detect_and_parse and assert that result.calls[0].parameters parses
"label" to the string "true" (and isinstance(params["label"], str)) to ensure no
coercion to boolean occurs for anyOf: [{type: "string"}, {type: "null"}].
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tensorrt_llm/serve/tool_parser/qwen3_coder_parser.py`:
- Around line 377-379: The code currently forces param_type = "object" whenever
param_config[param_name] has "anyOf"; instead, inspect
param_config[param_name]["anyOf"] to find concrete non-null subtype(s) and set
param_type to that subtype when unambiguous (e.g., pick "string" if anyOf
contains {"type":"string"} and {"type":"null"}), otherwise fall back to
"object"; update the logic around param_config[param_name] and param_type so
values like true/false are parsed as boolean when anyOf includes boolean, and
ensure null remains allowed when anyOf includes null.

---

Nitpick comments:
In `@tests/unittest/llmapi/apps/test_tool_parsers.py`:
- Around line 1010-1130: Update the anyOf string/null coverage by adding a
literal-like case for the "label" field in
test_parse_anyof_parameter_type_conversion (or as a new test) where the input
uses an unquoted true token (<parameter=label>true</parameter>); run
parser.detect_and_parse and assert that result.calls[0].parameters parses
"label" to the string "true" (and isinstance(params["label"], str)) to ensure no
coercion to boolean occurs for anyOf: [{type: "string"}, {type: "null"}].

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a9a72c29-b24c-40c1-afad-bb3d1a0701b6

📥 Commits

Reviewing files that changed from the base of the PR and between 5cc0ccd and a9353bc.

📒 Files selected for processing (2)
  • tensorrt_llm/serve/tool_parser/qwen3_coder_parser.py
  • tests/unittest/llmapi/apps/test_tool_parsers.py

@tijyojwad tijyojwad changed the title [https://nvbugs/5944411][fix] Handle anyOf parameter schemas in Qwen3Coder tool parser [https://nvbugs/5944411][fix] @coderabbitai title Mar 12, 2026
@tijyojwad tijyojwad changed the title [https://nvbugs/5944411][fix] @coderabbitai title [https://nvbugs/5944411][fix] Handle anyOf parameter schemas in Qwen3Coder tool parser Mar 12, 2026
@tijyojwad tijyojwad requested review from 2ez4bz and Wanli-Jiang March 12, 2026 23:50
@tijyojwad
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38792 [ run ] triggered by Bot. Commit: a9353bc Link to invocation

Copy link
Collaborator

@QiJune QiJune left a comment

Choose a reason for hiding this comment

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

LGTM

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38792 [ run ] completed with state SUCCESS. Commit: a9353bc
/LLM/main/L0_MergeRequest_PR pipeline #30106 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@tijyojwad
Copy link
Collaborator Author

/bot run --only-multi-gpu-test --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38883 [ run ] triggered by Bot. Commit: a9353bc Link to invocation

@tijyojwad tijyojwad enabled auto-merge (squash) March 13, 2026 18:34
@tensorrt-cicd
Copy link
Collaborator

PR_Github #38883 [ run ] completed with state SUCCESS. Commit: a9353bc
/LLM/main/L0_MergeRequest_PR pipeline #30191 (Partly Tested) completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.

CI Report

Link to invocation

@tijyojwad tijyojwad force-pushed the fix-anyof-qwen3-parser branch from 51cd1ad to a9353bc Compare March 13, 2026 19:51
@2ez4bz
Copy link
Collaborator

2ez4bz commented Mar 13, 2026

/bot help

@github-actions
Copy link

GitHub Bot Help

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

Details

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental) --high-priority]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

--high-priority (OPTIONAL) : Run the pipeline with high priority. This option is restricted to authorized users only and will route the job to a high-priority queue.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

@2ez4bz
Copy link
Collaborator

2ez4bz commented Mar 13, 2026

/bot --reuse-test 30191

@github-actions
Copy link

GitHub Bot Help

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

Details

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental) --high-priority]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

--high-priority (OPTIONAL) : Run the pipeline with high priority. This option is restricted to authorized users only and will route the job to a high-priority queue.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

@2ez4bz
Copy link
Collaborator

2ez4bz commented Mar 13, 2026

/bot run --reuse-test 30191

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38897 [ run ] triggered by Bot. Commit: a9353bc Link to invocation

@tijyojwad
Copy link
Collaborator Author

/bot help

@github-actions
Copy link

GitHub Bot Help

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

Details

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental) --high-priority]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

--high-priority (OPTIONAL) : Run the pipeline with high priority. This option is restricted to authorized users only and will route the job to a high-priority queue.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38897 [ run ] completed with state SUCCESS. Commit: a9353bc
/LLM/main/L0_MergeRequest_PR pipeline #30205 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@yuanjingx87
Copy link
Collaborator

/bot reuse-pipeline --number 12173

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38911 [ reuse-pipeline ] triggered by Bot. Commit: a9353bc Link to invocation

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38911 [ reuse-pipeline ] completed with state SUCCESS. Commit: a9353bc
Can't reuse PR_Github #38897 with status: FAILED

Link to invocation

@yuanjingx87
Copy link
Collaborator

/bot skip --comment "CI passed with same code change."

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38917 [ skip ] triggered by Bot. Commit: a9353bc Link to invocation

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38917 [ skip ] completed with state SUCCESS. Commit: a9353bc
Skipping testing for commit a9353bc

Link to invocation

@tijyojwad tijyojwad merged commit 9a9dc3c into NVIDIA:main Mar 13, 2026
13 of 17 checks passed
@2ez4bz
Copy link
Collaborator

2ez4bz commented Mar 15, 2026

first try

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants