diff --git a/deeptutor/capabilities/guided_learning.py b/deeptutor/capabilities/guided_learning.py index 41e0b9333..9c114311f 100644 --- a/deeptutor/capabilities/guided_learning.py +++ b/deeptutor/capabilities/guided_learning.py @@ -264,7 +264,7 @@ class GuidedLearningCapability(BaseCapability): except Exception as e: import logging logging.getLogger(__name__).warning(f"RAG retrieval failed: {e}") - return ("", f"RAG 检索失败: {e}") + return ("", "RAG 检索失败") # ── Real LLM call ─────────────────────────────────────────────────── @@ -372,9 +372,9 @@ class GuidedLearningCapability(BaseCapability): await stream.content(w, metadata={"type": "rag_error"}) except Exception as e: import logging - logging.getLogger(__name__).error(f"Stage {stage} failed: {e}") + logging.getLogger(__name__).error(f"Stage {stage} failed: {e}", exc_info=True) async with stream.stage("error", source=self.manifest.name): - await stream.content(f"阶段执行失败: {e}。进度已保存,下次将继续此阶段。") + await stream.content("阶段执行失败,进度已保存,下次将继续此阶段。") finally: _turn_call_llm.reset(token) self._service.save(progress) @@ -829,14 +829,16 @@ class GuidedLearningCapability(BaseCapability): timeout=self._ERROR_DIAGNOSIS_TIMEOUT_SECONDS, ) except (Exception, asyncio.TimeoutError) as exc: + import logging + logging.getLogger(__name__).warning("error_diagnosis failed: %s", exc, exc_info=True) progress.stage_failure_counts["error_diagnosis"] = progress.stage_failure_counts.get("error_diagnosis", 0) + 1 progress.stage_failure_notes["error_diagnosis"] = str(exc) for rec in active_errors: - rec.ai_confirmation = f"error_diagnosis_unavailable: {exc}" + rec.ai_confirmation = "error_diagnosis_unavailable" await stream.content( "错因诊断暂时不可用,已保留现有错误分类并继续后续模块测试。", source=self.manifest.name, - metadata={"type": "error_diagnosis_unavailable", "error": str(exc)}, + metadata={"type": "error_diagnosis_unavailable"}, ) self._service.advance_stage(progress, LearningStage.MODULE_TEST) return diff --git a/deeptutor/learning/tests/test_error_diagnosis.py b/deeptutor/learning/tests/test_error_diagnosis.py index 0bb805df3..c2f45bceb 100644 --- a/deeptutor/learning/tests/test_error_diagnosis.py +++ b/deeptutor/learning/tests/test_error_diagnosis.py @@ -82,7 +82,7 @@ async def test_error_diagnosis_llm_failure_advances_to_module_test(): assert progress.current_stage == LearningStage.MODULE_TEST assert progress.error_records[0].error_type == ErrorType.APPLICATION_ERROR - assert progress.error_records[0].ai_confirmation.startswith("error_diagnosis_unavailable:") + assert progress.error_records[0].ai_confirmation == "error_diagnosis_unavailable" assert any("错因诊断暂时不可用" in text for kind, text in stream.events if kind == "content") @@ -102,7 +102,7 @@ async def test_error_diagnosis_llm_timeout_advances_to_module_test(): await cap._run_error_diagnosis(progress, None, stream) assert progress.current_stage == LearningStage.MODULE_TEST - assert progress.error_records[0].ai_confirmation.startswith("error_diagnosis_unavailable:") + assert progress.error_records[0].ai_confirmation == "error_diagnosis_unavailable" @pytest.mark.asyncio