feat(provider): preserve reasoning_details across turns and configure MiniMax reasoning_split via registry#1438
Conversation
…niMax reasoning_split via registry overrides
chengyongru
left a comment
There was a problem hiding this comment.
Review Summary
This PR addresses a real need (preserving reasoning metadata across turns), but has some issues that should be addressed before merging.
Issues
1. reasoning_split Parameter Passing Method (Critical)
According to litellm MiniMax documentation, reasoning_split should be passed via extra_body, not directly in kwargs:
# From litellm docs:
stream = client.chat.completions.create(
model="minimax/MiniMax-M2.1",
messages=[...],
extra_body={"reasoning_split": True}, # <-- via extra_body
stream=True,
)However, this PR adds it directly to kwargs via model_overrides:
model_overrides=(
("minimax-m2.5", {"reasoning_split": True}),
...
)And _apply_model_overrides does:
kwargs.update(overrides) # adds reasoning_split directly to kwargsSince litellm.drop_params = True is set in LiteLLMProvider.__init__, the reasoning_split parameter will likely be dropped silently because it's not a recognized litellm parameter.
Recommendation: Either:
- Add support for
extra_bodyin_apply_model_overrides - Or verify that litellm actually accepts
reasoning_splitas a direct kwarg (I couldn't find evidence of this)
2. Code Duplication in subagent.py
The subagent loop directly constructs the assistant message dict instead of using ContextBuilder.add_assistant_message():
# subagent.py (new code)
{
"role": "assistant",
"content": response.content or "",
"tool_calls": tool_call_dicts,
**({"reasoning_content": response.reasoning_content} if response.reasoning_content is not None else {}),
**({"thinking_blocks": response.thinking_blocks} if response.thinking_blocks else {}),
**({"reasoning_details": response.reasoning_details} if response.reasoning_details is not None else {}),
}vs:
# loop.py (existing code)
messages = self.context.add_assistant_message(
messages, response.content, tool_call_dicts,
reasoning_content=response.reasoning_content,
thinking_blocks=response.thinking_blocks,
reasoning_details=response.reasoning_details,
)This creates inconsistency and potential bugs if add_assistant_message is updated in the future.
Recommendation: Refactor subagent.py to use add_assistant_message for consistency, or extract the logic into a shared helper function.
3. Missing Tests
No test code is included to verify:
reasoning_detailsis correctly preserved across turnsmodel_overridescorrectly appliesreasoning_splitto MiniMax models- The feature works end-to-end with actual MiniMax API
Minor Suggestions
- Consider adding a comment explaining what
reasoning_detailscontains (MiniMax interleaved CoT metadata per the field comment) - The
model_overridespattern matching (pattern in model_lower) is case-insensitive but substring-based - this could accidentally match unintended models
Verification Needed
Before merging, please verify:
- Does
reasoning_split=Trueactually reach the MiniMax API when passed directly in kwargs? - Does the response actually contain
reasoning_detailsin the expected format?
You can test by adding a debug log in _parse_response:
if reasoning_details:
logger.debug(f"Got reasoning_details: {reasoning_details}")…assistant message construction
|
Thanks for the review — addressed all requested points. What I changed
Validation
|
…return" This reverts commit 191e863.
Summary
This PR improves reasoning metadata continuity across multi-turn conversations and configures MiniMax interleaved reasoning in a provider-configurable way.
Changes
reasoning_detailsto provider response model.reasoning_detailsin assistant message history for:reasoning_detailsthrough message sanitization in LiteLLM provider.reasoning_detailsfrom LiteLLM response (messageand provider-specific fields fallback).reasoning_splitenablement to provider registrymodel_overridesfor:minimax-m2.5minimax-m2.1minimax-m2Why
Validation