Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

docs(llm): name two contracts the LightRAG convergence relies on

Bingxi Zhao (Frank)ac18b7505609
diff --git a/deeptutor/services/llm/error_mapping.py b/deeptutor/services/llm/error_mapping.py
index 890ffe0c9..6bdc0b6c7 100644
--- a/deeptutor/services/llm/error_mapping.py
+++ b/deeptutor/services/llm/error_mapping.py
@@ -129,7 +129,16 @@ _GLOBAL_RULES: list[MappingRule] = [
def map_error(exc: Exception, provider: str | None = None) -> LLMError:
- """Map provider-specific errors to unified internal exceptions."""
+ """Map provider-specific errors to unified internal exceptions.
+
+ An exception that is already an ``LLMError`` is returned *itself*, not a
+ replacement: re-running the rules would re-classify a precise error into a
+ vaguer one (an ``LLMTimeoutError`` fell out as a bare ``LLMAPIError``), and
+ callers such as the LightRAG adapter re-raise the terminal error and
+ compare identity. Filling in ``provider`` when the raiser did not know it is
+ therefore an in-place write on the caller's exception — deliberate, and the
+ only field this function mutates.
+ """
if isinstance(exc, LLMError):
if exc.provider is None:
exc.provider = provider
diff --git a/deeptutor/services/rag/pipelines/lightrag/config.py b/deeptutor/services/rag/pipelines/lightrag/config.py
index 2d8aed5fd..77af2cb27 100644
--- a/deeptutor/services/rag/pipelines/lightrag/config.py
+++ b/deeptutor/services/rag/pipelines/lightrag/config.py
@@ -268,6 +268,12 @@ def build_vision_model_func(*, io_bridge: OwnerLoopBridge | None = None):
image_data=image_data,
messages=messages,
max_retries=0,
+ # Never strip the image and answer anyway. The provider's
+ # stage-2 fallback exists to salvage a text answer from a model
+ # that turns out not to take images, but here the *whole point*
+ # of the call is the image: a description produced without it is
+ # invented, and it would be indexed as fact. Fail the image
+ # instead, and let the caller log and skip it.
allow_image_fallback=False,
)