Remove deprecated reasoning_content message field (#33402)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2026-01-30 11:48:15 +00:00
committed by GitHub
parent 174f16700b
commit c5113f60f2
8 changed files with 26 additions and 55 deletions
+9 -12
View File
@@ -45,7 +45,7 @@ dsml_token: str = "|DSML|"
system_msg_template: str = "{content}"
user_msg_template: str = "<|User|>{content}<|Assistant|>"
assistant_msg_template: str = "{reasoning}{content}{tool_calls}<|end▁of▁sentence|>"
thinking_template = "{reasoning_content}"
thinking_template = "{reasoning}"
response_format_template: str = "## Response Format:\n\nYou MUST strictly adhere to the following schema to reply:\n{schema}"
tool_call_template: str = (
@@ -170,7 +170,7 @@ def render_message(
tools = msg.get("tools")
response_format = msg.get("response_format")
tool_calls = msg.get("tool_calls")
reasoning_content = msg.get("reasoning") or msg.get("reasoning_content")
reasoning = msg.get("reasoning")
is_prefix = msg.get("prefix", False)
if tools:
@@ -269,13 +269,12 @@ def render_message(
summary_content = content or ""
if thinking_mode == "thinking" and index > last_user_idx:
if not (reasoning_content or tool_calls):
if not (reasoning or tool_calls):
raise ValueError(
f"ThinkingMode: {thinking_mode}, invalid message without reasoning_content/tool_calls `{msg}` after last user message"
f"ThinkingMode: {thinking_mode}, invalid message without reasoning/tool_calls `{msg}` after last user message"
)
thinking_part = (
thinking_template.format(reasoning_content=reasoning_content or "")
+ thinking_end_token
thinking_template.format(reasoning=reasoning or "") + thinking_end_token
)
if not tool_calls and is_prefix:
@@ -307,7 +306,6 @@ def drop_thinking_messages(
elif role == "assistant":
msg_wo_thinking = copy.copy(msg)
msg_wo_thinking.pop("reasoning_content", None)
msg_wo_thinking.pop("reasoning", None)
messages_wo_thinking.append(msg_wo_thinking)
@@ -421,7 +419,7 @@ def parse_tool_calls(index: int, text: str):
# formatted string and will not attempt to correct malformed output
# that may be generated by the model.
def parse_message_from_completion_text(text: str, thinking_mode: str):
summary_content, reasoning_content, tool_calls = "", "", []
summary_content, reasoning, tool_calls = "", "", []
index, stop_token = 0, None
tool_calls_start_token = f"\n\n<{dsml_token}function_calls"
@@ -431,7 +429,7 @@ def parse_message_from_completion_text(text: str, thinking_mode: str):
index, content_delta, stop_token = _read_until_stop(
index, text, [thinking_end_token, tool_calls_start_token]
)
reasoning_content = content_delta
reasoning = content_delta
if stop_token != thinking_end_token:
raise RuntimeError("Invalid thinking format")
@@ -462,13 +460,12 @@ def parse_message_from_completion_text(text: str, thinking_mode: str):
thinking_end_token,
dsml_token,
]:
if sp_token in summary_content or sp_token in reasoning_content:
if sp_token in summary_content or sp_token in reasoning:
raise RuntimeError("Unexpected special token in content")
return {
"role": "assistant",
"content": summary_content,
"reasoning_content": reasoning_content,
"reasoning": reasoning_content,
"reasoning": reasoning,
"tool_calls": tool_calls_to_openai_format(tool_calls),
}