Skip to content

[None][fix] Forward reasoning_effort to the chat template - #17553

Open
joerowell wants to merge 2 commits into
NVIDIA:mainfrom
joerowell:joerowell/reasoning-effort-chat-template
Open

[None][fix] Forward reasoning_effort to the chat template#17553
joerowell wants to merge 2 commits into
NVIDIA:mainfrom
joerowell:joerowell/reasoning-effort-chat-template

Conversation

@joerowell

@joerowell joerowell commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Dev Engineer Review

  • reasoning_effort forwards to chat templates.
  • Explicit request values override chat_template_kwargs.
  • Unset values are omitted.
  • Supported values include none, minimal, low, medium, high, xhigh, and max.
  • Harmony maps low, medium, and high directly. It maps xhigh and max to high reasoning.
  • Unsupported values return None instead of raising KeyError.
  • The changes preserve request immutability and existing template kwargs.
  • No configuration or test-list files changed.

QA Engineer Review

Added CPU-only tests:

  • test_a_sent_level_reaches_the_template_unchanged
  • test_an_unsent_effort_is_not_forwarded
  • test_a_sent_level_overrides_chat_template_kwargs
  • test_chat_template_kwargs_still_work_on_their_own
  • test_other_template_kwargs_are_preserved
  • test_the_request_kwargs_are_not_mutated
  • test_harmony_tolerates_every_level_the_field_accepts
  • test_harmony_still_maps_the_levels_it_owns

No corresponding tests/integration/test_lists/, test-db/, or qa/ coverage entry was found. Verdict: needs follow-up.

@joerowell
joerowell requested a review from a team as a code owner August 12, 2026 09:40
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 664fe524-3e3d-4b5e-8eea-936e976d1337

📥 Commits

Reviewing files that changed from the base of the PR and between 6beb4b2 and b5c7ae6.

📒 Files selected for processing (4)
  • tensorrt_llm/serve/harmony_adapter.py
  • tensorrt_llm/serve/openai_protocol.py
  • tensorrt_llm/serve/openai_server.py
  • tests/unittest/llmapi/apps/test_reasoning_effort_resolution.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • tensorrt_llm/serve/openai_protocol.py
  • tensorrt_llm/serve/openai_server.py
  • tensorrt_llm/serve/harmony_adapter.py
  • tests/unittest/llmapi/apps/test_reasoning_effort_resolution.py

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


Walkthrough

The change expands accepted reasoning-effort values, forwards explicit values to chat templates, preserves existing template kwargs, and prevents unsupported Harmony values from raising KeyError. CPU-only tests cover forwarding and Harmony behavior.

Changes

Reasoning effort support

Layer / File(s) Summary
Reasoning effort contracts and Harmony handling
tensorrt_llm/serve/openai_protocol.py, tensorrt_llm/serve/harmony_adapter.py
The request accepts none, minimal, xhigh, and max. Harmony maps xhigh and max to high reasoning and returns None for unsupported values.
Template kwargs forwarding
tensorrt_llm/serve/openai_server.py
Chat completion rendering copies chat_template_kwargs, applies explicit reasoning_effort, and preserves other kwargs.
Forwarding and Harmony validation
tests/unittest/llmapi/apps/test_reasoning_effort_resolution.py
CPU-only tests cover forwarding, precedence, omission, immutability, and Harmony mappings.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to b5c7a

This change is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ChatCompletionRequest
  participant OpenAIServer
  participant ChatTemplate
  Client->>ChatCompletionRequest: send reasoning_effort
  ChatCompletionRequest->>OpenAIServer: request and chat_template_kwargs
  OpenAIServer->>OpenAIServer: merge explicit reasoning_effort
  OpenAIServer->>ChatTemplate: render with merged kwargs
Loading

Suggested reviewers: mikeiovine, allisonlim-nv

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was provided. The required Description, Test Coverage, and PR Checklist information is missing. Add a description that explains the issue and solution, lists the relevant tests and coverage, and completes the PR Checklist. Address the API-change label requirement because the pull request expands the reasoning_effort API.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required [None][fix] format and clearly summarizes the main change: forwarding reasoning_effort to the chat template.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
tensorrt_llm/serve/openai_server.py (1)

208-232: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a precise request type annotation.

Annotate request as ChatCompletionRequest. This helper reads Pydantic request fields and is part of the chat-template contract.

Proposed fix
-def _chat_template_kwargs_with_effort(request) -> dict:
+def _chat_template_kwargs_with_effort(
+        request: ChatCompletionRequest) -> dict[str, Any]:

As per coding guidelines, “Annotate every function” and “use precise types instead of dict/object/Any where applicable.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tensorrt_llm/serve/openai_server.py` around lines 208 - 232, Update
_chat_template_kwargs_with_effort to annotate request as ChatCompletionRequest,
reusing the existing import or adding the appropriate import if needed. Keep the
current return annotation and behavior unchanged.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tensorrt_llm/serve/harmony_adapter.py`:
- Around line 1922-1929: Add an "xhigh" entry to the str_to_effort mapping used
by reasoning-effort resolution, mapping it to ReasoningEffort.HIGH alongside
"max", so both requests resolve identically while preserving existing fallback
behavior.

In `@tests/unittest/llmapi/apps/test_reasoning_effort_resolution.py`:
- Around line 32-104: Run the repository-configured YAPF and ruff formatters on
the test file containing make_request, _chat_template_kwargs_with_effort, and
maybe_transform_reasoning_effort, then commit all formatter-generated changes
without altering the test behavior.

---

