Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions vllm/tokenizers/deepseek_v4_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,18 @@
"<tool_result>{content}</tool_result>"
)

REASONING_EFFORT_MAX = (
REASONING_EFFORT_HIGH = (
"Reasoning Effort: Absolute maximum with no shortcuts permitted.\n"
"You MUST be very thorough in your thinking and comprehensively decompose the problem to resolve the root cause, rigorously stress-testing your logic against all potential paths, edge cases, and adversarial scenarios.\n"
"Explicitly write out your entire deliberation process, documenting every intermediate step, considered alternative, and rejected hypothesis to ensure absolutely no assumption is left unchecked.\n\n"
)

REASONING_EFFORT_MAX = (
"Reasoning Effort: Beyond maximum \u2014 exhaustive, relentless, and uncompromising.\n"
"You MUST reason with the utmost depth and rigor, leaving absolutely nothing to chance: exhaustively decompose the problem into its most fundamental components, trace every causal chain to its root, and resolve the underlying cause rather than any surface symptom.\n"
"Do not stop reasoning until you have independently verified the solution from multiple angles and are certain that no assumption remains unchecked and no error remains undiscovered.\n\n"
)

Comment on lines +70 to +81

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Wrap the long prompt literals.

Lines 72, 73, 78, and 79 exceed the 88-character limit. Split the literals with adjacent strings. Preserve all spaces and escape sequences so the rendered prompts do not change.

Proposed fix
-    "You MUST be very thorough in your thinking and comprehensively decompose the problem to resolve the root cause, rigorously stress-testing your logic against all potential paths, edge cases, and adversarial scenarios.\n"
-    "Explicitly write out your entire deliberation process, documenting every intermediate step, considered alternative, and rejected hypothesis to ensure absolutely no assumption is left unchecked.\n\n"
+    "You MUST be very thorough in your thinking and comprehensively decompose the "
+    "problem to resolve the root cause, rigorously stress-testing your logic "
+    "against all potential paths, edge cases, and adversarial scenarios.\n"
+    "Explicitly write out your entire deliberation process, documenting every "
+    "intermediate step, considered alternative, and rejected hypothesis to ensure "
+    "absolutely no assumption is left unchecked.\n\n"
...
-    "You MUST reason with the utmost depth and rigor, leaving absolutely nothing to chance: exhaustively decompose the problem into its most fundamental components, trace every causal chain to its root, and resolve the underlying cause rather than any surface symptom.\n"
-    "Do not stop reasoning until you have independently verified the solution from multiple angles and are certain that no assumption remains unchecked and no error remains undiscovered.\n\n"
+    "You MUST reason with the utmost depth and rigor, leaving absolutely nothing to "
+    "chance: exhaustively decompose the problem into its most fundamental components, "
+    "trace every causal chain to its root, and resolve the underlying cause rather "
+    "than any surface symptom.\n"
+    "Do not stop reasoning until you have independently verified the solution from "
+    "multiple angles and are certain that no assumption remains unchecked and no "
+    "error remains undiscovered.\n\n"

As per coding guidelines, Python code must follow an 88-character line length limit.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
REASONING_EFFORT_HIGH = (
"Reasoning Effort: Absolute maximum with no shortcuts permitted.\n"
"You MUST be very thorough in your thinking and comprehensively decompose the problem to resolve the root cause, rigorously stress-testing your logic against all potential paths, edge cases, and adversarial scenarios.\n"
"Explicitly write out your entire deliberation process, documenting every intermediate step, considered alternative, and rejected hypothesis to ensure absolutely no assumption is left unchecked.\n\n"
)
REASONING_EFFORT_MAX = (
"Reasoning Effort: Beyond maximum \u2014 exhaustive, relentless, and uncompromising.\n"
"You MUST reason with the utmost depth and rigor, leaving absolutely nothing to chance: exhaustively decompose the problem into its most fundamental components, trace every causal chain to its root, and resolve the underlying cause rather than any surface symptom.\n"
"Do not stop reasoning until you have independently verified the solution from multiple angles and are certain that no assumption remains unchecked and no error remains undiscovered.\n\n"
)
REASONING_EFFORT_HIGH = (
"Reasoning Effort: Absolute maximum with no shortcuts permitted.\n"
"You MUST be very thorough in your thinking and comprehensively decompose the "
"problem to resolve the root cause, rigorously stress-testing your logic "
"against all potential paths, edge cases, and adversarial scenarios.\n"
"Explicitly write out your entire deliberation process, documenting every "
"intermediate step, considered alternative, and rejected hypothesis to ensure "
"absolutely no assumption is left unchecked.\n\n"
)
REASONING_EFFORT_MAX = (
"Reasoning Effort: Beyond maximum \u2014 exhaustive, relentless, and uncompromising.\n"
"You MUST reason with the utmost depth and rigor, leaving absolutely nothing to "
"chance: exhaustively decompose the problem into its most fundamental components, "
"trace every causal chain to its root, and resolve the underlying cause rather "
"than any surface symptom.\n"
"Do not stop reasoning until you have independently verified the solution from "
"multiple angles and are certain that no assumption remains unchecked and no "
"error remains undiscovered.\n\n"
)
🤖 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 `@vllm/tokenizers/deepseek_v4_encoding.py` around lines 70 - 81, Wrap the long
string literals in REASONING_EFFORT_HIGH and REASONING_EFFORT_MAX using adjacent
string segments so every line stays within 88 characters. Preserve the rendered
prompt text exactly, including spaces, punctuation, newline escapes, and
paragraph spacing.

Source: Coding guidelines

TOOLS_TEMPLATE = """## Tools

You have access to a set of tools to help answer the user's question. You can invoke tools by writing a "<{dsml_token}tool_calls>" block like the following:
Expand Down Expand Up @@ -263,10 +269,10 @@ def render_message(index: int, messages: List[Dict[str, Any]], thinking_mode: st
if tool_calls:
tool_calls = tool_calls_from_openai_format(tool_calls)

# Reasoning effort prefix (only at index 0 in thinking mode with max effort)
# Reasoning effort prefix (only at index 0 in thinking mode, for high/max effort)
assert reasoning_effort in ['max', None, 'high'], f"Invalid reasoning effort: {reasoning_effort}"
if index == 0 and thinking_mode == "thinking" and reasoning_effort == 'max':
prompt += REASONING_EFFORT_MAX
if index == 0 and thinking_mode == "thinking" and reasoning_effort in ("high", "max"):
prompt += REASONING_EFFORT_HIGH if reasoning_effort == "high" else REASONING_EFFORT_MAX

if role == "system":
prompt += system_msg_template.format(content=content or "")
Expand Down