[None][fix] Forward reasoning_effort to the chat template - #17553
[None][fix] Forward reasoning_effort to the chat template#17553joerowell wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe change expands accepted reasoning-effort values, forwards explicit values to chat templates, preserves existing template kwargs, and prevents unsupported Harmony values from raising ChangesReasoning effort support
Estimated code review effort: 3 (Moderate) | ~20 minutes Mergeability Score: ⚪ Minimal · up to This change forwards reasoning_effort through chat-template handling, with no identified concrete correctness, security, availability, deployment, or permission risk at the current head; it is merge-ready after normal checks. 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
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tensorrt_llm/serve/openai_server.py (1)
208-232: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a precise request type annotation.
Annotate
requestasChatCompletionRequest. 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/Anywhere 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
📒 Files selected for processing (4)
tensorrt_llm/serve/harmony_adapter.pytensorrt_llm/serve/openai_protocol.pytensorrt_llm/serve/openai_server.pytests/unittest/llmapi/apps/test_reasoning_effort_resolution.py
Signed-off-by: Joe Rowell <joerowell4@gmail.com>
601faaf to
0d55bbc
Compare
Signed-off-by: Joe Rowell <joerowell4@gmail.com>
Dev Engineer Review
reasoning_effortforwards to chat templates.chat_template_kwargs.reasoning_effortacceptsnone,minimal,xhigh, andmax.maxandxhighto high reasoning.Noneinstead of raisingKeyError.QA Engineer Review
Added CPU-only tests:
test_a_sent_level_reaches_the_template_unchangedtest_an_unsent_effort_is_not_forwardedtest_a_sent_level_overrides_chat_template_kwargstest_chat_template_kwargs_still_work_on_their_owntest_other_template_kwargs_are_preservedtest_the_request_kwargs_are_not_mutatedtest_harmony_tolerates_every_level_the_field_acceptstest_harmony_still_maps_the_levels_it_ownsNo corresponding
tests/integration/test_lists/,test-db/, orqa/coverage entry was found. Verdict: needs follow-up.