Nitpick comments:
In `@tensorrt_llm/serve/openai_server.py`:
- Around line 208-232: Update _chat_template_kwargs_with_effort to annotate
request as ChatCompletionRequest, reusing the existing import or adding the
appropriate import if needed. Keep the current return annotation and behavior
unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 184d25ea-16fd-4cd1-b28c-a42e51c2cffc

📥 Commits

Reviewing files that changed from the base of the PR and between 07b3e82 and 601faaf.

📒 Files selected for processing (4)
  • tensorrt_llm/serve/harmony_adapter.py
  • tensorrt_llm/serve/openai_protocol.py
  • tensorrt_llm/serve/openai_server.py
  • tests/unittest/llmapi/apps/test_reasoning_effort_resolution.py

Comment thread tensorrt_llm/serve/harmony_adapter.py Outdated
Comment thread tests/unittest/llmapi/apps/test_reasoning_effort_resolution.py
@joerowell
joerowell force-pushed the joerowell/reasoning-effort-chat-template branch from 601faaf to 0d55bbc Compare August 12, 2026 16:30
@DomBrown

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67484 [ run ] triggered by Bot. Commit: 0856a36 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67484 [ run ] completed with state FAILURE. Commit: 0856a36
/LLM/main/L0_MergeRequest_PR pipeline #54982 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

CI Agent Failure Analysis

Link to invocation

@DomBrown

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67496 [ run ] triggered by Bot. Commit: 0856a36 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67496 [ run ] completed with state SUCCESS. Commit: 0856a36
/LLM/main/L0_MergeRequest_PR pipeline #54991 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

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67542 [ run ] triggered by Bot. Commit: 0856a36 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67542 [ run ] completed with state SUCCESS. Commit: 0856a36
/LLM/main/L0_MergeRequest_PR pipeline #55037 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

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67562 [ run ] triggered by Bot. Commit: 0856a36 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67562 [ run ] completed with state FAILURE. Commit: 0856a36
/LLM/main/L0_MergeRequest_PR pipeline #55054 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

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67579 [ run ] triggered by Bot. Commit: 0856a36 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #67579 [ run ] completed with state SUCCESS. Commit: 0856a36
/LLM/main/L0_MergeRequest_PR pipeline #55067 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

CI Agent Failure Analysis

Link to invocation

@DomBrown
DomBrown force-pushed the joerowell/reasoning-effort-chat-template branch from 0856a36 to 59f2c50 Compare August 20, 2026 08:39
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #69196 [ run ] triggered by Bot. Commit: b5c7ae6 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #69196 [ run ] completed with state SUCCESS. Commit: b5c7ae6
/LLM/main/L0_MergeRequest_PR pipeline #56560 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

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #69225 [ run ] triggered by Bot. Commit: b5c7ae6 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #69225 [ run ] completed with state SUCCESS. Commit: b5c7ae6
/LLM/main/L0_MergeRequest_PR pipeline #56588 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

CI Agent Failure Analysis

Link to invocation

@DomBrown
DomBrown force-pushed the joerowell/reasoning-effort-chat-template branch from b5c7ae6 to 7fed60a Compare August 27, 2026 13:17
@DomBrown

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #69728 [ run ] triggered by Bot. Commit: 7fed60a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #69728 [ run ] completed with state SUCCESS. Commit: 7fed60a
/LLM/main/L0_MergeRequest_PR pipeline #57026 completed with status: 'UNSTABLE'

CI Report

⚠️ Multi-GPU Label Required:
Multi-GPU tests require the ci: full pre-merge approved label on this PR. Ask a member of NVIDIA/trt-llm-ci-approvers to add the label, then re-trigger CI with the same bot command (no rebase needed).

⚠️ 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

"low": ReasoningEffort.LOW,
"medium": ReasoningEffort.MEDIUM,
"high": ReasoningEffort.HIGH
"high": ReasoningEffort.HIGH,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does "minimal" also need to be in this dictionary?

@mikeiovine

Copy link
Copy Markdown
Collaborator

/bot run

1 similar comment
@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71285 [ run ] triggered by Bot. Commit: dd002e5 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71285 [ run ] completed with state SUCCESS. Commit: dd002e5
/LLM/main/L0_MergeRequest_PR pipeline #58416 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

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71348 [ run ] triggered by Bot. Commit: ae8315a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71348 [ run ] completed with state FAILURE. Commit: ae8315a
/LLM/main/L0_MergeRequest_PR pipeline #58475 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

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71444 [ run ] triggered by Bot. Commit: 39a9f9e Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71444 [ run ] completed with state FAILURE. Commit: 39a9f9e
/LLM/main/L0_MergeRequest_PR pipeline #58551 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

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71575 [ run ] triggered by Bot. Commit: 1255c43 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71575 [ run ] completed with state SUCCESS. Commit: 1255c43
/LLM/main/L0_MergeRequest_PR pipeline #58661 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

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71616 [ run ] triggered by Bot. Commit: 2e1735f Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71616 [ run ] completed with state FAILURE. Commit: 2e1735f
/LLM/main/L0_MergeRequest_PR pipeline #58701 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

CI Agent Failure Analysis

Link to invocation

Signed-off-by: Joe Rowell <joerowell4@gmail.com>
Signed-off-by: Joe Rowell <joerowell4@gmail.com>
@allisonlim-nv
allisonlim-nv force-pushed the joerowell/reasoning-effort-chat-template branch from 2e1735f to f9d2901 Compare September 7, 2026 17:31
@allisonlim-nv

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71992 [ run ] triggered by Bot. Commit: f9d2901 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #71992 [ run ] completed with state FAILURE. Commit: f9d2901
/LLM/main/L0_MergeRequest_PR pipeline #59053 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

CI Agent Failure Analysis

Link to invocation

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants