refactor(ai_client): migrate _minimax_history call sites to provider_state.get_history('minimax')
Phase 4 of code_path_audit_phase_3_provider_state_20260624. 9 sites in _send_minimax (lines 2654-2690) migrated from _minimax_history/_minimax_history_lock to local capture history = provider_state.get_history('minimax'). The migration follows the canonical pattern: 1 outer capture, 2 append/not checks migrated, 1 nested closure with history.lock + history iteration, 2 kwargs at run_with_tool_loop (history_lock=history.lock, history=history).
Verified: 36 tests pass across test_provider_state_migration (14) + test_minimax_provider (10) + test_ai_client_result (5) + test_ai_loop_regressions_20260614 (7).
Conventions: 1-space indentation, CRLF preserved, no comments added.
This commit is contained in:
+8
-7
@@ -2654,15 +2654,16 @@ def _send_minimax(md_content: str, user_message: str, base_dir: str,
|
|||||||
from src.openai_schemas import ChatMessage
|
from src.openai_schemas import ChatMessage
|
||||||
try:
|
try:
|
||||||
_ensure_minimax_client()
|
_ensure_minimax_client()
|
||||||
|
history = provider_state.get_history("minimax")
|
||||||
tools: list[Metadata] | None = _get_deepseek_tools() or None
|
tools: list[Metadata] | None = _get_deepseek_tools() or None
|
||||||
_repair_minimax_history(_minimax_history)
|
_repair_minimax_history(history)
|
||||||
if discussion_history and not _minimax_history:
|
if discussion_history and not history:
|
||||||
_minimax_history.append({"role": "user", "content": f"[DISCUSSION HISTORY]\n\n{discussion_history}\n\n---\n\n{user_message}"})
|
history.append({"role": "user", "content": f"[DISCUSSION HISTORY]\n\n{discussion_history}\n\n---\n\n{user_message}"})
|
||||||
else:
|
else:
|
||||||
_minimax_history.append({"role": "user", "content": user_message})
|
history.append({"role": "user", "content": user_message})
|
||||||
def _build_minimax_request(_round_idx: int) -> OpenAICompatibleRequest:
|
def _build_minimax_request(_round_idx: int) -> OpenAICompatibleRequest:
|
||||||
with _minimax_history_lock:
|
with history.lock:
|
||||||
history_msgs: list[ChatMessage] = [ChatMessage(role=m["role"], content=m["content"]) for m in _minimax_history]
|
history_msgs: list[ChatMessage] = [ChatMessage(role=m["role"], content=m["content"]) for m in history]
|
||||||
messages: list[ChatMessage] = [ChatMessage(role="system", content=f"{_get_combined_system_prompt()}\n\n<context>\n{md_content}\n</context>")]
|
messages: list[ChatMessage] = [ChatMessage(role="system", content=f"{_get_combined_system_prompt()}\n\n<context>\n{md_content}\n</context>")]
|
||||||
messages.extend(history_msgs)
|
messages.extend(history_msgs)
|
||||||
return OpenAICompatibleRequest(
|
return OpenAICompatibleRequest(
|
||||||
@@ -2681,7 +2682,7 @@ def _send_minimax(md_content: str, user_message: str, base_dir: str,
|
|||||||
_minimax_client, _build_minimax_request, capabilities=caps,
|
_minimax_client, _build_minimax_request, capabilities=caps,
|
||||||
pre_tool_callback=pre_tool_callback, qa_callback=qa_callback, stream_callback=stream_callback,
|
pre_tool_callback=pre_tool_callback, qa_callback=qa_callback, stream_callback=stream_callback,
|
||||||
patch_callback=patch_callback, base_dir=base_dir, vendor_name="minimax",
|
patch_callback=patch_callback, base_dir=base_dir, vendor_name="minimax",
|
||||||
history_lock=_minimax_history_lock, history=_minimax_history,
|
history_lock=history.lock, history=history,
|
||||||
trim_func=lambda h: _trim_minimax_history(_build_minimax_request(0).messages, h),
|
trim_func=lambda h: _trim_minimax_history(_build_minimax_request(0).messages, h),
|
||||||
reasoning_extractor=_extract_minimax_reasoning if caps.reasoning else None,
|
reasoning_extractor=_extract_minimax_reasoning if caps.reasoning else None,
|
||||||
wrap_reasoning_in_text=bool(caps.reasoning),
|
wrap_reasoning_in_text=bool(caps.reasoning),
|
||||||
|
|||||||
Reference in New Issue
Block a user