{"record":{"id":"8ee6766803e2bc8b","repo":"HKUDS/DeepTutor","slug":"codegeneratoragent-generation-prompts-are-not-conf","errorCode":null,"errorMessage":"CodeGeneratorAgent generation prompts are not configured.","messagePattern":"CodeGeneratorAgent generation prompts are not configured\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"deeptutor/agents/math_animator/agents/code_generator_agent.py","lineNumber":61,"sourceCode":"            output_mode=output_mode,\n            analysis=analysis,\n            design=design,\n            duration_target_seconds=duration_target_seconds,\n        )\n\n    async def generate(\n        self,\n        *,\n        user_input: str,\n        output_mode: str,\n        analysis: ConceptAnalysis,\n        design: SceneDesign,\n        duration_target_seconds: float | None = None,\n    ) -> GeneratedCode:\n        system_prompt = self.get_prompt(\"generate_system\")\n        user_template = self.get_prompt(\"generate_user_template\")\n        if not system_prompt or not user_template:\n            raise ValueError(\"CodeGeneratorAgent generation prompts are not configured.\")\n\n        user_prompt = user_template.format(\n            user_input=user_input.strip(),\n            output_mode=output_mode,\n            duration_requirement=(\n                f\"用户明确目标时长约 {duration_target_seconds:.1f} 秒，生成代码必须围绕该时长做节奏预算。\"\n                if duration_target_seconds is not None\n                else \"用户未给出明确秒数时长，可按标准教学节奏生成。\"\n            ),\n            analysis_json=json.dumps(analysis.model_dump(), ensure_ascii=False, indent=2),\n            design_json=json.dumps(design.model_dump(), ensure_ascii=False, indent=2),\n        )\n        _chunks: list[str] = []\n        async for _c in self.stream_llm(\n            user_prompt=user_prompt,\n            system_prompt=system_prompt,\n            response_format={\"type\": \"json_object\"},\n            stage=\"code_generation\",","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/agents/math_animator/agents/code_generator_agent.py#L43-L79","documentation":"Raised by the pypdf fallback branch of _extract_pdf when neither pymupdf nor pypdf could be imported. The module degrades gracefully at import time, so PDF extraction only fails at call time when no reader library exists in the environment.","triggerScenarios":"Running in a minimal install (deeptutor-cli without PDF extras) and calling extract_text_from_bytes on a .pdf; a venv where pymupdf/pypdf were uninstalled or failed to build.","commonSituations":"Slim Docker images or CI environments that trimmed optional dependencies; pip resolver dropping pymupdf due to a conflicting pin on another package.","solutions":["Install a PDF reader: pip install pymupdf (preferred) or pip install pypdf","If installation conflicts, check pip check / dependency pins that exclude pymupdf and loosen them","Pre-check import fitz or pypdf before offering PDF upload in the UI/API"],"exampleFix":"// before\n# environment lacks pymupdf and pypdf\ntext = extract_text_from_bytes(data, filename=\"doc.pdf\")  # raises\n\n// after\npip install pymupdf\ntext = extract_text_from_bytes(data, filename=\"doc.pdf\")","handlingStrategy":"validation","validationCode":"def pdf_reader_available() -> bool:\n    try:\n        import fitz  # noqa\n        return True\n    except ImportError:\n        pass\n    try:\n        import pypdf  # noqa\n        return True\n    except ImportError:\n        return False\n\nassert pdf_reader_available(), \"install pymupdf or pypdf to ingest PDFs\"","typeGuard":null,"tryCatchPattern":"try:\n    text = extract_text_from_bytes(data, filename=fn)\nexcept CorruptDocumentError as e:\n    if \"no PDF reader available\" in str(e):\n        raise RuntimeError(\"missing dependency: pip install pymupdf\") from e","preventionTips":["Include pymupdf in deployment dependency locks","Run a dependency smoke test at service startup for each ingest format you support"],"tags":["pdf","missing-dependency","pymupdf","pypdf"],"backgroundTag":"missing-optional-dependency","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}