Skip to content
Open
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
13 changes: 13 additions & 0 deletions run_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9044,6 +9044,19 @@ def _copy_reasoning_content_for_api(self, source_msg: dict, api_msg: dict) -> No
# genuine reasoning content is not overwritten (#15812 regression in
# PR #15478).
if isinstance(normalized_reasoning, str) and normalized_reasoning:
# Custom/vLLM providers: vLLM's OpenAI-compat endpoint does NOT
# consume reasoning_content on incoming messages — it expects
# <think> blocks inline in content (MiniMax M2.7, DeepSeek-R1,
# GLM-4.x on vLLM). Reconstruct the think blocks so the
# model's chain-of-thought is preserved across turns. See #20577.
_provider = (getattr(self, "provider", None) or "").strip().lower()
if _provider == "custom":
_content = api_msg.get("content") or ""

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.

provider == "custom" covers every custom OpenAI-compatible endpoint, not only vLLM endpoints that require inline thinking. Please gate this on an explicit endpoint capability/configuration so custom endpoints that accept reasoning_content are not silently changed.

if isinstance(_content, str) and normalized_reasoning not in _content:
api_msg["content"] = (
f"<think>\n{normalized_reasoning}\n</think>\n{_content}"
)
return
api_msg["reasoning_content"] = normalized_reasoning
return

Expand Down
Loading