diff --git a/src/ai_client.py b/src/ai_client.py index 0cae954c..f1ce2b29 100644 --- a/src/ai_client.py +++ b/src/ai_client.py @@ -2654,15 +2654,16 @@ def _send_minimax(md_content: str, user_message: str, base_dir: str, from src.openai_schemas import ChatMessage try: _ensure_minimax_client() + history = provider_state.get_history("minimax") tools: list[Metadata] | None = _get_deepseek_tools() or None - _repair_minimax_history(_minimax_history) - if discussion_history and not _minimax_history: - _minimax_history.append({"role": "user", "content": f"[DISCUSSION HISTORY]\n\n{discussion_history}\n\n---\n\n{user_message}"}) + _repair_minimax_history(history) + if discussion_history and not history: + history.append({"role": "user", "content": f"[DISCUSSION HISTORY]\n\n{discussion_history}\n\n---\n\n{user_message}"}) else: - _minimax_history.append({"role": "user", "content": user_message}) + history.append({"role": "user", "content": user_message}) def _build_minimax_request(_round_idx: int) -> OpenAICompatibleRequest: - with _minimax_history_lock: - history_msgs: list[ChatMessage] = [ChatMessage(role=m["role"], content=m["content"]) for m in _minimax_history] + with history.lock: + 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\n{md_content}\n")] messages.extend(history_msgs) 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, 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", - 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), reasoning_extractor=_extract_minimax_reasoning if caps.reasoning else None, wrap_reasoning_in_text=bool(caps.reasoning),