diff --git a/src/app_controller.py b/src/app_controller.py index 070eed66..1062b81e 100644 --- a/src/app_controller.py +++ b/src/app_controller.py @@ -3673,28 +3673,26 @@ class AppController: ai_client.set_model_params(self.temperature, self.max_tokens, self.history_trunc_limit, self.top_p) ai_client.set_agent_tools(self.ui_agent_tools) # Force update adapter path right before send to bypass potential duplication issues self._update_gcli_adapter(self.ui_gemini_cli_path) - try: - resp = ai_client.send( - event.stable_md, - user_msg, - event.base_dir, - event.file_items, - event.disc_text, - stream=True, - stream_callback=lambda text: self._on_ai_stream(text), - pre_tool_callback=self._confirm_and_run, - qa_callback=ai_client.run_tier4_analysis, - patch_callback=ai_client.run_tier4_patch_callback, - rag_engine=None # Already handled above - ) - self.event_queue.put("response", {"text": resp, "status": "done", "role": "AI"}) + result = ai_client.send_result( + event.stable_md, + user_msg, + event.base_dir, + event.file_items, + event.disc_text, + stream=True, + stream_callback=lambda text: self._on_ai_stream(text), + pre_tool_callback=self._confirm_and_run, + qa_callback=ai_client.run_tier4_analysis, + patch_callback=ai_client.run_tier4_patch_callback, + rag_engine=None, # Already handled above + ) + if result.ok: + self.event_queue.put("response", {"text": result.data, "status": "done", "role": "AI"}) self._ai_status = "done" - except ai_client.ProviderError as e: - self.event_queue.put("response", {"text": e.ui_message(), "status": "error", "role": "Vendor API"}) - self._ai_status = f"error: {e.ui_message()}" - except Exception as e: - self.event_queue.put("response", {"text": f"ERROR: {e}", "status": "error", "role": "System"}) - self._ai_status = f"error: {e}" + else: + err = result.errors[0] + self.event_queue.put("response", {"text": err.ui_message(), "status": "error", "role": "Vendor API"}) + self._ai_status = f"error: {err.ui_message()}" def _on_tool_log(self, script: str, result: str) -> None: """