From 7d2ce8f89d2a2e399b202626335d0f39529b401b Mon Sep 17 00:00:00 2001 From: Ed_ Date: Thu, 25 Jun 2026 12:26:26 -0400 Subject: [PATCH] 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. --- src/ai_client.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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),