HKUDS/DeepTutor · error · ValueError

SummaryAgent prompts are not configured.

Error message

SummaryAgent prompts are not configured.

What it means

Raised by _extract_docx when the primary python-docx extraction produced no text, the raw OOXML fallback also produced nothing, and python-docx is not installed in the environment. With no library and no fallback text, extraction is impossible and CorruptDocumentError is raised.

Source

Thrown at deeptutor/agents/math_animator/agents/summary_agent.py:43

            api_key=api_key,
            base_url=base_url,
            api_version=api_version,
            language=language,
        )

    async def process(
        self,
        *,
        user_input: str,
        output_mode: str,
        analysis: ConceptAnalysis,
        design: SceneDesign,
        render_result: RenderResult,
    ) -> SummaryPayload:
        system_prompt = self.get_prompt("system")
        user_template = self.get_prompt("user_template")
        if not system_prompt or not user_template:
            raise ValueError("SummaryAgent prompts are not configured.")

        user_prompt = user_template.format(
            user_input=user_input.strip(),
            output_mode=output_mode,
            analysis_json=json.dumps(analysis.model_dump(), ensure_ascii=False, indent=2),
            design_json=json.dumps(design.model_dump(), ensure_ascii=False, indent=2),
            render_json=json.dumps(render_result.model_dump(), ensure_ascii=False, indent=2),
        )
        _chunks: list[str] = []
        async for _c in self.stream_llm(
            user_prompt=user_prompt,
            system_prompt=system_prompt,
            response_format={"type": "json_object"},
            stage="summary",
            trace_meta=build_trace_metadata(
                call_id=new_call_id("math-summary"),
                phase="summary",
                label="Summarize result",

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Install python-docx (pip install python-docx) so the primary path can extract formatted content
  2. If the docx is image-only, run OCR on embedded images instead
  3. Verify the file is genuinely a Word file (check magic bytes / _check_magic) before extraction

Example fix

// before
# no python-docx installed, empty-content docx
text = extract_text_from_bytes(data, filename="empty.docx")  # raises

// after
pip install python-docx
text = extract_text_from_bytes(data, filename="empty.docx")
Defensive patterns

Strategy: validation

Validate before calling

def docx_lib_available() -> bool:
    try:
        import docx  # noqa
        return True
    except ImportError:
        return False

if not docx_lib_available() and ext == ".docx":
    warn("python-docx missing; OOXML fallback only")

Try / catch

except CorruptDocumentError as e:
    if "python-docx not installed" in str(e):
        subprocess pip_install("python-docx") or mark_file_unreadable(fn)

Prevention

When it happens

Trigger: Calling extraction on a .docx in an environment without python-docx where the file contains no <w:t> text (empty document, images-only, or a .docx that is actually not a Word file).

Common situations: Minimal installs of deeptutor-cli; users renaming other files to .docx; documents consisting solely of embedded images.

Related errors


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/ed1ad2c963dcecbf. Report an issue: GitHub.